mirror of
https://github.com/kubernetes/kubectl.git
synced 2026-05-28 04:35:50 -04: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. Kubernetes-commit: e389b2723e6af29a9f70509fe8ff6e5121c30681
This commit is contained in:
parent
3474b03beb
commit
bdaa26ce9e
1 changed files with 4 additions and 0 deletions
|
|
@ -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 a new issue