mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 02:09:56 +00:00
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:
parent
8415ae647d
commit
e389b2723e
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user