Skip to content

Commit 0649f40

Browse files
committed
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 <[email protected]>
1 parent 0c0408c commit 0649f40

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

pkg/registry/core/pod/storage/storage.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
"k8s.io/kubernetes/pkg/printers"
4343
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
4444
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
45-
"k8s.io/kubernetes/pkg/registry/core/pod"
45+
registrypod "k8s.io/kubernetes/pkg/registry/core/pod"
4646
podrest "k8s.io/kubernetes/pkg/registry/core/pod/rest"
4747
)
4848

@@ -73,29 +73,29 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGet
7373
store := &genericregistry.Store{
7474
NewFunc: func() runtime.Object { return &api.Pod{} },
7575
NewListFunc: func() runtime.Object { return &api.PodList{} },
76-
PredicateFunc: pod.MatchPod,
76+
PredicateFunc: registrypod.MatchPod,
7777
DefaultQualifiedResource: api.Resource("pods"),
7878

79-
CreateStrategy: pod.Strategy,
80-
UpdateStrategy: pod.Strategy,
81-
DeleteStrategy: pod.Strategy,
79+
CreateStrategy: registrypod.Strategy,
80+
UpdateStrategy: registrypod.Strategy,
81+
DeleteStrategy: registrypod.Strategy,
8282
ReturnDeletedObject: true,
8383

8484
TableConvertor: printerstorage.TableConvertor{TableGenerator: printers.NewTableGenerator().With(printersinternal.AddHandlers)},
8585
}
8686
options := &generic.StoreOptions{
8787
RESTOptions: optsGetter,
88-
AttrFunc: pod.GetAttrs,
89-
TriggerFunc: map[string]storage.IndexerFunc{"spec.nodeName": pod.NodeNameTriggerFunc},
88+
AttrFunc: registrypod.GetAttrs,
89+
TriggerFunc: map[string]storage.IndexerFunc{"spec.nodeName": registrypod.NodeNameTriggerFunc},
9090
}
9191
if err := store.CompleteWithOptions(options); err != nil {
9292
return PodStorage{}, err
9393
}
9494

9595
statusStore := *store
96-
statusStore.UpdateStrategy = pod.StatusStrategy
96+
statusStore.UpdateStrategy = registrypod.StatusStrategy
9797
ephemeralContainersStore := *store
98-
ephemeralContainersStore.UpdateStrategy = pod.EphemeralContainersStrategy
98+
ephemeralContainersStore.UpdateStrategy = registrypod.EphemeralContainersStrategy
9999

100100
bindingREST := &BindingREST{store: store}
101101
return PodStorage{
@@ -118,7 +118,7 @@ var _ = rest.Redirector(&REST{})
118118

119119
// ResourceLocation returns a pods location from its HostIP
120120
func (r *REST) ResourceLocation(ctx context.Context, name string) (*url.URL, http.RoundTripper, error) {
121-
return pod.ResourceLocation(r, r.proxyTransport, ctx, name)
121+
return registrypod.ResourceLocation(r, r.proxyTransport, ctx, name)
122122
}
123123

124124
// Implement ShortNamesProvider

pkg/registry/core/pod/storage/storage_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
3737
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
3838
"k8s.io/apiserver/pkg/registry/rest"
39-
"k8s.io/apiserver/pkg/storage"
39+
apiserverstorage "k8s.io/apiserver/pkg/storage"
4040
storeerr "k8s.io/apiserver/pkg/storage/errors"
4141
etcd3testing "k8s.io/apiserver/pkg/storage/etcd3/testing"
4242
api "k8s.io/kubernetes/pkg/apis/core"
@@ -155,13 +155,13 @@ func TestDelete(t *testing.T) {
155155
}
156156

157157
type FailDeletionStorage struct {
158-
storage.Interface
158+
apiserverstorage.Interface
159159
Called *bool
160160
}
161161

162-
func (f FailDeletionStorage) Delete(ctx context.Context, key string, out runtime.Object, precondition *storage.Preconditions, _ storage.ValidateObjectFunc) error {
162+
func (f FailDeletionStorage) Delete(ctx context.Context, key string, out runtime.Object, precondition *apiserverstorage.Preconditions, _ apiserverstorage.ValidateObjectFunc) error {
163163
*f.Called = true
164-
return storage.NewKeyNotFoundError(key, 0)
164+
return apiserverstorage.NewKeyNotFoundError(key, 0)
165165
}
166166

167167
func newFailDeleteStorage(t *testing.T, called *bool) (*REST, *etcd3testing.EtcdTestServer) {

0 commit comments

Comments
 (0)