mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-21 09:57:52 +00:00
Merge pull request #88133 from julianvmodesto/dry-run-tests
Cleanup --dry-run values in tests, docs, and scripts
This commit is contained in:
@@ -104,9 +104,9 @@ func NewCmdReconcile(f cmdutil.Factory, streams genericclioptions.IOStreams) *co
|
||||
o.PrintFlags.AddFlags(cmd)
|
||||
|
||||
cmdutil.AddFilenameOptionFlags(cmd, o.FilenameOptions, "identifying the resource to reconcile.")
|
||||
cmd.Flags().BoolVar(&o.DryRun, "dry-run", o.DryRun, "If true, display results but do not submit changes")
|
||||
cmd.Flags().BoolVar(&o.RemoveExtraPermissions, "remove-extra-permissions", o.RemoveExtraPermissions, "If true, removes extra permissions added to roles")
|
||||
cmd.Flags().BoolVar(&o.RemoveExtraSubjects, "remove-extra-subjects", o.RemoveExtraSubjects, "If true, removes extra subjects added to rolebindings")
|
||||
cmdutil.AddDryRunFlag(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -121,6 +121,8 @@ func (o *ReconcileOptions) Complete(cmd *cobra.Command, f cmdutil.Factory, args
|
||||
return errors.New("no arguments are allowed")
|
||||
}
|
||||
|
||||
o.DryRun = getClientSideDryRun(cmd)
|
||||
|
||||
namespace, enforceNamespace, err := f.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -328,3 +330,14 @@ func (o *ReconcileOptions) printResults(object runtime.Object,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getClientSideDryRun(cmd *cobra.Command) bool {
|
||||
dryRunStrategy, err := cmdutil.GetDryRunStrategy(cmd)
|
||||
if err != nil {
|
||||
klog.Fatalf("error accessing --dry-run flag for command %s: %v", cmd.Name(), err)
|
||||
}
|
||||
if dryRunStrategy == cmdutil.DryRunServer {
|
||||
klog.Fatalf("--dry-run=server for command %s is not supported yet", cmd.Name())
|
||||
}
|
||||
return dryRunStrategy == cmdutil.DryRunClient
|
||||
}
|
||||
|
Reference in New Issue
Block a user