mirror of
https://github.com/go-acme/lego
synced 2026-03-14 14:35:48 +01:00
chore: extend conditional option
This commit is contained in:
parent
e76dcf035b
commit
c8a455c506
2 changed files with 20 additions and 9 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue