diff --git a/hack/.staticcheck_failures b/hack/.staticcheck_failures index 5edbe8d6b71e..207f2b387bcb 100644 --- a/hack/.staticcheck_failures +++ b/hack/.staticcheck_failures @@ -91,9 +91,7 @@ vendor/k8s.io/client-go/restmapper vendor/k8s.io/client-go/tools/leaderelection vendor/k8s.io/client-go/transport vendor/k8s.io/component-base/metrics -vendor/k8s.io/kubectl/pkg/cmd/edit vendor/k8s.io/kubectl/pkg/cmd/get vendor/k8s.io/kubectl/pkg/cmd/scale -vendor/k8s.io/kubectl/pkg/cmd/set vendor/k8s.io/kubectl/pkg/cmd/testing vendor/k8s.io/metrics/pkg/client/custom_metrics diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/edit/edit.go b/staging/src/k8s.io/kubectl/pkg/cmd/edit/edit.go index 4a828dba5b86..993a2df0b930 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/edit/edit.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/edit/edit.go @@ -17,8 +17,6 @@ limitations under the License. package edit import ( - "fmt" - "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" @@ -77,7 +75,7 @@ func NewCmdEdit(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra DisableFlagsInUseLine: true, Short: i18n.T("Edit a resource on the server"), Long: editLong, - Example: fmt.Sprintf(editExample), + Example: editExample, Run: func(cmd *cobra.Command, args []string) { if err := o.Complete(f, args, cmd); err != nil { cmdutil.CheckErr(err) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/set/helper.go b/staging/src/k8s.io/kubectl/pkg/cmd/set/helper.go index 72cc7756056e..a60bcd634459 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/set/helper.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/set/helper.go @@ -54,6 +54,7 @@ func selectString(s, spec string) bool { pos := 0 match := true parts := strings.Split(spec, "*") +Loop: for i, part := range parts { if len(part) == 0 { continue @@ -69,7 +70,7 @@ func selectString(s, spec string) bool { // last part does not exactly match remaining part of string case i == (len(parts)-1) && len(s) != (len(part)+next): match = false - break + break Loop default: pos = next } diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/set/set_env.go b/staging/src/k8s.io/kubectl/pkg/cmd/set/set_env.go index 4501ae59a897..eaadad5342e8 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/set/set_env.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/set/set_env.go @@ -151,7 +151,7 @@ func NewCmdEnv(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Co DisableFlagsInUseLine: true, Short: "Update environment variables on a pod template", Long: envLong, - Example: fmt.Sprintf(envExample), + Example: envExample, Run: func(cmd *cobra.Command, args []string) { cmdutil.CheckErr(o.Complete(f, cmd, args)) cmdutil.CheckErr(o.Validate()) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/set/set_selector.go b/staging/src/k8s.io/kubectl/pkg/cmd/set/set_selector.go index 2abe2d7df754..df235c862367 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/set/set_selector.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/set/set_selector.go @@ -175,6 +175,9 @@ func (o *SetSelectorOptions) RunSelector() error { r := o.ResourceFinder.Do() return r.Visit(func(info *resource.Info, err error) error { + if err != nil { + return err + } patch := &Patch{Info: info} if len(o.resourceVersion) != 0 { diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/set/set_subject_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/set/set_subject_test.go index 91cb6e6cc429..d3393abb77c9 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/set/set_subject_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/set/set_subject_test.go @@ -411,7 +411,7 @@ func TestAddSubject(t *testing.T) { } for _, tt := range tests { changed := false - got := []rbacv1.Subject{} + var got []rbacv1.Subject if changed, got = addSubjects(tt.existing, tt.subjects); (changed != false) != tt.wantChange { t.Errorf("%q. addSubjects() changed = %v, wantChange = %v", tt.Name, changed, tt.wantChange) }