Skip to content

Commit 2369eab

Browse files
committed
use cmdutil DryRun flag helper
1 parent d9d259b commit 2369eab

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

pkg/cmd/cli/cmd/create/clusterquota.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func NewCmdCreateClusterQuota(name, fullName string, f *clientcmd.Factory, out i
6262
}
6363

6464
cmdutil.AddPrinterFlags(cmd)
65-
cmd.Flags().BoolVarP(&o.DryRun, "dry-run", "", false, "If true, only print the object that would be sent, without sending it.")
65+
cmdutil.AddDryRunFlag(cmd)
6666
cmd.Flags().String("project-label-selector", "", "The project label selector for the cluster resource quota")
6767
cmd.Flags().String("project-annotation-selector", "", "The project annotation selector for the cluster resource quota")
6868
cmd.Flags().StringSlice("hard", []string{}, "The resource to constrain: RESOURCE=QUANTITY (pods=10)")
@@ -74,6 +74,8 @@ func (o *CreateClusterQuotaOptions) Complete(cmd *cobra.Command, f *clientcmd.Fa
7474
return fmt.Errorf("NAME is required: %v", args)
7575
}
7676

77+
o.DryRun = cmdutil.GetFlagBool(cmd, "dry-run")
78+
7779
var labelSelector *unversioned.LabelSelector
7880
labelSelectorString := cmdutil.GetFlagString(cmd, "project-label-selector")
7981
if len(labelSelectorString) > 0 {

pkg/cmd/cli/cmd/create/deploymentconfig.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ func NewCmdCreateDeploymentConfig(name, fullName string, f *clientcmd.Factory, o
5757
Aliases: []string{"dc"},
5858
}
5959

60-
cmd.Flags().BoolVarP(&o.DryRun, "dry-run", "", false, "If true, only print the object that would be sent, without sending it.")
6160
cmd.Flags().String("image", "", "The image for the container to run.")
6261
cmd.MarkFlagRequired("image")
62+
cmdutil.AddDryRunFlag(cmd)
6363
cmdutil.AddPrinterFlags(cmd)
6464
return cmd
6565
}
@@ -76,6 +76,7 @@ func (o *CreateDeploymentConfigOptions) Complete(cmd *cobra.Command, f *clientcm
7676

7777
labels := map[string]string{"deployment-config.name": args[0]}
7878

79+
o.DryRun = cmdutil.GetFlagBool(cmd, "dry-run")
7980
o.DC = &deployapi.DeploymentConfig{
8081
ObjectMeta: kapi.ObjectMeta{Name: args[0]},
8182
Spec: deployapi.DeploymentConfigSpec{

pkg/cmd/cli/cmd/create/identity.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func NewCmdCreateIdentity(name, fullName string, f *clientcmd.Factory, out io.Wr
6363
},
6464
}
6565

66-
cmd.Flags().BoolVarP(&o.DryRun, "dry-run", "", false, "If true, only print the object that would be sent, without sending it.")
66+
cmdutil.AddDryRunFlag(cmd)
6767
cmdutil.AddPrinterFlags(cmd)
6868
return cmd
6969
}
@@ -83,6 +83,8 @@ func (o *CreateIdentityOptions) Complete(cmd *cobra.Command, f *clientcmd.Factor
8383
return fmt.Errorf("exactly one argument (username) is supported, not: %v", args)
8484
}
8585

86+
o.DryRun = cmdutil.GetFlagBool(cmd, "dry-run")
87+
8688
client, _, err := f.Clients()
8789
if err != nil {
8890
return err

pkg/cmd/cli/cmd/create/imagestream.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func NewCmdCreateImageStream(name, fullName string, f *clientcmd.Factory, out io
5959
}
6060

6161
cmdutil.AddPrinterFlags(cmd)
62-
cmd.Flags().BoolVarP(&o.DryRun, "dry-run", "", false, "If true, only print the object that would be sent, without sending it.")
62+
cmdutil.AddDryRunFlag(cmd)
6363
return cmd
6464
}
6565

@@ -69,6 +69,8 @@ func (o *CreateImageStreamOptions) Complete(cmd *cobra.Command, f *clientcmd.Fac
6969
Spec: imageapi.ImageStreamSpec{},
7070
}
7171

72+
o.DryRun = cmdutil.GetFlagBool(cmd, "dry-run")
73+
7274
switch len(args) {
7375
case 0:
7476
return fmt.Errorf("image stream name is required")

pkg/cmd/cli/cmd/create/route.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func NewCmdCreateEdgeRoute(fullName string, f *clientcmd.Factory, out io.Writer)
7171

7272
kcmdutil.AddValidateFlags(cmd)
7373
kcmdutil.AddPrinterFlags(cmd)
74-
cmd.Flags().Bool("dry-run", false, "If true, only print the route that would be created, without creating it.")
74+
kcmdutil.AddDryRunFlag(cmd)
7575
cmd.Flags().String("hostname", "", "Set a hostname for the new route")
7676
cmd.Flags().String("port", "", "Name of the service port or number of the container port the route will route traffic to")
7777
cmd.Flags().String("insecure-policy", "", "Set an insecure policy for the new route")
@@ -198,7 +198,7 @@ func NewCmdCreatePassthroughRoute(fullName string, f *clientcmd.Factory, out io.
198198

199199
kcmdutil.AddValidateFlags(cmd)
200200
kcmdutil.AddPrinterFlags(cmd)
201-
cmd.Flags().Bool("dry-run", false, "If true, only print the route that would be created, without creating it.")
201+
kcmdutil.AddDryRunFlag(cmd)
202202
cmd.Flags().String("hostname", "", "Set a hostname for the new route")
203203
cmd.Flags().String("port", "", "Name of the service port or number of the container port the route will route traffic to")
204204
cmd.Flags().String("service", "", "Name of the service that the new route is exposing")
@@ -297,7 +297,7 @@ func NewCmdCreateReencryptRoute(fullName string, f *clientcmd.Factory, out io.Wr
297297

298298
kcmdutil.AddValidateFlags(cmd)
299299
kcmdutil.AddPrinterFlags(cmd)
300-
cmd.Flags().Bool("dry-run", false, "If true, only print the route that would be created, without creating it.")
300+
kcmdutil.AddDryRunFlag(cmd)
301301
cmd.Flags().String("hostname", "", "Set a hostname for the new route")
302302
cmd.Flags().String("port", "", "Name of the service port or number of the container port the route will route traffic to")
303303
cmd.Flags().String("service", "", "Name of the service that the new route is exposing")

pkg/cmd/cli/cmd/create/user.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func NewCmdCreateUser(name, fullName string, f *clientcmd.Factory, out io.Writer
6262
},
6363
}
6464
cmd.Flags().StringVar(&o.FullName, "full-name", o.FullName, "Display name of the user")
65-
cmd.Flags().BoolVarP(&o.DryRun, "dry-run", "", false, "If true, only print the object that would be sent, without sending it.")
65+
cmdutil.AddDryRunFlag(cmd)
6666
cmdutil.AddPrinterFlags(cmd)
6767
return cmd
6868
}
@@ -77,6 +77,8 @@ func (o *CreateUserOptions) Complete(cmd *cobra.Command, f *clientcmd.Factory, a
7777
return fmt.Errorf("exactly one argument (username) is supported, not: %v", args)
7878
}
7979

80+
o.DryRun = cmdutil.GetFlagBool(cmd, "dry-run")
81+
8082
client, _, err := f.Clients()
8183
if err != nil {
8284
return err

pkg/cmd/cli/cmd/create/user_identity_mapping.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func NewCmdCreateUserIdentityMapping(name, fullName string, f *clientcmd.Factory
5959
},
6060
}
6161
cmdutil.AddPrinterFlags(cmd)
62-
cmd.Flags().BoolVarP(&o.DryRun, "dry-run", "", false, "If true, only print the object that would be sent, without sending it.")
62+
cmdutil.AddDryRunFlag(cmd)
6363
return cmd
6464
}
6565

@@ -76,6 +76,8 @@ func (o *CreateUserIdentityMappingOptions) Complete(cmd *cobra.Command, f *clien
7676
return fmt.Errorf("exactly two arguments (identity and user name) are supported, not: %v", args)
7777
}
7878

79+
o.DryRun = cmdutil.GetFlagBool(cmd, "dry-run")
80+
7981
client, _, err := f.Clients()
8082
if err != nil {
8183
return err

0 commit comments

Comments
 (0)