From 1c5c8601e479cc3b32809868c250aeb256796484 Mon Sep 17 00:00:00 2001 From: Sachin Kumar Singh Date: Wed, 2 Dec 2020 03:35:34 +0530 Subject: [PATCH] Fix typos and add comments in functions for `kubectl create` subcommands Certain missing comments and typos in comments are fixed in the files that implement `kubectl create` subcommands. --- staging/src/k8s.io/kubectl/pkg/cmd/create/create_cronjob.go | 4 ++++ .../src/k8s.io/kubectl/pkg/cmd/create/create_deployment.go | 2 ++ .../src/k8s.io/kubectl/pkg/cmd/create/create_priorityclass.go | 1 + .../src/k8s.io/kubectl/pkg/cmd/create/create_rolebinding.go | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/create/create_cronjob.go b/staging/src/k8s.io/kubectl/pkg/cmd/create/create_cronjob.go index 758ae0db480..a9be3563a01 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/create/create_cronjob.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/create/create_cronjob.go @@ -49,6 +49,7 @@ var ( kubectl create cronjob my-job --image=busybox --schedule="*/1 * * * *" -- date`) ) +// CreateCronJobOptions is returned by NewCreateCronJobOptions type CreateCronJobOptions struct { PrintFlags *genericclioptions.PrintFlags @@ -72,6 +73,7 @@ type CreateCronJobOptions struct { genericclioptions.IOStreams } +// NewCreateCronJobOptions returns an initialized CreateCronJobOptions instance func NewCreateCronJobOptions(ioStreams genericclioptions.IOStreams) *CreateCronJobOptions { return &CreateCronJobOptions{ PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme), @@ -110,6 +112,7 @@ func NewCmdCreateCronJob(f cmdutil.Factory, ioStreams genericclioptions.IOStream return cmd } +// Complete completes all the required options func (o *CreateCronJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []string) error { name, err := NameFromCommandArgs(cmd, args) if err != nil { @@ -165,6 +168,7 @@ func (o *CreateCronJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, a return nil } +// Run performs the execution of 'create cronjob' sub command func (o *CreateCronJobOptions) Run() error { cronjob := o.createCronJob() diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/create/create_deployment.go b/staging/src/k8s.io/kubectl/pkg/cmd/create/create_deployment.go index b28b09b6b0f..b542c976854 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/create/create_deployment.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/create/create_deployment.go @@ -79,6 +79,7 @@ type CreateDeploymentOptions struct { genericclioptions.IOStreams } +// NewCreateDeploymentOptions returns an initialized CreateDeploymentOptions instance func NewCreateDeploymentOptions(ioStreams genericclioptions.IOStreams) *CreateDeploymentOptions { return &CreateDeploymentOptions{ Port: -1, @@ -173,6 +174,7 @@ func (o *CreateDeploymentOptions) Complete(f cmdutil.Factory, cmd *cobra.Command return nil } +// Validate makes sure there is no discrepency in provided option values func (o *CreateDeploymentOptions) Validate() error { if len(o.Images) > 1 && len(o.Command) > 0 { return fmt.Errorf("cannot specify multiple --image options and command") diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/create/create_priorityclass.go b/staging/src/k8s.io/kubectl/pkg/cmd/create/create_priorityclass.go index 8062e5923d4..d709d78c17c 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/create/create_priorityclass.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/create/create_priorityclass.go @@ -71,6 +71,7 @@ type PriorityClassOptions struct { genericclioptions.IOStreams } +// NewPriorityClassOptions returns an initialized PriorityClassOptions instance func NewPriorityClassOptions(ioStreams genericclioptions.IOStreams) *PriorityClassOptions { return &PriorityClassOptions{ Value: 0, diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/create/create_rolebinding.go b/staging/src/k8s.io/kubectl/pkg/cmd/create/create_rolebinding.go index 10e0a144c50..d2932d271b3 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/create/create_rolebinding.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/create/create_rolebinding.go @@ -45,7 +45,7 @@ var ( kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1`)) ) -// RoleBindingOpts holds the options for 'create rolebinding' sub command +// RoleBindingOptions holds the options for 'create rolebinding' sub command type RoleBindingOptions struct { PrintFlags *genericclioptions.PrintFlags PrintObj func(obj runtime.Object) error