Merge pull request #110326 from ardaguclu/add-validation-replace

Validate dry-run and force flags can not be used same time in replace
This commit is contained in:
Kubernetes Prow Robot 2022-07-07 20:35:45 -07:00 committed by GitHub
commit ebcc5834f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -227,8 +227,12 @@ func (o *ReplaceOptions) Validate() error {
return fmt.Errorf("--timeout must have --force specified") 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) { if cmdutil.IsFilenameSliceEmpty(o.DeleteOptions.FilenameOptions.Filenames, o.DeleteOptions.FilenameOptions.Kustomize) {
return fmt.Errorf("Must specify --filename to replace") return fmt.Errorf("must specify --filename to replace")
} }
if len(o.Raw) > 0 { if len(o.Raw) > 0 {