mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Add --expect-no-changes flag to preview (#449)
We want to offer a return-code oriented interface to detect changes pending to be applied. The preview command, by default, returns 0 regardless of pending changes. We add a flag, `--expect-no-changes`, that will return non-zero if there are changes pending application, and 0 if there are none.
This commit is contained in:
Miguel Bernabeu Diaz
committed by
Craig Peterson
parent
f6b26f24c6
commit
d4947fce23
@ -34,6 +34,7 @@ type PreviewArgs struct {
|
||||
GetCredentialsArgs
|
||||
FilterArgs
|
||||
Notify bool
|
||||
WarnChanges bool
|
||||
}
|
||||
|
||||
func (args *PreviewArgs) flags() []cli.Flag {
|
||||
@ -45,6 +46,11 @@ func (args *PreviewArgs) flags() []cli.Flag {
|
||||
Destination: &args.Notify,
|
||||
Usage: `set to true to send notifications to configured destinations`,
|
||||
})
|
||||
flags = append(flags, cli.BoolFlag{
|
||||
Name: "expect-no-changes",
|
||||
Destination: &args.WarnChanges,
|
||||
Usage: `set to true for non-zero return code if there are changes`,
|
||||
})
|
||||
return flags
|
||||
}
|
||||
|
||||
@ -165,6 +171,9 @@ DomainLoop:
|
||||
if anyErrors {
|
||||
return errors.Errorf("Completed with errors")
|
||||
}
|
||||
if totalCorrections != 0 && args.WarnChanges {
|
||||
return errors.Errorf("There are pending changes")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user