Skip to content

Commit

Permalink
StoreConfig always initializes the account if it is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldcroes authored and traefiker committed Sep 3, 2018
1 parent 0f0ba09 commit e4bb506
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cmd/storeconfig/storeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ func Run(kv *staert.KvSource, traefikConfiguration *cmd.TraefikConfiguration) fu
}
}

accountInitialized, err := keyExists(kv, traefikConfiguration.GlobalConfiguration.ACME.Storage)
if err != nil {
return err
}

// Check to see if ACME account object is already in kv store
if traefikConfiguration.GlobalConfiguration.ACME.OverrideCertificates {
if traefikConfiguration.GlobalConfiguration.ACME.OverrideCertificates || !accountInitialized {

// Store the ACME Account into the KV Store
// Certificates in KV Store will be overridden
Expand Down Expand Up @@ -114,6 +119,15 @@ func Run(kv *staert.KvSource, traefikConfiguration *cmd.TraefikConfiguration) fu
}
}

func keyExists(source *staert.KvSource, key string) (bool, error) {
list, err := source.List(key, nil)
if err != nil {
return false, err
}

return len(list) > 0, nil
}

// migrateACMEData allows migrating data from acme.json file to KV store in function of the file format
func migrateACMEData(fileName string) (*acme.Account, error) {

Expand Down

0 comments on commit e4bb506

Please sign in to comment.