mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #27168 from smarterclayton/flatten_types
Automatic merge from submit-queue ObjectMeta, ListMeta, and TypeMeta should implement their interfaces Make unversioned.ListMeta implement List. Update all the *List types so they implement GetListMeta. This helps avoid using reflection to get list information. Remove all unnecessary boilerplate, move the interfaces to the right places, and add a test that verifies that objects implement one, the other, but never both. @ncdc @lavalamp this supercedes #26964 with the boilerplate removed. Added tests
This commit is contained in:
commit
9d8e79be09
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package api
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api/meta"
|
||||
"k8s.io/kubernetes/pkg/api/meta/metatypes"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/conversion"
|
||||
@ -64,6 +65,10 @@ func ListMetaFor(obj runtime.Object) (*unversioned.ListMeta, error) {
|
||||
return meta, err
|
||||
}
|
||||
|
||||
func (obj *ObjectMeta) GetObjectMeta() meta.Object { return obj }
|
||||
|
||||
func (obj *ObjectReference) GetObjectKind() unversioned.ObjectKind { return obj }
|
||||
|
||||
// Namespace implements meta.Object for any object with an ObjectMeta typed field. Allows
|
||||
// fast, direct access to metadata fields for API objects.
|
||||
func (meta *ObjectMeta) GetNamespace() string { return meta.Namespace }
|
||||
|
@ -73,20 +73,10 @@ type ListMetaAccessor interface {
|
||||
// List lets you work with list metadata from any of the versioned or
|
||||
// internal API objects. Attempting to set or retrieve a field on an object that does
|
||||
// not support that field will be a no-op and return a default value.
|
||||
type List interface {
|
||||
GetResourceVersion() string
|
||||
SetResourceVersion(version string)
|
||||
GetSelfLink() string
|
||||
SetSelfLink(selfLink string)
|
||||
}
|
||||
type List unversioned.List
|
||||
|
||||
// Type exposes the type and APIVersion of versioned or internal API objects.
|
||||
type Type interface {
|
||||
GetAPIVersion() string
|
||||
SetAPIVersion(version string)
|
||||
GetKind() string
|
||||
SetKind(kind string)
|
||||
}
|
||||
type Type unversioned.Type
|
||||
|
||||
// MetadataAccessor lets you work with object and list metadata from any of the versioned or
|
||||
// internal API objects. Attempting to set or retrieve a field on an object that does
|
||||
|
@ -35,6 +35,11 @@ func ListAccessor(obj interface{}) (List, error) {
|
||||
return om, nil
|
||||
}
|
||||
}
|
||||
if listMetaAccessor, ok := obj.(unversioned.ListMetaAccessor); ok {
|
||||
if om := listMetaAccessor.GetListMeta(); om != nil {
|
||||
return om, nil
|
||||
}
|
||||
}
|
||||
// we may get passed an object that is directly portable to List
|
||||
if list, ok := obj.(List); ok {
|
||||
return list, nil
|
||||
|
@ -25,6 +25,9 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/meta"
|
||||
"k8s.io/kubernetes/pkg/api/meta/metatypes"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
)
|
||||
|
||||
var _ meta.Object = &api.ObjectMeta{}
|
||||
@ -97,3 +100,75 @@ func TestAccessOwnerReferences(t *testing.T) {
|
||||
testSetOwnerReferences(t)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccessorImplementations(t *testing.T) {
|
||||
for _, group := range testapi.Groups {
|
||||
for _, gv := range []unversioned.GroupVersion{*group.GroupVersion(), group.InternalGroupVersion()} {
|
||||
for kind, knownType := range api.Scheme.KnownTypes(gv) {
|
||||
value := reflect.New(knownType)
|
||||
obj := value.Interface()
|
||||
if _, ok := obj.(runtime.Object); !ok {
|
||||
t.Errorf("%v (%v) does not implement runtime.Object", gv.WithKind(kind), knownType)
|
||||
}
|
||||
lm, isLM := obj.(meta.ListMetaAccessor)
|
||||
om, isOM := obj.(meta.ObjectMetaAccessor)
|
||||
switch {
|
||||
case isLM && isOM:
|
||||
t.Errorf("%v (%v) implements ListMetaAccessor and ObjectMetaAccessor", gv.WithKind(kind), knownType)
|
||||
continue
|
||||
case isLM:
|
||||
m := lm.GetListMeta()
|
||||
if m == nil {
|
||||
t.Errorf("%v (%v) returns nil ListMeta", gv.WithKind(kind), knownType)
|
||||
continue
|
||||
}
|
||||
m.SetResourceVersion("102030")
|
||||
if m.GetResourceVersion() != "102030" {
|
||||
t.Errorf("%v (%v) did not preserve resource version", gv.WithKind(kind), knownType)
|
||||
continue
|
||||
}
|
||||
m.SetSelfLink("102030")
|
||||
if m.GetSelfLink() != "102030" {
|
||||
t.Errorf("%v (%v) did not preserve self link", gv.WithKind(kind), knownType)
|
||||
continue
|
||||
}
|
||||
case isOM:
|
||||
m := om.GetObjectMeta()
|
||||
if m == nil {
|
||||
t.Errorf("%v (%v) returns nil ObjectMeta", gv.WithKind(kind), knownType)
|
||||
continue
|
||||
}
|
||||
m.SetResourceVersion("102030")
|
||||
if m.GetResourceVersion() != "102030" {
|
||||
t.Errorf("%v (%v) did not preserve resource version", gv.WithKind(kind), knownType)
|
||||
continue
|
||||
}
|
||||
m.SetSelfLink("102030")
|
||||
if m.GetSelfLink() != "102030" {
|
||||
t.Errorf("%v (%v) did not preserve self link", gv.WithKind(kind), knownType)
|
||||
continue
|
||||
}
|
||||
labels := map[string]string{"a": "b"}
|
||||
m.SetLabels(labels)
|
||||
if !reflect.DeepEqual(m.GetLabels(), labels) {
|
||||
t.Errorf("%v (%v) did not preserve labels", gv.WithKind(kind), knownType)
|
||||
continue
|
||||
}
|
||||
default:
|
||||
if _, ok := obj.(unversioned.ListMetaAccessor); ok {
|
||||
continue
|
||||
}
|
||||
if _, ok := value.Elem().Type().FieldByName("ObjectMeta"); ok {
|
||||
t.Errorf("%v (%v) has ObjectMeta but does not implement ObjectMetaAccessor", gv.WithKind(kind), knownType)
|
||||
continue
|
||||
}
|
||||
if _, ok := value.Elem().Type().FieldByName("ListMeta"); ok {
|
||||
t.Errorf("%v (%v) has ListMeta but does not implement ListMetaAccessor", gv.WithKind(kind), knownType)
|
||||
continue
|
||||
}
|
||||
t.Logf("%v (%v) does not implement ListMetaAccessor or ObjectMetaAccessor", gv.WithKind(kind), knownType)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
||||
package api
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api/meta"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/runtime/serializer"
|
||||
@ -114,70 +113,3 @@ func AddToScheme(scheme *runtime.Scheme) {
|
||||
&unversioned.APIResourceList{},
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *Pod) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *Pod) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodStatusResult) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *PodStatusResult) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodTemplate) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *PodTemplate) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodTemplateList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicationController) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *ReplicationController) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicationControllerList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Service) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *Service) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ServiceList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Endpoints) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *Endpoints) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *EndpointsList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Node) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *Node) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *NodeList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *NodeProxyOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Binding) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *Binding) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Event) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *Event) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *EventList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *List) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ListOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *LimitRange) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *LimitRange) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *LimitRangeList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ResourceQuota) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *ResourceQuota) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ResourceQuotaList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Namespace) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *Namespace) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *NamespaceList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ServiceAccount) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *ServiceAccount) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ServiceAccountList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Secret) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *Secret) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *SecretList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PersistentVolume) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *PersistentVolume) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PersistentVolumeList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PersistentVolumeClaim) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *PersistentVolumeClaim) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PersistentVolumeClaimList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DeleteOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodAttachOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodLogOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodExecOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodProxyOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ServiceProxyOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ComponentStatus) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *ComponentStatus) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ComponentStatusList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *SerializedReference) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *RangeAllocation) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *RangeAllocation) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ObjectReference) GetObjectKind() unversioned.ObjectKind { return obj }
|
||||
func (obj *ExportOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMap) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *ConfigMap) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMapList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
62
pkg/api/unversioned/meta.go
Normal file
62
pkg/api/unversioned/meta.go
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package unversioned
|
||||
|
||||
// ListMetaAccessor retrieves the list interface from an object
|
||||
// TODO: move this, and TypeMeta and ListMeta, to a different package
|
||||
type ListMetaAccessor interface {
|
||||
GetListMeta() List
|
||||
}
|
||||
|
||||
// List lets you work with list metadata from any of the versioned or
|
||||
// internal API objects. Attempting to set or retrieve a field on an object that does
|
||||
// not support that field will be a no-op and return a default value.
|
||||
// TODO: move this, and TypeMeta and ListMeta, to a different package
|
||||
type List interface {
|
||||
GetResourceVersion() string
|
||||
SetResourceVersion(version string)
|
||||
GetSelfLink() string
|
||||
SetSelfLink(selfLink string)
|
||||
}
|
||||
|
||||
// Type exposes the type and APIVersion of versioned or internal API objects.
|
||||
// TODO: move this, and TypeMeta and ListMeta, to a different package
|
||||
type Type interface {
|
||||
GetAPIVersion() string
|
||||
SetAPIVersion(version string)
|
||||
GetKind() string
|
||||
SetKind(kind string)
|
||||
}
|
||||
|
||||
func (meta *ListMeta) GetResourceVersion() string { return meta.ResourceVersion }
|
||||
func (meta *ListMeta) SetResourceVersion(version string) { meta.ResourceVersion = version }
|
||||
func (meta *ListMeta) GetSelfLink() string { return meta.SelfLink }
|
||||
func (meta *ListMeta) SetSelfLink(selfLink string) { meta.SelfLink = selfLink }
|
||||
|
||||
func (obj *TypeMeta) GetObjectKind() ObjectKind { return obj }
|
||||
|
||||
// SetGroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta
|
||||
func (obj *TypeMeta) SetGroupVersionKind(gvk GroupVersionKind) {
|
||||
obj.APIVersion, obj.Kind = gvk.ToAPIVersionAndKind()
|
||||
}
|
||||
|
||||
// GroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta
|
||||
func (obj *TypeMeta) GroupVersionKind() GroupVersionKind {
|
||||
return FromAPIVersionAndKind(obj.APIVersion, obj.Kind)
|
||||
}
|
||||
|
||||
func (obj *ListMeta) GetListMeta() List { return obj }
|
@ -23,20 +23,3 @@ var SchemeGroupVersion = GroupVersion{Group: "", Version: ""}
|
||||
func Kind(kind string) GroupKind {
|
||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||
}
|
||||
|
||||
// SetGroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta
|
||||
func (obj *TypeMeta) SetGroupVersionKind(gvk GroupVersionKind) {
|
||||
obj.APIVersion, obj.Kind = gvk.ToAPIVersionAndKind()
|
||||
}
|
||||
|
||||
// GroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta
|
||||
func (obj *TypeMeta) GroupVersionKind() GroupVersionKind {
|
||||
return FromAPIVersionAndKind(obj.APIVersion, obj.Kind)
|
||||
}
|
||||
|
||||
func (obj *Status) GetObjectKind() ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *APIVersions) GetObjectKind() ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *APIGroupList) GetObjectKind() ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *APIGroup) GetObjectKind() ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *APIResourceList) GetObjectKind() ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ExportOptions) GetObjectKind() ObjectKind { return &obj.TypeMeta }
|
||||
|
85
pkg/api/v1/meta.go
Normal file
85
pkg/api/v1/meta.go
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright 2014 The Kubernetes Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api/meta"
|
||||
"k8s.io/kubernetes/pkg/api/meta/metatypes"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
)
|
||||
|
||||
func (obj *ObjectMeta) GetObjectMeta() meta.Object { return obj }
|
||||
|
||||
// Namespace implements meta.Object for any object with an ObjectMeta typed field. Allows
|
||||
// fast, direct access to metadata fields for API objects.
|
||||
func (meta *ObjectMeta) GetNamespace() string { return meta.Namespace }
|
||||
func (meta *ObjectMeta) SetNamespace(namespace string) { meta.Namespace = namespace }
|
||||
func (meta *ObjectMeta) GetName() string { return meta.Name }
|
||||
func (meta *ObjectMeta) SetName(name string) { meta.Name = name }
|
||||
func (meta *ObjectMeta) GetGenerateName() string { return meta.GenerateName }
|
||||
func (meta *ObjectMeta) SetGenerateName(generateName string) { meta.GenerateName = generateName }
|
||||
func (meta *ObjectMeta) GetUID() types.UID { return meta.UID }
|
||||
func (meta *ObjectMeta) SetUID(uid types.UID) { meta.UID = uid }
|
||||
func (meta *ObjectMeta) GetResourceVersion() string { return meta.ResourceVersion }
|
||||
func (meta *ObjectMeta) SetResourceVersion(version string) { meta.ResourceVersion = version }
|
||||
func (meta *ObjectMeta) GetSelfLink() string { return meta.SelfLink }
|
||||
func (meta *ObjectMeta) SetSelfLink(selfLink string) { meta.SelfLink = selfLink }
|
||||
func (meta *ObjectMeta) GetCreationTimestamp() unversioned.Time { return meta.CreationTimestamp }
|
||||
func (meta *ObjectMeta) SetCreationTimestamp(creationTimestamp unversioned.Time) {
|
||||
meta.CreationTimestamp = creationTimestamp
|
||||
}
|
||||
func (meta *ObjectMeta) GetDeletionTimestamp() *unversioned.Time { return meta.DeletionTimestamp }
|
||||
func (meta *ObjectMeta) SetDeletionTimestamp(deletionTimestamp *unversioned.Time) {
|
||||
meta.DeletionTimestamp = deletionTimestamp
|
||||
}
|
||||
func (meta *ObjectMeta) GetLabels() map[string]string { return meta.Labels }
|
||||
func (meta *ObjectMeta) SetLabels(labels map[string]string) { meta.Labels = labels }
|
||||
func (meta *ObjectMeta) GetAnnotations() map[string]string { return meta.Annotations }
|
||||
func (meta *ObjectMeta) SetAnnotations(annotations map[string]string) { meta.Annotations = annotations }
|
||||
func (meta *ObjectMeta) GetFinalizers() []string { return meta.Finalizers }
|
||||
func (meta *ObjectMeta) SetFinalizers(finalizers []string) { meta.Finalizers = finalizers }
|
||||
|
||||
func (meta *ObjectMeta) GetOwnerReferences() []metatypes.OwnerReference {
|
||||
ret := make([]metatypes.OwnerReference, len(meta.OwnerReferences))
|
||||
for i := 0; i < len(meta.OwnerReferences); i++ {
|
||||
ret[i].Kind = meta.OwnerReferences[i].Kind
|
||||
ret[i].Name = meta.OwnerReferences[i].Name
|
||||
ret[i].UID = meta.OwnerReferences[i].UID
|
||||
ret[i].APIVersion = meta.OwnerReferences[i].APIVersion
|
||||
if meta.OwnerReferences[i].Controller != nil {
|
||||
value := *meta.OwnerReferences[i].Controller
|
||||
ret[i].Controller = &value
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (meta *ObjectMeta) SetOwnerReferences(references []metatypes.OwnerReference) {
|
||||
newReferences := make([]OwnerReference, len(references))
|
||||
for i := 0; i < len(references); i++ {
|
||||
newReferences[i].Kind = references[i].Kind
|
||||
newReferences[i].Name = references[i].Name
|
||||
newReferences[i].UID = references[i].UID
|
||||
newReferences[i].APIVersion = references[i].APIVersion
|
||||
if references[i].Controller != nil {
|
||||
value := *references[i].Controller
|
||||
newReferences[i].Controller = &value
|
||||
}
|
||||
}
|
||||
meta.OwnerReferences = newReferences
|
||||
}
|
@ -92,50 +92,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
// Add the watch version that applies
|
||||
versionedwatch.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
}
|
||||
|
||||
func (obj *Pod) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodStatusResult) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodTemplate) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodTemplateList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicationController) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicationControllerList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Service) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ServiceList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Endpoints) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *EndpointsList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Node) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *NodeList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *NodeProxyOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Binding) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Event) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *EventList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *List) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *LimitRange) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *LimitRangeList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ResourceQuota) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ResourceQuotaList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Namespace) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *NamespaceList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Secret) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *SecretList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ServiceAccount) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ServiceAccountList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PersistentVolume) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PersistentVolumeList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PersistentVolumeClaim) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PersistentVolumeClaimList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DeleteOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ListOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodAttachOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodLogOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodExecOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodProxyOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ServiceProxyOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ComponentStatus) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ComponentStatusList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *SerializedReference) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *RangeAllocation) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ExportOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMap) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMapList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -52,6 +52,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&api.ListOptions{},
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *PetSet) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PetSetList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -48,7 +48,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&LocalSubjectAccessReview{},
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *LocalSubjectAccessReview) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *SubjectAccessReview) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *SelfSubjectAccessReview) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -52,7 +52,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&api.ListOptions{},
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *Scale) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *HorizontalPodAutoscaler) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *HorizontalPodAutoscalerList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -44,7 +44,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
)
|
||||
versionedwatch.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
}
|
||||
|
||||
func (obj *HorizontalPodAutoscaler) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *HorizontalPodAutoscalerList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Scale) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -54,9 +54,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&api.ListOptions{},
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *Job) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *JobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *JobTemplate) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ScheduledJob) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ScheduledJobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -44,6 +44,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
)
|
||||
versionedwatch.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
}
|
||||
|
||||
func (obj *Job) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *JobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -47,9 +47,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
)
|
||||
versionedwatch.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
}
|
||||
|
||||
func (obj *Job) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *JobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *JobTemplate) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ScheduledJob) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ScheduledJobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -48,6 +48,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&KubeSchedulerConfiguration{},
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *KubeProxyConfiguration) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *KubeSchedulerConfiguration) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -38,6 +38,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&KubeSchedulerConfiguration{},
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *KubeProxyConfiguration) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *KubeSchedulerConfiguration) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -77,23 +77,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&NetworkPolicyList{},
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *Deployment) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DeploymentList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DeploymentRollback) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicationControllerDummy) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Scale) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ThirdPartyResource) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ThirdPartyResourceList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DaemonSet) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DaemonSetList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ThirdPartyResourceData) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ThirdPartyResourceDataList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Ingress) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *IngressList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicaSet) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicaSetList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodSecurityPolicy) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodSecurityPolicyList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *NetworkPolicy) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *NetworkPolicyList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -67,28 +67,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
// Add the watch version that applies
|
||||
versionedwatch.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
}
|
||||
|
||||
func (obj *Deployment) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DeploymentList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DeploymentRollback) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *HorizontalPodAutoscaler) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *HorizontalPodAutoscalerList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Job) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *JobList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicationControllerDummy) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Scale) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ThirdPartyResource) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ThirdPartyResourceList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DaemonSet) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *DaemonSetList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ThirdPartyResourceData) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ThirdPartyResourceDataList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Ingress) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *IngressList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ListOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicaSet) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicaSetList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodSecurityPolicy) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodSecurityPolicyList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *NetworkPolicy) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *NetworkPolicyList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -50,6 +50,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&PodDisruptionBudgetList{},
|
||||
)
|
||||
}
|
||||
|
||||
func (obj *PodDisruptionBudget) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodDisruptionBudgetList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -45,6 +45,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
// Add the watch version that applies
|
||||
versionedwatch.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
}
|
||||
|
||||
func (obj *PodDisruptionBudget) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *PodDisruptionBudgetList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -62,13 +62,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
)
|
||||
versioned.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
}
|
||||
|
||||
func (obj *ClusterRole) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ClusterRoleBinding) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ClusterRoleBindingList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ClusterRoleList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
||||
func (obj *Role) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *RoleBinding) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *RoleBindingList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *RoleList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -50,13 +50,3 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
)
|
||||
versioned.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
}
|
||||
|
||||
func (obj *ClusterRole) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ClusterRoleBinding) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ClusterRoleBindingList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ClusterRoleList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
||||
func (obj *Role) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *RoleBinding) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *RoleBindingList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *RoleList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -120,7 +120,7 @@ func newMapper() *meta.DefaultRESTMapper {
|
||||
|
||||
func addGrouplessTypes() {
|
||||
type ListOptions struct {
|
||||
runtime.Object
|
||||
Object runtime.Object
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
LabelSelector string `json:"labelSelector,omitempty"`
|
||||
FieldSelector string `json:"fieldSelector,omitempty"`
|
||||
@ -139,7 +139,7 @@ func addGrouplessTypes() {
|
||||
|
||||
func addTestTypes() {
|
||||
type ListOptions struct {
|
||||
runtime.Object
|
||||
Object runtime.Object
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
LabelSelector string `json:"labelSelector,omitempty"`
|
||||
FieldSelector string `json:"fieldSelector,omitempty"`
|
||||
@ -167,7 +167,7 @@ func addTestTypes() {
|
||||
|
||||
func addNewTestTypes() {
|
||||
type ListOptions struct {
|
||||
runtime.Object
|
||||
Object runtime.Object
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
LabelSelector string `json:"labelSelector,omitempty"`
|
||||
FieldSelector string `json:"fieldSelector,omitempty"`
|
||||
|
Loading…
Reference in New Issue
Block a user