diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/replace/replace.go b/staging/src/k8s.io/kubectl/pkg/cmd/replace/replace.go index 37478fd5f98..bb6fc0289d1 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/replace/replace.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/replace/replace.go @@ -227,8 +227,12 @@ 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") + return fmt.Errorf("must specify --filename to replace") } if len(o.Raw) > 0 {