1
0
mirror of https://github.com/go-acme/lego.git synced 2025-11-30 00:58:21 +02:00

fix(cli): create client only when needed (#2372)

This commit is contained in:
Ludovic Fernandez
2024-12-03 14:03:49 +01:00
committed by GitHub
parent aacfa2b069
commit eb041044b8
5 changed files with 44 additions and 15 deletions

View File

@@ -18,7 +18,16 @@ import (
const filePerm os.FileMode = 0o600
func setup(ctx *cli.Context, accountsStorage *AccountsStorage) (*Account, *lego.Client) {
// setupClient creates a new client with challenge settings.
func setupClient(ctx *cli.Context, account *Account, keyType certcrypto.KeyType) *lego.Client {
client := newClient(ctx, account, keyType)
setupChallenges(ctx, client)
return client
}
func setupAccount(ctx *cli.Context, accountsStorage *AccountsStorage) (*Account, certcrypto.KeyType) {
keyType := getKeyType(ctx)
privateKey := accountsStorage.GetPrivateKey(keyType)
@@ -29,9 +38,7 @@ func setup(ctx *cli.Context, accountsStorage *AccountsStorage) (*Account, *lego.
account = &Account{Email: accountsStorage.GetUserID(), key: privateKey}
}
client := newClient(ctx, account, keyType)
return account, client
return account, keyType
}
func newClient(ctx *cli.Context, acc registration.User, keyType certcrypto.KeyType) *lego.Client {