refactor: remane old KV account format.
This commit is contained in:
parent
07c396dea5
commit
6c974f7903
@ -6,8 +6,8 @@ import (
|
|||||||
"github.com/ldez/traefik-certs-dumper/v2/dumper"
|
"github.com/ldez/traefik-certs-dumper/v2/dumper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CertificateV1 is used to store certificate info
|
// CertificateOld is used to store certificate info
|
||||||
type CertificateV1 struct {
|
type CertificateOld struct {
|
||||||
Domain string
|
Domain string
|
||||||
CertURL string
|
CertURL string
|
||||||
CertStableURL string
|
CertStableURL string
|
||||||
@ -15,8 +15,8 @@ type CertificateV1 struct {
|
|||||||
Certificate []byte
|
Certificate []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountV1 is used to store lets encrypt registration info
|
// AccountOld is used to store lets encrypt registration info
|
||||||
type AccountV1 struct {
|
type AccountOld struct {
|
||||||
Email string
|
Email string
|
||||||
Registration *registration.Resource
|
Registration *registration.Resource
|
||||||
PrivateKey []byte
|
PrivateKey []byte
|
||||||
@ -40,11 +40,11 @@ type ChallengeCert struct {
|
|||||||
// DomainsCertificate contains a certificate for multiple domains
|
// DomainsCertificate contains a certificate for multiple domains
|
||||||
type DomainsCertificate struct {
|
type DomainsCertificate struct {
|
||||||
Domains dumper.Domain
|
Domains dumper.Domain
|
||||||
Certificate *CertificateV1
|
Certificate *CertificateOld
|
||||||
}
|
}
|
||||||
|
|
||||||
// convertAccountV1ToV2 converts account information from version 1 to 2
|
// convertOldAccount converts account information from old account format.
|
||||||
func convertAccountV1ToV2(account *AccountV1) *dumper.StoredData {
|
func convertOldAccount(account *AccountOld) *dumper.StoredData {
|
||||||
storedData := &dumper.StoredData{}
|
storedData := &dumper.StoredData{}
|
||||||
storedData.Account = &dumper.Account{
|
storedData.Account = &dumper.Account{
|
||||||
PrivateKey: account.PrivateKey,
|
PrivateKey: account.PrivateKey,
|
||||||
|
|||||||
@ -86,12 +86,12 @@ func getStoredDataFromGzip(pair *store.KVPair) (*dumper.StoredData, error) {
|
|||||||
return nil, fmt.Errorf("unable to read the pair content: %v", err)
|
return nil, fmt.Errorf("unable to read the pair content: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
account := &AccountV1{}
|
account := &AccountOld{}
|
||||||
if err := json.Unmarshal(acmeData, &account); err != nil {
|
if err := json.Unmarshal(acmeData, &account); err != nil {
|
||||||
return nil, fmt.Errorf("unable marshal AccountV1: %v", err)
|
return nil, fmt.Errorf("unable marshal AccountOld: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return convertAccountV1ToV2(account), nil
|
return convertOldAccount(account), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isDebug() bool {
|
func isDebug() bool {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user