Skip to content

Commit

Permalink
fix: multiple resolvers.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Sep 30, 2019
1 parent f8e2d89 commit 574db1a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions dumper/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
32 changes: 20 additions & 12 deletions dumper/v2/dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -35,24 +35,32 @@ func Dump(data *acme.StoredData, baseConfig *dumper.BaseConfig) error {
return err
}

for _, cert := range data.Certificates {
err := writeCert(baseConfig.DumpPath, cert.Certificate, baseConfig.CrtInfo, baseConfig.DomainSubDir)
if err != nil {
return err
for _, store := range data {
for _, cert := range store.Certificates {
err := writeCert(baseConfig.DumpPath, cert.Certificate, baseConfig.CrtInfo, baseConfig.DomainSubDir)
if err != nil {
return err
}

err = writeKey(baseConfig.DumpPath, cert.Certificate, baseConfig.KeyInfo, baseConfig.DomainSubDir)
if err != nil {
return err
}
}

err = writeKey(baseConfig.DumpPath, cert.Certificate, baseConfig.KeyInfo, baseConfig.DomainSubDir)
if store.Account == nil {
continue
}

privateKeyPem := extractPEMPrivateKey(store.Account)

err := ioutil.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0600)
if err != nil {
return err
}
}

if data.Account == nil {
return nil
}

privateKeyPem := extractPEMPrivateKey(data.Account)
return ioutil.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0600)
return nil
}

func writeCert(dumpPath string, cert acme.Certificate, info dumper.FileInfo, domainSubDir bool) error {
Expand Down
35 changes: 0 additions & 35 deletions dumper/v2/storeddata.go

This file was deleted.

1 change: 0 additions & 1 deletion hook/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 574db1a

Please sign in to comment.