diff --git a/hack/.golint_failures b/hack/.golint_failures index b88d3e2be79..48dcf65711e 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -261,7 +261,6 @@ staging/src/k8s.io/apimachinery/pkg/apis/meta/v1beta1 staging/src/k8s.io/apimachinery/pkg/apis/testapigroup staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1 staging/src/k8s.io/apimachinery/pkg/conversion -staging/src/k8s.io/apimachinery/pkg/labels staging/src/k8s.io/apimachinery/pkg/runtime staging/src/k8s.io/apimachinery/pkg/runtime/schema staging/src/k8s.io/apimachinery/pkg/runtime/serializer diff --git a/pkg/registry/admissionregistration/mutatingwebhookconfiguration/strategy.go b/pkg/registry/admissionregistration/mutatingwebhookconfiguration/strategy.go index 0b316abe264..6f5ea4aeadb 100644 --- a/pkg/registry/admissionregistration/mutatingwebhookconfiguration/strategy.go +++ b/pkg/registry/admissionregistration/mutatingwebhookconfiguration/strategy.go @@ -39,7 +39,7 @@ type mutatingWebhookConfigurationStrategy struct { // Strategy is the default logic that applies when creating and updating mutatingWebhookConfiguration objects. var Strategy = mutatingWebhookConfigurationStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} -// NamespaceScoped returns true because all mutatingWebhookConfiguration' need to be within a namespace. +// NamespaceScoped returns false because MutatingWebhookConfiguration is cluster-scoped resource. func (mutatingWebhookConfigurationStrategy) NamespaceScoped() bool { return false } diff --git a/pkg/registry/admissionregistration/validatingwebhookconfiguration/strategy.go b/pkg/registry/admissionregistration/validatingwebhookconfiguration/strategy.go index 494012e3d13..8f22af2b978 100644 --- a/pkg/registry/admissionregistration/validatingwebhookconfiguration/strategy.go +++ b/pkg/registry/admissionregistration/validatingwebhookconfiguration/strategy.go @@ -39,7 +39,7 @@ type validatingWebhookConfigurationStrategy struct { // Strategy is the default logic that applies when creating and updating validatingWebhookConfiguration objects. var Strategy = validatingWebhookConfigurationStrategy{legacyscheme.Scheme, names.SimpleNameGenerator} -// NamespaceScoped returns true because all validatingWebhookConfiguration' need to be within a namespace. +// NamespaceScoped returns false because ValidatingWebhookConfiguration is cluster-scoped resource. func (validatingWebhookConfigurationStrategy) NamespaceScoped() bool { return false } diff --git a/staging/src/k8s.io/api/core/v1/resource.go b/staging/src/k8s.io/api/core/v1/resource.go index 5bc9cd5bf1b..6a8c7062053 100644 --- a/staging/src/k8s.io/api/core/v1/resource.go +++ b/staging/src/k8s.io/api/core/v1/resource.go @@ -21,43 +21,43 @@ import ( ) // Returns string version of ResourceName. -func (self ResourceName) String() string { - return string(self) +func (rn ResourceName) String() string { + return string(rn) } // Returns the CPU limit if specified. -func (self *ResourceList) Cpu() *resource.Quantity { - if val, ok := (*self)[ResourceCPU]; ok { +func (rl *ResourceList) Cpu() *resource.Quantity { + if val, ok := (*rl)[ResourceCPU]; ok { return &val } return &resource.Quantity{Format: resource.DecimalSI} } // Returns the Memory limit if specified. -func (self *ResourceList) Memory() *resource.Quantity { - if val, ok := (*self)[ResourceMemory]; ok { +func (rl *ResourceList) Memory() *resource.Quantity { + if val, ok := (*rl)[ResourceMemory]; ok { return &val } return &resource.Quantity{Format: resource.BinarySI} } // Returns the Storage limit if specified. -func (self *ResourceList) Storage() *resource.Quantity { - if val, ok := (*self)[ResourceStorage]; ok { +func (rl *ResourceList) Storage() *resource.Quantity { + if val, ok := (*rl)[ResourceStorage]; ok { return &val } return &resource.Quantity{Format: resource.BinarySI} } -func (self *ResourceList) Pods() *resource.Quantity { - if val, ok := (*self)[ResourcePods]; ok { +func (rl *ResourceList) Pods() *resource.Quantity { + if val, ok := (*rl)[ResourcePods]; ok { return &val } return &resource.Quantity{} } -func (self *ResourceList) StorageEphemeral() *resource.Quantity { - if val, ok := (*self)[ResourceEphemeralStorage]; ok { +func (rl *ResourceList) StorageEphemeral() *resource.Quantity { + if val, ok := (*rl)[ResourceEphemeralStorage]; ok { return &val } return &resource.Quantity{} diff --git a/staging/src/k8s.io/apimachinery/pkg/labels/selector.go b/staging/src/k8s.io/apimachinery/pkg/labels/selector.go index 9324a1a6c37..50ae4f7cef4 100644 --- a/staging/src/k8s.io/apimachinery/pkg/labels/selector.go +++ b/staging/src/k8s.io/apimachinery/pkg/labels/selector.go @@ -263,11 +263,11 @@ func (r *Requirement) Values() sets.String { } // Empty returns true if the internalSelector doesn't restrict selection space -func (lsel internalSelector) Empty() bool { - if lsel == nil { +func (s internalSelector) Empty() bool { + if s == nil { return true } - return len(lsel) == 0 + return len(s) == 0 } // String returns a human-readable string that represents this @@ -330,51 +330,51 @@ func safeSort(in []string) []string { } // Add adds requirements to the selector. It copies the current selector returning a new one -func (lsel internalSelector) Add(reqs ...Requirement) Selector { - var sel internalSelector - for ix := range lsel { - sel = append(sel, lsel[ix]) +func (s internalSelector) Add(reqs ...Requirement) Selector { + var ret internalSelector + for ix := range s { + ret = append(ret, s[ix]) } for _, r := range reqs { - sel = append(sel, r) + ret = append(ret, r) } - sort.Sort(ByKey(sel)) - return sel + sort.Sort(ByKey(ret)) + return ret } // Matches for a internalSelector returns true if all // its Requirements match the input Labels. If any // Requirement does not match, false is returned. -func (lsel internalSelector) Matches(l Labels) bool { - for ix := range lsel { - if matches := lsel[ix].Matches(l); !matches { +func (s internalSelector) Matches(l Labels) bool { + for ix := range s { + if matches := s[ix].Matches(l); !matches { return false } } return true } -func (lsel internalSelector) Requirements() (Requirements, bool) { return Requirements(lsel), true } +func (s internalSelector) Requirements() (Requirements, bool) { return Requirements(s), true } // String returns a comma-separated string of all // the internalSelector Requirements' human-readable strings. -func (lsel internalSelector) String() string { +func (s internalSelector) String() string { var reqs []string - for ix := range lsel { - reqs = append(reqs, lsel[ix].String()) + for ix := range s { + reqs = append(reqs, s[ix].String()) } return strings.Join(reqs, ",") } // RequiresExactMatch introspect whether a given selector requires a single specific field // to be set, and if so returns the value it requires. -func (lsel internalSelector) RequiresExactMatch(label string) (value string, found bool) { - for ix := range lsel { - if lsel[ix].key == label { - switch lsel[ix].operator { +func (s internalSelector) RequiresExactMatch(label string) (value string, found bool) { + for ix := range s { + if s[ix].key == label { + switch s[ix].operator { case selection.Equals, selection.DoubleEquals, selection.In: - if len(lsel[ix].strValues) == 1 { - return lsel[ix].strValues[0], true + if len(s[ix].strValues) == 1 { + return s[ix].strValues[0], true } } return "", false