Validate dry-run and force flags can not be used same time in replace

This PR adds validation to check that `dry-run` and `force` flags
are not used at the same time. Because when `force` flag is set,
`dry-run` is discarded and objects are replaced already.
This commit is contained in:
Arda Güçlü 2022-06-01 14:01:40 +03:00
parent 8415ae647d
commit e389b2723e

View File

@ -227,6 +227,10 @@ func (o *ReplaceOptions) Validate() error {
return fmt.Errorf("--timeout must have --force specified")
}
if o.DeleteOptions.ForceDeletion && o.DryRunStrategy != cmdutil.DryRunNone {
return fmt.Errorf("dry-run can not be used when --force is set")
}
if cmdutil.IsFilenameSliceEmpty(o.DeleteOptions.FilenameOptions.Filenames, o.DeleteOptions.FilenameOptions.Kustomize) {
return fmt.Errorf("Must specify --filename to replace")
}