Staticcheck: vendor/k8s.io/pkg/cmd/set|edit
Kubernetes-commit: 2b8e60bb21358608cfa46942e0b3210eee263ea8
This commit is contained in:
parent
331c786cb4
commit
454ffd5141
|
@ -17,8 +17,6 @@ limitations under the License.
|
||||||
package edit
|
package edit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
|
@ -77,7 +75,7 @@ func NewCmdEdit(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
Short: i18n.T("Edit a resource on the server"),
|
Short: i18n.T("Edit a resource on the server"),
|
||||||
Long: editLong,
|
Long: editLong,
|
||||||
Example: fmt.Sprintf(editExample),
|
Example: editExample,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := o.Complete(f, args, cmd); err != nil {
|
if err := o.Complete(f, args, cmd); err != nil {
|
||||||
cmdutil.CheckErr(err)
|
cmdutil.CheckErr(err)
|
||||||
|
|
|
@ -54,6 +54,7 @@ func selectString(s, spec string) bool {
|
||||||
pos := 0
|
pos := 0
|
||||||
match := true
|
match := true
|
||||||
parts := strings.Split(spec, "*")
|
parts := strings.Split(spec, "*")
|
||||||
|
Loop:
|
||||||
for i, part := range parts {
|
for i, part := range parts {
|
||||||
if len(part) == 0 {
|
if len(part) == 0 {
|
||||||
continue
|
continue
|
||||||
|
@ -69,7 +70,7 @@ func selectString(s, spec string) bool {
|
||||||
// last part does not exactly match remaining part of string
|
// last part does not exactly match remaining part of string
|
||||||
case i == (len(parts)-1) && len(s) != (len(part)+next):
|
case i == (len(parts)-1) && len(s) != (len(part)+next):
|
||||||
match = false
|
match = false
|
||||||
break
|
break Loop
|
||||||
default:
|
default:
|
||||||
pos = next
|
pos = next
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ func NewCmdEnv(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Co
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
Short: "Update environment variables on a pod template",
|
Short: "Update environment variables on a pod template",
|
||||||
Long: envLong,
|
Long: envLong,
|
||||||
Example: fmt.Sprintf(envExample),
|
Example: envExample,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cmdutil.CheckErr(o.Complete(f, cmd, args))
|
cmdutil.CheckErr(o.Complete(f, cmd, args))
|
||||||
cmdutil.CheckErr(o.Validate())
|
cmdutil.CheckErr(o.Validate())
|
||||||
|
|
|
@ -175,6 +175,9 @@ func (o *SetSelectorOptions) RunSelector() error {
|
||||||
r := o.ResourceFinder.Do()
|
r := o.ResourceFinder.Do()
|
||||||
|
|
||||||
return r.Visit(func(info *resource.Info, err error) error {
|
return r.Visit(func(info *resource.Info, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
patch := &Patch{Info: info}
|
patch := &Patch{Info: info}
|
||||||
|
|
||||||
if len(o.resourceVersion) != 0 {
|
if len(o.resourceVersion) != 0 {
|
||||||
|
|
|
@ -411,7 +411,7 @@ func TestAddSubject(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
changed := false
|
changed := false
|
||||||
got := []rbacv1.Subject{}
|
var got []rbacv1.Subject
|
||||||
if changed, got = addSubjects(tt.existing, tt.subjects); (changed != false) != tt.wantChange {
|
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)
|
t.Errorf("%q. addSubjects() changed = %v, wantChange = %v", tt.Name, changed, tt.wantChange)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue