Skip to content

Commit c349708

Browse files
committed
Do not use --force with --dry-run
Signed-off-by: rafal-jan <[email protected]>
1 parent cebed7e commit c349708

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/utils/kube/resource_ops.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ func (k *kubectlResourceOperations) ReplaceResource(ctx context.Context, obj *un
237237
if err != nil {
238238
return err
239239
}
240+
241+
if err := replaceOptions.Validate(); err != nil {
242+
return fmt.Errorf("error validating replace options: %w", err)
243+
}
244+
240245
return replaceOptions.Run(k.fact)
241246
})
242247
}
@@ -541,7 +546,11 @@ func (k *kubectlResourceOperations) newReplaceOptions(config *rest.Config, f cmd
541546

542547
o.DeleteOptions.Filenames = []string{fileName}
543548
o.Namespace = namespace
544-
o.DeleteOptions.ForceDeletion = force
549+
550+
if dryRunStrategy == cmdutil.DryRunNone {
551+
o.DeleteOptions.ForceDeletion = force
552+
}
553+
545554
return o, nil
546555
}
547556

0 commit comments

Comments
 (0)