mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
Default ObjectNameFunc for all REST Stores
All Stores in Kubernetes follow the same logic for determining the name of an object. This change makes it so that CompleteWithOptions defaults the ObjectNameFunc if it is not specified. Thus a user does not need to remember to use ObjectMeta.Name. Using the wrong field as the name can lead to an object which has a name that bypasses normal object name validation. Signed-off-by: Monis Khan <mkhan@redhat.com>
This commit is contained in:
@@ -52,12 +52,9 @@ type FinalizeREST struct {
|
||||
// NewREST returns a RESTStorage object that will work against namespaces.
|
||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *FinalizeREST) {
|
||||
store := &genericregistry.Store{
|
||||
Copier: api.Scheme,
|
||||
NewFunc: func() runtime.Object { return &api.Namespace{} },
|
||||
NewListFunc: func() runtime.Object { return &api.NamespaceList{} },
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*api.Namespace).Name, nil
|
||||
},
|
||||
Copier: api.Scheme,
|
||||
NewFunc: func() runtime.Object { return &api.Namespace{} },
|
||||
NewListFunc: func() runtime.Object { return &api.NamespaceList{} },
|
||||
PredicateFunc: namespace.MatchNamespace,
|
||||
QualifiedResource: api.Resource("namespaces"),
|
||||
WatchCacheSize: cachesize.GetWatchCacheSizeByResource("namespaces"),
|
||||
|
||||
Reference in New Issue
Block a user