Merge pull request #82233 from SataQiu/fix-golint-kubelet

Fix golint failures of pkg/kubelet
This commit is contained in:
Kubernetes Prow Robot 2019-09-11 10:41:19 -07:00 committed by GitHub
commit 252a7ecbe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -110,7 +110,6 @@ pkg/kubeapiserver
pkg/kubeapiserver/options pkg/kubeapiserver/options
pkg/kubectl/cmd/convert pkg/kubectl/cmd/convert
pkg/kubectl/cmd/get pkg/kubectl/cmd/get
pkg/kubelet
pkg/kubelet/apis/config pkg/kubelet/apis/config
pkg/kubelet/apis/config/v1beta1 pkg/kubelet/apis/config/v1beta1
pkg/kubelet/apis/deviceplugin/v1beta1 pkg/kubelet/apis/deviceplugin/v1beta1

View File

@ -40,8 +40,8 @@ type ReasonCache struct {
cache *lru.Cache cache *lru.Cache
} }
// Reason is the cached item in ReasonCache // ReasonItem is the cached item in ReasonCache
type reasonItem struct { type ReasonItem struct {
Err error Err error
Message string Message string
} }
@ -64,7 +64,7 @@ func (c *ReasonCache) composeKey(uid types.UID, name string) string {
func (c *ReasonCache) add(uid types.UID, name string, reason error, message string) { func (c *ReasonCache) add(uid types.UID, name string, reason error, message string) {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() defer c.lock.Unlock()
c.cache.Add(c.composeKey(uid, name), reasonItem{reason, message}) c.cache.Add(c.composeKey(uid, name), ReasonItem{reason, message})
} }
// Update updates the reason cache with the SyncPodResult. Only SyncResult with // Update updates the reason cache with the SyncPodResult. Only SyncResult with
@ -93,13 +93,13 @@ func (c *ReasonCache) Remove(uid types.UID, name string) {
// Get gets error reason from the cache. The return values are error reason, error message and // Get gets error reason from the cache. The return values are error reason, error message and
// whether an error reason is found in the cache. If no error reason is found, empty string will // whether an error reason is found in the cache. If no error reason is found, empty string will
// be returned for error reason and error message. // be returned for error reason and error message.
func (c *ReasonCache) Get(uid types.UID, name string) (*reasonItem, bool) { func (c *ReasonCache) Get(uid types.UID, name string) (*ReasonItem, bool) {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() defer c.lock.Unlock()
value, ok := c.cache.Get(c.composeKey(uid, name)) value, ok := c.cache.Get(c.composeKey(uid, name))
if !ok { if !ok {
return nil, false return nil, false
} }
info := value.(reasonItem) info := value.(ReasonItem)
return &info, true return &info, true
} }