diff --git a/challenge/dns01/dns_challenge_options.go b/challenge/dns01/dns_challenge_options.go index 89995bf55..4359177da 100644 --- a/challenge/dns01/dns_challenge_options.go +++ b/challenge/dns01/dns_challenge_options.go @@ -10,8 +10,8 @@ import ( type ChallengeOption func(*Challenge) error -// CondOption Conditional challenge option. -func CondOption(condition bool, opt ChallengeOption) ChallengeOption { +// CondOptions Conditional challenge options. +func CondOptions(condition bool, opt ...ChallengeOption) ChallengeOption { if !condition { // NoOp options return func(*Challenge) error { @@ -19,7 +19,16 @@ func CondOption(condition bool, opt ChallengeOption) ChallengeOption { } } - return opt + return func(chlg *Challenge) error { + for _, opt := range opt { + err := opt(chlg) + if err != nil { + return err + } + } + + return nil + } } func DisableAuthoritativeNssPropagationRequirement() ChallengeOption { diff --git a/cmd/setup_challenges.go b/cmd/setup_challenges.go index d1339aaed..1d34e13d3 100644 --- a/cmd/setup_challenges.go +++ b/cmd/setup_challenges.go @@ -197,14 +197,16 @@ func setupDNS(cmd *cli.Command, client *lego.Client) error { shouldWait := cmd.IsSet(flgDNSPropagationWait) err = client.Challenge.SetDNS01Provider(provider, - dns01.CondOption(shouldWait, + dns01.CondOptions(shouldWait, dns01.PropagationWait(cmd.Duration(flgDNSPropagationWait), true), ), - dns01.CondOption(!shouldWait && cmd.Bool(flgDNSPropagationDisableANS), - dns01.DisableAuthoritativeNssPropagationRequirement(), - ), - dns01.CondOption(!shouldWait && cmd.Bool(flgDNSPropagationDisableRNS), - dns01.DisableRecursiveNSsPropagationRequirement(), + dns01.CondOptions(!shouldWait, + dns01.CondOptions(cmd.Bool(flgDNSPropagationDisableANS), + dns01.DisableAuthoritativeNssPropagationRequirement(), + ), + dns01.CondOptions(cmd.Bool(flgDNSPropagationDisableRNS), + dns01.DisableRecursiveNSsPropagationRequirement(), + ), ), )