fix: multiple resolvers.
This commit is contained in:
parent
f8e2d89d6c
commit
574db1a1e0
@ -35,7 +35,7 @@
|
||||
exclude-use-default = false
|
||||
max-per-linter = 0
|
||||
max-same-issues = 0
|
||||
exclude = []
|
||||
exclude = ["ST1000: at least one file in a package should have a package comment"]
|
||||
[[issues.exclude-rules]]
|
||||
path = "cmd/"
|
||||
linters = ["gochecknoglobals", "gochecknoinits"]
|
||||
|
||||
@ -60,8 +60,8 @@ func dumpV2(acmeFile string, baseConfig *dumper.BaseConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
data := &acme.StoredData{}
|
||||
if err = json.NewDecoder(source).Decode(data); err != nil {
|
||||
data := map[string]*acme.StoredData{}
|
||||
if err = json.NewDecoder(source).Decode(&data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ const (
|
||||
)
|
||||
|
||||
// Dump Dumps data to certificates.
|
||||
func Dump(data *acme.StoredData, baseConfig *dumper.BaseConfig) error {
|
||||
func Dump(data map[string]*acme.StoredData, baseConfig *dumper.BaseConfig) error {
|
||||
if baseConfig.Clean {
|
||||
err := cleanDir(baseConfig.DumpPath)
|
||||
if err != nil {
|
||||
@ -35,7 +35,8 @@ func Dump(data *acme.StoredData, baseConfig *dumper.BaseConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, cert := range data.Certificates {
|
||||
for _, store := range data {
|
||||
for _, cert := range store.Certificates {
|
||||
err := writeCert(baseConfig.DumpPath, cert.Certificate, baseConfig.CrtInfo, baseConfig.DomainSubDir)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -47,12 +48,19 @@ func Dump(data *acme.StoredData, baseConfig *dumper.BaseConfig) error {
|
||||
}
|
||||
}
|
||||
|
||||
if data.Account == nil {
|
||||
return nil
|
||||
if store.Account == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
privateKeyPem := extractPEMPrivateKey(data.Account)
|
||||
return ioutil.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0600)
|
||||
privateKeyPem := extractPEMPrivateKey(store.Account)
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func writeCert(dumpPath string, cert acme.Certificate, info dumper.FileInfo, domainSubDir bool) error {
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"github.com/go-acme/lego/v3/certcrypto"
|
||||
"github.com/go-acme/lego/v3/registration"
|
||||
)
|
||||
|
||||
// StoredData represents the data managed by the Store
|
||||
type StoredData struct {
|
||||
Account *Account
|
||||
Certificates []*Certificate
|
||||
HTTPChallenges map[string]map[string][]byte
|
||||
TLSChallenges map[string]*Certificate
|
||||
}
|
||||
|
||||
// Certificate is a struct which contains all data needed from an ACME certificate
|
||||
type Certificate struct {
|
||||
Domain Domain `json:"domain,omitempty"`
|
||||
Certificate []byte `json:"certificate,omitempty"`
|
||||
Key []byte `json:"key,omitempty"`
|
||||
}
|
||||
|
||||
// Domain holds a domain name with SANs
|
||||
type Domain struct {
|
||||
Main string `json:"main,omitempty"`
|
||||
SANs []string `json:"sans,omitempty"`
|
||||
}
|
||||
|
||||
// Account is used to store lets encrypt registration info
|
||||
type Account struct {
|
||||
Email string
|
||||
Registration *registration.Resource
|
||||
PrivateKey []byte
|
||||
KeyType certcrypto.KeyType
|
||||
}
|
||||
@ -19,7 +19,6 @@ func Test_execute(t *testing.T) {
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
|
||||
err := execute(test.command)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user