mirror of
https://github.com/go-acme/lego
synced 2026-03-14 14:35:48 +01:00
refactor: isolate storage configurations creation
This commit is contained in:
parent
c3d56b4412
commit
f6c577597e
1 changed files with 21 additions and 15 deletions
|
|
@ -16,16 +16,7 @@ type CertificatesStorage struct {
|
|||
func newCertificatesStorage(cmd *cli.Command) *CertificatesStorage {
|
||||
basePath := cmd.String(flgPath)
|
||||
|
||||
config := storage.CertificatesWriterConfig{
|
||||
BasePath: basePath,
|
||||
PEM: cmd.Bool(flgPEM),
|
||||
PFX: cmd.Bool(flgPFX),
|
||||
PFXFormat: cmd.String(flgPFXPass),
|
||||
PFXPassword: cmd.String(flgPFXFormat),
|
||||
Filename: cmd.String(flgFilename),
|
||||
}
|
||||
|
||||
writer, err := storage.NewCertificatesWriter(config)
|
||||
writer, err := storage.NewCertificatesWriter(newCertificatesWriterConfig(cmd, basePath))
|
||||
if err != nil {
|
||||
log.Fatal("Certificates storage initialization", log.ErrorAttr(err))
|
||||
}
|
||||
|
|
@ -36,17 +27,32 @@ func newCertificatesStorage(cmd *cli.Command) *CertificatesStorage {
|
|||
}
|
||||
}
|
||||
|
||||
func newCertificatesWriterConfig(cmd *cli.Command, basePath string) storage.CertificatesWriterConfig {
|
||||
return storage.CertificatesWriterConfig{
|
||||
BasePath: basePath,
|
||||
PEM: cmd.Bool(flgPEM),
|
||||
PFX: cmd.Bool(flgPFX),
|
||||
PFXFormat: cmd.String(flgPFXPass),
|
||||
PFXPassword: cmd.String(flgPFXFormat),
|
||||
Filename: cmd.String(flgFilename),
|
||||
}
|
||||
}
|
||||
|
||||
// newAccountsStorage Creates a new AccountsStorage.
|
||||
func newAccountsStorage(cmd *cli.Command) *storage.AccountsStorage {
|
||||
accountsStorage, err := storage.NewAccountsStorage(storage.AccountsStorageConfig{
|
||||
Email: cmd.String(flgEmail),
|
||||
BasePath: cmd.String(flgPath),
|
||||
Server: cmd.String(flgServer),
|
||||
UserAgent: getUserAgent(cmd),
|
||||
})
|
||||
accountsStorage, err := storage.NewAccountsStorage(newAccountsStorageConfig(cmd))
|
||||
if err != nil {
|
||||
log.Fatal("Accounts storage initialization", log.ErrorAttr(err))
|
||||
}
|
||||
|
||||
return accountsStorage
|
||||
}
|
||||
|
||||
func newAccountsStorageConfig(cmd *cli.Command) storage.AccountsStorageConfig {
|
||||
return storage.AccountsStorageConfig{
|
||||
Email: cmd.String(flgEmail),
|
||||
BasePath: cmd.String(flgPath),
|
||||
Server: cmd.String(flgServer),
|
||||
UserAgent: getUserAgent(cmd),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue