mirror of
https://github.com/go-acme/lego
synced 2026-03-14 14:35:48 +01:00
refactor: add func to get User-Agent without flags
This commit is contained in:
parent
0fabf2bda4
commit
3a9480759e
1 changed files with 8 additions and 4 deletions
12
cmd/setup.go
12
cmd/setup.go
|
|
@ -36,7 +36,7 @@ func newClient(cmd *cli.Command, account registration.User, keyType certcrypto.K
|
|||
func newClientConfig(cmd *cli.Command, account registration.User, keyType certcrypto.KeyType) *lego.Config {
|
||||
config := lego.NewConfig(account)
|
||||
config.CADirURL = cmd.String(flags.FlgServer)
|
||||
config.UserAgent = getUserAgent(cmd)
|
||||
config.UserAgent = getUserAgentFromFlag(cmd)
|
||||
|
||||
config.Certificate = lego.CertificateConfig{
|
||||
KeyType: keyType,
|
||||
|
|
@ -62,8 +62,12 @@ func newClientConfig(cmd *cli.Command, account registration.User, keyType certcr
|
|||
return config
|
||||
}
|
||||
|
||||
func getUserAgent(cmd *cli.Command) string {
|
||||
return strings.TrimSpace(fmt.Sprintf("%s lego-cli/%s", cmd.String(flags.FlgUserAgent), cmd.Version))
|
||||
func getUserAgentFromFlag(cmd *cli.Command) string {
|
||||
return getUserAgent(cmd, cmd.String(flags.FlgUserAgent))
|
||||
}
|
||||
|
||||
func getUserAgent(cmd *cli.Command, ua string) string {
|
||||
return strings.TrimSpace(fmt.Sprintf("%s lego-cli/%s", ua, cmd.Version))
|
||||
}
|
||||
|
||||
func newObtainRequest(cmd *cli.Command, domains []string) certificate.ObtainRequest {
|
||||
|
|
@ -97,7 +101,7 @@ func newAccountsStorageConfig(cmd *cli.Command) storage.AccountsStorageConfig {
|
|||
return storage.AccountsStorageConfig{
|
||||
BasePath: cmd.String(flags.FlgPath),
|
||||
Server: cmd.String(flags.FlgServer),
|
||||
UserAgent: getUserAgent(cmd),
|
||||
UserAgent: getUserAgentFromFlag(cmd),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue