From 0649f4064e9c6751bee63b14e25bea563a6d3ec4 Mon Sep 17 00:00:00 2001 From: clarklee92 Date: Thu, 7 Nov 2019 21:44:22 +0800 Subject: [PATCH] Variables collides with imported package name Such declarations will make using the package exported identifiers impossible after the declaration or create confusion when reading the code. Signed-off-by: clarklee92 --- pkg/registry/core/pod/storage/storage.go | 20 +++++++++---------- pkg/registry/core/pod/storage/storage_test.go | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/registry/core/pod/storage/storage.go b/pkg/registry/core/pod/storage/storage.go index f005bef0f1e..d0565145744 100644 --- a/pkg/registry/core/pod/storage/storage.go +++ b/pkg/registry/core/pod/storage/storage.go @@ -42,7 +42,7 @@ import ( "k8s.io/kubernetes/pkg/printers" printersinternal "k8s.io/kubernetes/pkg/printers/internalversion" printerstorage "k8s.io/kubernetes/pkg/printers/storage" - "k8s.io/kubernetes/pkg/registry/core/pod" + registrypod "k8s.io/kubernetes/pkg/registry/core/pod" podrest "k8s.io/kubernetes/pkg/registry/core/pod/rest" ) @@ -73,29 +73,29 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGet store := &genericregistry.Store{ NewFunc: func() runtime.Object { return &api.Pod{} }, NewListFunc: func() runtime.Object { return &api.PodList{} }, - PredicateFunc: pod.MatchPod, + PredicateFunc: registrypod.MatchPod, DefaultQualifiedResource: api.Resource("pods"), - CreateStrategy: pod.Strategy, - UpdateStrategy: pod.Strategy, - DeleteStrategy: pod.Strategy, + CreateStrategy: registrypod.Strategy, + UpdateStrategy: registrypod.Strategy, + DeleteStrategy: registrypod.Strategy, ReturnDeletedObject: true, TableConvertor: printerstorage.TableConvertor{TableGenerator: printers.NewTableGenerator().With(printersinternal.AddHandlers)}, } options := &generic.StoreOptions{ RESTOptions: optsGetter, - AttrFunc: pod.GetAttrs, - TriggerFunc: map[string]storage.IndexerFunc{"spec.nodeName": pod.NodeNameTriggerFunc}, + AttrFunc: registrypod.GetAttrs, + TriggerFunc: map[string]storage.IndexerFunc{"spec.nodeName": registrypod.NodeNameTriggerFunc}, } if err := store.CompleteWithOptions(options); err != nil { return PodStorage{}, err } statusStore := *store - statusStore.UpdateStrategy = pod.StatusStrategy + statusStore.UpdateStrategy = registrypod.StatusStrategy ephemeralContainersStore := *store - ephemeralContainersStore.UpdateStrategy = pod.EphemeralContainersStrategy + ephemeralContainersStore.UpdateStrategy = registrypod.EphemeralContainersStrategy bindingREST := &BindingREST{store: store} return PodStorage{ @@ -118,7 +118,7 @@ var _ = rest.Redirector(&REST{}) // ResourceLocation returns a pods location from its HostIP func (r *REST) ResourceLocation(ctx context.Context, name string) (*url.URL, http.RoundTripper, error) { - return pod.ResourceLocation(r, r.proxyTransport, ctx, name) + return registrypod.ResourceLocation(r, r.proxyTransport, ctx, name) } // Implement ShortNamesProvider diff --git a/pkg/registry/core/pod/storage/storage_test.go b/pkg/registry/core/pod/storage/storage_test.go index b511720ebe1..4d53ea89718 100644 --- a/pkg/registry/core/pod/storage/storage_test.go +++ b/pkg/registry/core/pod/storage/storage_test.go @@ -36,7 +36,7 @@ import ( genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing" "k8s.io/apiserver/pkg/registry/rest" - "k8s.io/apiserver/pkg/storage" + apiserverstorage "k8s.io/apiserver/pkg/storage" storeerr "k8s.io/apiserver/pkg/storage/errors" etcd3testing "k8s.io/apiserver/pkg/storage/etcd3/testing" api "k8s.io/kubernetes/pkg/apis/core" @@ -155,13 +155,13 @@ func TestDelete(t *testing.T) { } type FailDeletionStorage struct { - storage.Interface + apiserverstorage.Interface Called *bool } -func (f FailDeletionStorage) Delete(ctx context.Context, key string, out runtime.Object, precondition *storage.Preconditions, _ storage.ValidateObjectFunc) error { +func (f FailDeletionStorage) Delete(ctx context.Context, key string, out runtime.Object, precondition *apiserverstorage.Preconditions, _ apiserverstorage.ValidateObjectFunc) error { *f.Called = true - return storage.NewKeyNotFoundError(key, 0) + return apiserverstorage.NewKeyNotFoundError(key, 0) } func newFailDeleteStorage(t *testing.T, called *bool) (*REST, *etcd3testing.EtcdTestServer) {