mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 18:28:13 +00:00 
			
		
		
		
	Move APIs and core code to use metav1.ObjectMeta
This commit is contained in:
		| @@ -75,7 +75,7 @@ type APIServiceStatus struct { | ||||
| // Name must be "version.group". | ||||
| type APIService struct { | ||||
| 	metav1.TypeMeta | ||||
| 	kapi.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec contains information for locating and communicating with a server | ||||
| 	Spec APIServiceSpec | ||||
|   | ||||
| @@ -75,7 +75,7 @@ type APIServiceStatus struct { | ||||
| // Name must be "version.group". | ||||
| type APIService struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	kapi.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec contains information for locating and communicating with a server | ||||
| 	Spec APIServiceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` | ||||
|   | ||||
| @@ -277,9 +277,9 @@ func TestAPIs(t *testing.T) { | ||||
| 		for _, o := range tc.apiservices { | ||||
| 			indexer.Add(o) | ||||
| 		} | ||||
| 		serviceIndexer.Add(&corev1.Service{ObjectMeta: corev1.ObjectMeta{Namespace: "ns", Name: "api"}}) | ||||
| 		serviceIndexer.Add(&corev1.Service{ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "api"}}) | ||||
| 		endpointsIndexer.Add(&corev1.Endpoints{ | ||||
| 			ObjectMeta: corev1.ObjectMeta{Namespace: "ns", Name: "api"}, | ||||
| 			ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "api"}, | ||||
| 			Subsets: []corev1.EndpointSubset{ | ||||
| 				{Addresses: []corev1.EndpointAddress{{}}}, | ||||
| 			}, | ||||
| @@ -434,9 +434,9 @@ func TestAPIGroup(t *testing.T) { | ||||
| 		for _, o := range tc.apiservices { | ||||
| 			indexer.Add(o) | ||||
| 		} | ||||
| 		serviceIndexer.Add(&corev1.Service{ObjectMeta: corev1.ObjectMeta{Namespace: "ns", Name: "api"}}) | ||||
| 		serviceIndexer.Add(&corev1.Service{ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "api"}}) | ||||
| 		endpointsIndexer.Add(&corev1.Endpoints{ | ||||
| 			ObjectMeta: corev1.ObjectMeta{Namespace: "ns", Name: "api"}, | ||||
| 			ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "api"}, | ||||
| 			Subsets: []corev1.EndpointSubset{ | ||||
| 				{Addresses: []corev1.EndpointAddress{{}}}, | ||||
| 			}, | ||||
|   | ||||
| @@ -25,7 +25,7 @@ import ( | ||||
|  | ||||
| type TestType struct { | ||||
| 	metav1.TypeMeta | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
| 	Status TestTypeStatus | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -30,7 +30,7 @@ type TestType struct { | ||||
| 	// unversioned objects in the generate file that is not used anywhere other than this test type. | ||||
| 	// +k8s:openapi-gen=false | ||||
| 	// +optional | ||||
| 	apiv1.ObjectMeta `json:"metadata,omitempty"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty"` | ||||
| 	// +optional | ||||
| 	Status TestTypeStatus `json:"status,omitempty"` | ||||
| } | ||||
|   | ||||
| @@ -99,7 +99,7 @@ type Cluster struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the behavior of the Cluster. | ||||
| 	// +optional | ||||
|   | ||||
| @@ -99,7 +99,7 @@ type Cluster struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the behavior of the Cluster. | ||||
| 	// +optional | ||||
|   | ||||
| @@ -24,6 +24,8 @@ import ( | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/davecgh/go-spew/spew" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/conversion" | ||||
| 	"k8s.io/apimachinery/pkg/labels" | ||||
| @@ -33,8 +35,6 @@ import ( | ||||
| 	"k8s.io/apimachinery/pkg/util/sets" | ||||
| 	"k8s.io/kubernetes/pkg/api/resource" | ||||
| 	"k8s.io/kubernetes/pkg/fields" | ||||
|  | ||||
| 	"github.com/davecgh/go-spew/spew" | ||||
| ) | ||||
|  | ||||
| // Conversion error conveniently packages up errors in conversions. | ||||
| @@ -272,7 +272,7 @@ func IsStandardFinalizerName(str string) bool { | ||||
| } | ||||
|  | ||||
| // SingleObject returns a ListOptions for watching a single object. | ||||
| func SingleObject(meta ObjectMeta) ListOptions { | ||||
| func SingleObject(meta metav1.ObjectMeta) ListOptions { | ||||
| 	return ListOptions{ | ||||
| 		FieldSelector:   fields.OneTermEqualSelector("metadata.name", meta.Name), | ||||
| 		ResourceVersion: meta.ResourceVersion, | ||||
|   | ||||
| @@ -356,7 +356,7 @@ func TestGetAvoidPodsFromNode(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			node: &Node{ | ||||
| 				ObjectMeta: ObjectMeta{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Annotations: map[string]string{ | ||||
| 						PreferAvoidPodsAnnotationKey: ` | ||||
| 							{ | ||||
| @@ -401,7 +401,7 @@ func TestGetAvoidPodsFromNode(t *testing.T) { | ||||
| 		{ | ||||
| 			node: &Node{ | ||||
| 				// Missing end symbol of "podController" and "podSignature" | ||||
| 				ObjectMeta: ObjectMeta{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Annotations: map[string]string{ | ||||
| 						PreferAvoidPodsAnnotationKey: ` | ||||
| 							{ | ||||
|   | ||||
| @@ -28,7 +28,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| func TestResourceVersioner(t *testing.T) { | ||||
| 	pod := internal.Pod{ObjectMeta: internal.ObjectMeta{ResourceVersion: "10"}} | ||||
| 	pod := internal.Pod{ObjectMeta: metav1.ObjectMeta{ResourceVersion: "10"}} | ||||
| 	version, err := accessor.ResourceVersion(&pod) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("unexpected error: %v", err) | ||||
| @@ -106,7 +106,7 @@ func TestRESTMapper(t *testing.T) { | ||||
| 			t.Errorf("unexpected: %#v, expected: %#v", mapping, interfaces) | ||||
| 		} | ||||
|  | ||||
| 		rc := &internal.ReplicationController{ObjectMeta: internal.ObjectMeta{Name: "foo"}} | ||||
| 		rc := &internal.ReplicationController{ObjectMeta: metav1.ObjectMeta{Name: "foo"}} | ||||
| 		name, err := mapping.MetadataAccessor.Name(rc) | ||||
| 		if err != nil { | ||||
| 			t.Errorf("unexpected error: %v", err) | ||||
|   | ||||
							
								
								
									
										100
									
								
								pkg/api/meta.go
									
									
									
									
									
								
							
							
						
						
									
										100
									
								
								pkg/api/meta.go
									
									
									
									
									
								
							| @@ -17,109 +17,11 @@ limitations under the License. | ||||
| package api | ||||
|  | ||||
| import ( | ||||
| 	"k8s.io/apimachinery/pkg/api/meta" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/conversion" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/apimachinery/pkg/types" | ||||
| ) | ||||
|  | ||||
| // HasObjectMetaSystemFieldValues returns true if fields that are managed by the system on ObjectMeta have values. | ||||
| func HasObjectMetaSystemFieldValues(meta *ObjectMeta) bool { | ||||
| func HasObjectMetaSystemFieldValues(meta *metav1.ObjectMeta) bool { | ||||
| 	return !meta.CreationTimestamp.Time.IsZero() || | ||||
| 		len(meta.UID) != 0 | ||||
| } | ||||
|  | ||||
| // ObjectMetaFor returns a pointer to a provided object's ObjectMeta. | ||||
| // TODO: allow runtime.Unknown to extract this object | ||||
| // TODO: Remove this function and use meta.Accessor() instead. | ||||
| func ObjectMetaFor(obj runtime.Object) (*ObjectMeta, error) { | ||||
| 	v, err := conversion.EnforcePtr(obj) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	var meta *ObjectMeta | ||||
| 	err = runtime.FieldPtr(v, "ObjectMeta", &meta) | ||||
| 	return meta, err | ||||
| } | ||||
|  | ||||
| // ListMetaFor returns a pointer to a provided object's ListMeta, | ||||
| // or an error if the object does not have that pointer. | ||||
| // TODO: allow runtime.Unknown to extract this object | ||||
| func ListMetaFor(obj runtime.Object) (*metav1.ListMeta, error) { | ||||
| 	v, err := conversion.EnforcePtr(obj) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	var meta *metav1.ListMeta | ||||
| 	err = runtime.FieldPtr(v, "ListMeta", &meta) | ||||
| 	return meta, err | ||||
| } | ||||
|  | ||||
| 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() metav1.Time   { return meta.CreationTimestamp } | ||||
| func (meta *ObjectMeta) SetCreationTimestamp(creationTimestamp metav1.Time) { | ||||
| 	meta.CreationTimestamp = creationTimestamp | ||||
| } | ||||
| func (meta *ObjectMeta) GetDeletionTimestamp() *metav1.Time { return meta.DeletionTimestamp } | ||||
| func (meta *ObjectMeta) SetDeletionTimestamp(deletionTimestamp *metav1.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() []metav1.OwnerReference { | ||||
| 	ret := make([]metav1.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 []metav1.OwnerReference) { | ||||
| 	newReferences := make([]metav1.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 | ||||
| } | ||||
|  | ||||
| func (meta *ObjectMeta) GetClusterName() string { | ||||
| 	return meta.ClusterName | ||||
| } | ||||
| func (meta *ObjectMeta) SetClusterName(clusterName string) { | ||||
| 	meta.ClusterName = clusterName | ||||
| } | ||||
|   | ||||
| @@ -29,7 +29,7 @@ import ( | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| ) | ||||
|  | ||||
| var _ meta.Object = &api.ObjectMeta{} | ||||
| var _ metav1.Object = &metav1.ObjectMeta{} | ||||
|  | ||||
| func getObjectMetaAndOwnerReferences() (objectMeta api.ObjectMeta, metaOwnerReferences []metav1.OwnerReference) { | ||||
| 	fuzz.New().NilChance(.5).NumElements(1, 5).Fuzz(&objectMeta) | ||||
| @@ -86,7 +86,7 @@ func TestAccessorImplementations(t *testing.T) { | ||||
| 					t.Errorf("%v (%v) does not implement runtime.Object", gv.WithKind(kind), knownType) | ||||
| 				} | ||||
| 				lm, isLM := obj.(meta.ListMetaAccessor) | ||||
| 				om, isOM := obj.(meta.ObjectMetaAccessor) | ||||
| 				om, isOM := obj.(metav1.ObjectMetaAccessor) | ||||
| 				switch { | ||||
| 				case isLM && isOM: | ||||
| 					t.Errorf("%v (%v) implements ListMetaAccessor and ObjectMetaAccessor", gv.WithKind(kind), knownType) | ||||
|   | ||||
| @@ -31,7 +31,7 @@ func (obj *FakeAPIObject) GetObjectKind() schema.ObjectKind { return schema.Empt | ||||
|  | ||||
| type ExtensionAPIObject struct { | ||||
| 	metav1.TypeMeta | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
| } | ||||
|  | ||||
| func (obj *ExtensionAPIObject) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } | ||||
| @@ -53,7 +53,7 @@ func TestGetReference(t *testing.T) { | ||||
| 	}{ | ||||
| 		"pod": { | ||||
| 			obj: &Pod{ | ||||
| 				ObjectMeta: ObjectMeta{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Name:            "foo", | ||||
| 					UID:             "bar", | ||||
| 					ResourceVersion: "42", | ||||
| @@ -88,7 +88,7 @@ func TestGetReference(t *testing.T) { | ||||
| 				TypeMeta: metav1.TypeMeta{ | ||||
| 					Kind: "ExtensionAPIObject", | ||||
| 				}, | ||||
| 				ObjectMeta: ObjectMeta{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Name:            "foo", | ||||
| 					UID:             "bar", | ||||
| 					ResourceVersion: "42", | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/serializer/protobuf" | ||||
|   | ||||
| @@ -23,6 +23,8 @@ import ( | ||||
| 	"strconv" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/google/gofuzz" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/labels" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| @@ -40,8 +42,6 @@ import ( | ||||
| 	"k8s.io/kubernetes/pkg/apis/rbac" | ||||
| 	"k8s.io/kubernetes/pkg/fields" | ||||
| 	"k8s.io/kubernetes/pkg/util/intstr" | ||||
|  | ||||
| 	"github.com/google/gofuzz" | ||||
| ) | ||||
|  | ||||
| // FuzzerFor can randomly populate api objects that are destined for version. | ||||
|   | ||||
| @@ -57,7 +57,7 @@ import ( | ||||
|  | ||||
| // ObjectMeta is metadata that all persisted resources must have, which includes all objects | ||||
| // users must create. | ||||
| // DEPRECATED: Use k8s.io/kubernetes/pkg/apis/meta/v1.ObjectMeta instead - this type will be removed soon. | ||||
| // DEPRECATED: Use k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta instead - this type will be removed soon. | ||||
| type ObjectMeta struct { | ||||
| 	// Name is unique within a namespace.  Name is required when creating resources, although | ||||
| 	// some resources may allow a client to request the generation of an appropriate name | ||||
| @@ -371,7 +371,7 @@ type PersistentVolumeClaimVolumeSource struct { | ||||
| type PersistentVolume struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	//Spec defines a persistent volume owned by the cluster | ||||
| 	// +optional | ||||
| @@ -442,7 +442,7 @@ type PersistentVolumeList struct { | ||||
| type PersistentVolumeClaim struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the volume requested by a pod author | ||||
| 	// +optional | ||||
| @@ -1982,7 +1982,7 @@ type PodStatus struct { | ||||
| type PodStatusResult struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
| 	// Status represents the current information about a pod. This data may not be up | ||||
| 	// to date. | ||||
| 	// +optional | ||||
| @@ -1995,7 +1995,7 @@ type PodStatusResult struct { | ||||
| type Pod struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the behavior of a pod. | ||||
| 	// +optional | ||||
| @@ -2011,7 +2011,7 @@ type Pod struct { | ||||
| type PodTemplateSpec struct { | ||||
| 	// Metadata of the pods created from this template. | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the behavior of a pod. | ||||
| 	// +optional | ||||
| @@ -2024,7 +2024,7 @@ type PodTemplateSpec struct { | ||||
| type PodTemplate struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Template defines the pods that will be created from this pod template | ||||
| 	// +optional | ||||
| @@ -2129,7 +2129,7 @@ type ReplicationControllerCondition struct { | ||||
| type ReplicationController struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the desired behavior of this replication controller. | ||||
| 	// +optional | ||||
| @@ -2334,7 +2334,7 @@ type ServicePort struct { | ||||
| type Service struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the behavior of a service. | ||||
| 	// +optional | ||||
| @@ -2354,7 +2354,7 @@ type Service struct { | ||||
| type ServiceAccount struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Secrets is the list of secrets allowed to be used by pods running using this ServiceAccount | ||||
| 	Secrets []ObjectReference | ||||
| @@ -2392,7 +2392,7 @@ type ServiceAccountList struct { | ||||
| type Endpoints struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// The set of all endpoints is the union of all subsets. | ||||
| 	Subsets []EndpointSubset | ||||
| @@ -2714,7 +2714,7 @@ type ResourceList map[ResourceName]resource.Quantity | ||||
| type Node struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the behavior of a node. | ||||
| 	// +optional | ||||
| @@ -2774,7 +2774,7 @@ const ( | ||||
| type Namespace struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the behavior of the Namespace. | ||||
| 	// +optional | ||||
| @@ -2799,7 +2799,7 @@ type Binding struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// ObjectMeta describes the object that is being bound. | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Target is the object to bind to. | ||||
| 	Target ObjectReference | ||||
| @@ -3027,7 +3027,7 @@ const ( | ||||
| type Event struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Required. The object that this event is about. | ||||
| 	// +optional | ||||
| @@ -3130,7 +3130,7 @@ type LimitRangeSpec struct { | ||||
| type LimitRange struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the limits enforced | ||||
| 	// +optional | ||||
| @@ -3220,7 +3220,7 @@ type ResourceQuotaStatus struct { | ||||
| type ResourceQuota struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the desired quota | ||||
| 	// +optional | ||||
| @@ -3248,7 +3248,7 @@ type ResourceQuotaList struct { | ||||
| type Secret struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Data contains the secret data.  Each key must be a valid DNS_SUBDOMAIN | ||||
| 	// or leading dot followed by valid DNS_SUBDOMAIN. | ||||
| @@ -3363,7 +3363,7 @@ type SecretList struct { | ||||
| type ConfigMap struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Data contains the configuration data. | ||||
| 	// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot. | ||||
| @@ -3446,7 +3446,7 @@ type ComponentCondition struct { | ||||
| type ComponentStatus struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// +optional | ||||
| 	Conditions []ComponentCondition | ||||
| @@ -3525,7 +3525,7 @@ type SELinuxOptions struct { | ||||
| type RangeAllocation struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
| 	// A string representing a unique label for a range of resources, such as a CIDR "10.0.0.0/8" or | ||||
| 	// port range "10000-30000". Range is not strongly schema'd here. The Range is expected to define | ||||
| 	// a start and end unless there is an implicit end. | ||||
|   | ||||
| @@ -269,9 +269,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error { | ||||
| } | ||||
|  | ||||
| func Convert_v1_ReplicationController_to_extensions_ReplicaSet(in *ReplicationController, out *extensions.ReplicaSet, s conversion.Scope) error { | ||||
| 	if err := Convert_v1_ObjectMeta_To_api_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	out.ObjectMeta = in.ObjectMeta | ||||
| 	if err := Convert_v1_ReplicationControllerSpec_to_extensions_ReplicaSetSpec(&in.Spec, &out.Spec, s); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -304,9 +302,7 @@ func Convert_v1_ReplicationControllerStatus_to_extensions_ReplicaSetStatus(in *R | ||||
| } | ||||
|  | ||||
| func Convert_extensions_ReplicaSet_to_v1_ReplicationController(in *extensions.ReplicaSet, out *ReplicationController, s conversion.Scope) error { | ||||
| 	if err := Convert_api_ObjectMeta_To_v1_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	out.ObjectMeta = in.ObjectMeta | ||||
| 	if err := Convert_extensions_ReplicaSetSpec_to_v1_ReplicationControllerSpec(&in.Spec, &out.Spec, s); err != nil { | ||||
| 		fieldErr, ok := err.(*field.Error) | ||||
| 		if !ok { | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import ( | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/api/resource" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/util/intstr" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/labels" | ||||
| 	"k8s.io/apimachinery/pkg/selection" | ||||
| 	"k8s.io/apimachinery/pkg/types" | ||||
| @@ -86,26 +87,12 @@ var standardFinalizers = sets.NewString( | ||||
| 	FinalizerOrphan, | ||||
| ) | ||||
|  | ||||
| // HasAnnotation returns a bool if passed in annotation exists | ||||
| func HasAnnotation(obj ObjectMeta, ann string) bool { | ||||
| 	_, found := obj.Annotations[ann] | ||||
| 	return found | ||||
| } | ||||
|  | ||||
| // SetMetaDataAnnotation sets the annotation and value | ||||
| func SetMetaDataAnnotation(obj *ObjectMeta, ann string, value string) { | ||||
| 	if obj.Annotations == nil { | ||||
| 		obj.Annotations = make(map[string]string) | ||||
| 	} | ||||
| 	obj.Annotations[ann] = value | ||||
| } | ||||
|  | ||||
| func IsStandardFinalizerName(str string) bool { | ||||
| 	return standardFinalizers.Has(str) | ||||
| } | ||||
|  | ||||
| // SingleObject returns a ListOptions for watching a single object. | ||||
| func SingleObject(meta ObjectMeta) ListOptions { | ||||
| func SingleObject(meta metav1.ObjectMeta) ListOptions { | ||||
| 	return ListOptions{ | ||||
| 		FieldSelector:   fields.OneTermEqualSelector("metadata.name", meta.Name).String(), | ||||
| 		ResourceVersion: meta.ResourceVersion, | ||||
|   | ||||
| @@ -190,7 +190,7 @@ func TestGetAffinityFromPod(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			pod: &Pod{ | ||||
| 				ObjectMeta: ObjectMeta{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Annotations: map[string]string{ | ||||
| 						AffinityAnnotationKey: ` | ||||
| 						{"nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": { | ||||
| @@ -209,7 +209,7 @@ func TestGetAffinityFromPod(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			pod: &Pod{ | ||||
| 				ObjectMeta: ObjectMeta{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Annotations: map[string]string{ | ||||
| 						AffinityAnnotationKey: ` | ||||
| 						{"nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": { | ||||
| @@ -350,7 +350,7 @@ func TestGetAvoidPodsFromNode(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			node: &Node{ | ||||
| 				ObjectMeta: ObjectMeta{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Annotations: map[string]string{ | ||||
| 						PreferAvoidPodsAnnotationKey: ` | ||||
| 							{ | ||||
| @@ -395,7 +395,7 @@ func TestGetAvoidPodsFromNode(t *testing.T) { | ||||
| 		{ | ||||
| 			node: &Node{ | ||||
| 				// Missing end symbol of "podController" and "podSignature" | ||||
| 				ObjectMeta: ObjectMeta{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Annotations: map[string]string{ | ||||
| 						PreferAvoidPodsAnnotationKey: ` | ||||
| 							{ | ||||
|   | ||||
| @@ -17,14 +17,13 @@ limitations under the License. | ||||
| package v1 | ||||
|  | ||||
| import ( | ||||
| 	"k8s.io/apimachinery/pkg/api/meta" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/types" | ||||
| ) | ||||
|  | ||||
| func (obj *ObjectMeta) GetObjectMeta() meta.Object { return obj } | ||||
| func (obj *ObjectMeta) GetObjectMeta() metav1.Object { return obj } | ||||
|  | ||||
| // Namespace implements meta.Object for any object with an ObjectMeta typed field. Allows | ||||
| // Namespace implements metav1.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 } | ||||
|   | ||||
| @@ -65,7 +65,7 @@ import ( | ||||
|  | ||||
| // ObjectMeta is metadata that all persisted resources must have, which includes all objects | ||||
| // users must create. | ||||
| // DEPRECATED: Use k8s.io/kubernetes/pkg/apis/meta/v1.ObjectMeta instead - this type will be removed soon. | ||||
| // DEPRECATED: Use k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta instead - this type will be removed soon. | ||||
| // +k8s:openapi-gen=false | ||||
| type ObjectMeta struct { | ||||
| 	// Name must be unique within a namespace. Is required when creating resources, although | ||||
| @@ -424,7 +424,7 @@ type PersistentVolume struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines a specification of a persistent volume owned by the cluster. | ||||
| 	// Provisioned by an administrator. | ||||
| @@ -516,7 +516,7 @@ type PersistentVolumeClaim struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the desired characteristics of a volume requested by a pod author. | ||||
| 	// More info: http://kubernetes.io/docs/user-guide/persistent-volumes#persistentvolumeclaims | ||||
| @@ -2254,7 +2254,7 @@ type PodStatusResult struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	// Most recently observed status of the pod. | ||||
| 	// This data may not be up to date. | ||||
| 	// Populated by the system. | ||||
| @@ -2273,7 +2273,7 @@ type Pod struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Specification of the desired behavior of the pod. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -2307,7 +2307,7 @@ type PodTemplateSpec struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Specification of the desired behavior of the pod. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -2323,7 +2323,7 @@ type PodTemplate struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Template defines the pods that will be created from this pod template. | ||||
| 	// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -2444,7 +2444,7 @@ type ReplicationController struct { | ||||
| 	// be the same as the Pod(s) that the replication controller manages. | ||||
| 	// Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the specification of the desired behavior of the replication controller. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -2677,7 +2677,7 @@ type Service struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the behavior of a service. | ||||
| 	// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -2721,7 +2721,7 @@ type ServiceAccount struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Secrets is the list of secrets allowed to be used by pods running using this ServiceAccount. | ||||
| 	// More info: http://kubernetes.io/docs/user-guide/secrets | ||||
| @@ -2768,7 +2768,7 @@ type Endpoints struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// The set of all endpoints is the union of all subsets. Addresses are placed into | ||||
| 	// subsets according to the IPs they share. A single address with multiple ports, | ||||
| @@ -3126,7 +3126,7 @@ type Node struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the behavior of a node. | ||||
| 	// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -3198,7 +3198,7 @@ type Namespace struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the behavior of the Namespace. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -3231,7 +3231,7 @@ type Binding struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// The target object that you want to bind to the standard object. | ||||
| 	Target ObjectReference `json:"target" protobuf:"bytes,2,opt,name=target"` | ||||
| @@ -3519,7 +3519,7 @@ type Event struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// The object that this event is about. | ||||
| 	InvolvedObject ObjectReference `json:"involvedObject" protobuf:"bytes,2,opt,name=involvedObject"` | ||||
| @@ -3628,7 +3628,7 @@ type LimitRange struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the limits enforced. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -3726,7 +3726,7 @@ type ResourceQuota struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the desired quota. | ||||
| 	// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -3761,7 +3761,7 @@ type Secret struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Data contains the secret data. Each key must be a valid DNS_SUBDOMAIN | ||||
| 	// or leading dot followed by valid DNS_SUBDOMAIN. | ||||
| @@ -3888,7 +3888,7 @@ type ConfigMap struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Data contains the configuration data. | ||||
| 	// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot. | ||||
| @@ -3943,7 +3943,7 @@ type ComponentStatus struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// List of component conditions observed | ||||
| 	// +optional | ||||
| @@ -4061,7 +4061,7 @@ type RangeAllocation struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Range is string that identifies the range represented by 'data'. | ||||
| 	Range string `json:"range" protobuf:"bytes,2,opt,name=range"` | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| ) | ||||
|  | ||||
| func TestValidateEvent(t *testing.T) { | ||||
|   | ||||
| @@ -26,7 +26,6 @@ import ( | ||||
| 	apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/util/validation/field" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -38,7 +37,7 @@ const ( | ||||
| // Ensure custom name functions are allowed | ||||
| func TestValidateObjectMetaCustomName(t *testing.T) { | ||||
| 	errs := ValidateObjectMeta( | ||||
| 		&api.ObjectMeta{Name: "test", GenerateName: "foo"}, | ||||
| 		&metav1.ObjectMeta{Name: "test", GenerateName: "foo"}, | ||||
| 		false, | ||||
| 		func(s string, prefix bool) []string { | ||||
| 			if s == "test" { | ||||
| @@ -58,7 +57,7 @@ func TestValidateObjectMetaCustomName(t *testing.T) { | ||||
| // Ensure namespace names follow dns label format | ||||
| func TestValidateObjectMetaNamespaces(t *testing.T) { | ||||
| 	errs := ValidateObjectMeta( | ||||
| 		&api.ObjectMeta{Name: "test", Namespace: "foo.bar"}, | ||||
| 		&metav1.ObjectMeta{Name: "test", Namespace: "foo.bar"}, | ||||
| 		true, | ||||
| 		func(s string, prefix bool) []string { | ||||
| 			return nil | ||||
| @@ -77,7 +76,7 @@ func TestValidateObjectMetaNamespaces(t *testing.T) { | ||||
| 		b[i] = letters[rand.Intn(len(letters))] | ||||
| 	} | ||||
| 	errs = ValidateObjectMeta( | ||||
| 		&api.ObjectMeta{Name: "test", Namespace: string(b)}, | ||||
| 		&metav1.ObjectMeta{Name: "test", Namespace: string(b)}, | ||||
| 		true, | ||||
| 		func(s string, prefix bool) []string { | ||||
| 			return nil | ||||
| @@ -198,7 +197,7 @@ func TestValidateObjectMetaOwnerReferences(t *testing.T) { | ||||
|  | ||||
| 	for _, tc := range testCases { | ||||
| 		errs := ValidateObjectMeta( | ||||
| 			&api.ObjectMeta{Name: "test", Namespace: "test", OwnerReferences: tc.ownerReferences}, | ||||
| 			&metav1.ObjectMeta{Name: "test", Namespace: "test", OwnerReferences: tc.ownerReferences}, | ||||
| 			true, | ||||
| 			func(s string, prefix bool) []string { | ||||
| 				return nil | ||||
| @@ -218,22 +217,22 @@ func TestValidateObjectMetaOwnerReferences(t *testing.T) { | ||||
|  | ||||
| func TestValidateObjectMetaUpdateIgnoresCreationTimestamp(t *testing.T) { | ||||
| 	if errs := ValidateObjectMetaUpdate( | ||||
| 		&api.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 		&api.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))}, | ||||
| 		&metav1.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 		&metav1.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))}, | ||||
| 		field.NewPath("field"), | ||||
| 	); len(errs) != 0 { | ||||
| 		t.Fatalf("unexpected errors: %v", errs) | ||||
| 	} | ||||
| 	if errs := ValidateObjectMetaUpdate( | ||||
| 		&api.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))}, | ||||
| 		&api.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 		&metav1.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))}, | ||||
| 		&metav1.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 		field.NewPath("field"), | ||||
| 	); len(errs) != 0 { | ||||
| 		t.Fatalf("unexpected errors: %v", errs) | ||||
| 	} | ||||
| 	if errs := ValidateObjectMetaUpdate( | ||||
| 		&api.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))}, | ||||
| 		&api.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(11, 0))}, | ||||
| 		&metav1.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))}, | ||||
| 		&metav1.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(11, 0))}, | ||||
| 		field.NewPath("field"), | ||||
| 	); len(errs) != 0 { | ||||
| 		t.Fatalf("unexpected errors: %v", errs) | ||||
| @@ -242,28 +241,28 @@ func TestValidateObjectMetaUpdateIgnoresCreationTimestamp(t *testing.T) { | ||||
|  | ||||
| func TestValidateFinalizersUpdate(t *testing.T) { | ||||
| 	testcases := map[string]struct { | ||||
| 		Old         api.ObjectMeta | ||||
| 		New         api.ObjectMeta | ||||
| 		Old         metav1.ObjectMeta | ||||
| 		New         metav1.ObjectMeta | ||||
| 		ExpectedErr string | ||||
| 	}{ | ||||
| 		"invalid adding finalizers": { | ||||
| 			Old:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/a"}}, | ||||
| 			New:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/a", "y/b"}}, | ||||
| 			Old:         metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/a"}}, | ||||
| 			New:         metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/a", "y/b"}}, | ||||
| 			ExpectedErr: "y/b", | ||||
| 		}, | ||||
| 		"invalid changing finalizers": { | ||||
| 			Old:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/a"}}, | ||||
| 			New:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/b"}}, | ||||
| 			Old:         metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/a"}}, | ||||
| 			New:         metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/b"}}, | ||||
| 			ExpectedErr: "x/b", | ||||
| 		}, | ||||
| 		"valid removing finalizers": { | ||||
| 			Old:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/a", "y/b"}}, | ||||
| 			New:         api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/a"}}, | ||||
| 			Old:         metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/a", "y/b"}}, | ||||
| 			New:         metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/a"}}, | ||||
| 			ExpectedErr: "", | ||||
| 		}, | ||||
| 		"valid adding finalizers for objects not being deleted": { | ||||
| 			Old:         api.ObjectMeta{Name: "test", ResourceVersion: "1", Finalizers: []string{"x/a"}}, | ||||
| 			New:         api.ObjectMeta{Name: "test", ResourceVersion: "1", Finalizers: []string{"x/a", "y/b"}}, | ||||
| 			Old:         metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Finalizers: []string{"x/a"}}, | ||||
| 			New:         metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Finalizers: []string{"x/a", "y/b"}}, | ||||
| 			ExpectedErr: "", | ||||
| 		}, | ||||
| 	} | ||||
| @@ -286,59 +285,59 @@ func TestValidateObjectMetaUpdatePreventsDeletionFieldMutation(t *testing.T) { | ||||
| 	gracePeriodLong := int64(40) | ||||
|  | ||||
| 	testcases := map[string]struct { | ||||
| 		Old          api.ObjectMeta | ||||
| 		New          api.ObjectMeta | ||||
| 		ExpectedNew  api.ObjectMeta | ||||
| 		Old          metav1.ObjectMeta | ||||
| 		New          metav1.ObjectMeta | ||||
| 		ExpectedNew  metav1.ObjectMeta | ||||
| 		ExpectedErrs []string | ||||
| 	}{ | ||||
| 		"valid without deletion fields": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			ExpectedNew:  api.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			ExpectedNew:  metav1.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			ExpectedErrs: []string{}, | ||||
| 		}, | ||||
| 		"valid with deletion fields": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			ExpectedNew:  api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			ExpectedNew:  metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			ExpectedErrs: []string{}, | ||||
| 		}, | ||||
|  | ||||
| 		"invalid set deletionTimestamp": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			ExpectedNew:  api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			ExpectedNew:  metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			ExpectedErrs: []string{"field.deletionTimestamp: Invalid value: \"1970-01-01T00:16:40Z\": field is immutable; may only be changed via deletion"}, | ||||
| 		}, | ||||
| 		"invalid clear deletionTimestamp": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			ExpectedNew:  api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			ExpectedNew:  metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			ExpectedErrs: []string{}, // no errors, validation copies the old value | ||||
| 		}, | ||||
| 		"invalid change deletionTimestamp": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &later}, | ||||
| 			ExpectedNew:  api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &later}, | ||||
| 			ExpectedNew:  metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, | ||||
| 			ExpectedErrs: []string{}, // no errors, validation copies the old value | ||||
| 		}, | ||||
|  | ||||
| 		"invalid set deletionGracePeriodSeconds": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			ExpectedNew:  api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			ExpectedNew:  metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			ExpectedErrs: []string{"field.deletionGracePeriodSeconds: Invalid value: 30: field is immutable; may only be changed via deletion"}, | ||||
| 		}, | ||||
| 		"invalid clear deletionGracePeriodSeconds": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			ExpectedNew:  api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1"}, | ||||
| 			ExpectedNew:  metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			ExpectedErrs: []string{}, // no errors, validation copies the old value | ||||
| 		}, | ||||
| 		"invalid change deletionGracePeriodSeconds": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodLong}, | ||||
| 			ExpectedNew:  api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodLong}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodLong}, | ||||
| 			ExpectedNew:  metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodLong}, | ||||
| 			ExpectedErrs: []string{"field.deletionGracePeriodSeconds: Invalid value: 40: field is immutable; may only be changed via deletion"}, | ||||
| 		}, | ||||
| 	} | ||||
| @@ -364,23 +363,23 @@ func TestValidateObjectMetaUpdatePreventsDeletionFieldMutation(t *testing.T) { | ||||
|  | ||||
| func TestObjectMetaGenerationUpdate(t *testing.T) { | ||||
| 	testcases := map[string]struct { | ||||
| 		Old          api.ObjectMeta | ||||
| 		New          api.ObjectMeta | ||||
| 		Old          metav1.ObjectMeta | ||||
| 		New          metav1.ObjectMeta | ||||
| 		ExpectedErrs []string | ||||
| 	}{ | ||||
| 		"invalid generation change - decremented": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 4}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 4}, | ||||
| 			ExpectedErrs: []string{"field.generation: Invalid value: 4: must not be decremented"}, | ||||
| 		}, | ||||
| 		"valid generation change - incremented by one": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 1}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 2}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 1}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 2}, | ||||
| 			ExpectedErrs: []string{}, | ||||
| 		}, | ||||
| 		"valid generation field - not updated": { | ||||
| 			Old:          api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5}, | ||||
| 			New:          api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5}, | ||||
| 			Old:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5}, | ||||
| 			New:          metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5}, | ||||
| 			ExpectedErrs: []string{}, | ||||
| 		}, | ||||
| 	} | ||||
| @@ -408,7 +407,7 @@ func TestObjectMetaGenerationUpdate(t *testing.T) { | ||||
| // Ensure trailing slash is allowed in generate name | ||||
| func TestValidateObjectMetaTrimsTrailingSlash(t *testing.T) { | ||||
| 	errs := ValidateObjectMeta( | ||||
| 		&api.ObjectMeta{Name: "test", GenerateName: "foo-"}, | ||||
| 		&metav1.ObjectMeta{Name: "test", GenerateName: "foo-"}, | ||||
| 		false, | ||||
| 		apimachineryvalidation.NameIsDNSSubdomain, | ||||
| 		field.NewPath("field")) | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"k8s.io/apimachinery/pkg/api/meta" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||
|   | ||||
| @@ -49,13 +49,13 @@ func TestAPIObjectMeta(t *testing.T) { | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	var _ meta.Object = &j.ObjectMeta | ||||
| 	var _ meta.ObjectMetaAccessor = j | ||||
| 	var _ metav1.Object = &j.ObjectMeta | ||||
| 	var _ metav1.ObjectMetaAccessor = j | ||||
| 	accessor, err := meta.Accessor(j) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("unexpected error: %v", err) | ||||
| 	} | ||||
| 	if accessor != meta.Object(j) { | ||||
| 	if accessor != metav1.Object(j) { | ||||
| 		t.Fatalf("should have returned the same pointer: %#v\n\n%#v", accessor, j) | ||||
| 	} | ||||
| 	if e, a := "bar", accessor.GetNamespace(); e != a { | ||||
|   | ||||
| @@ -32,7 +32,7 @@ import ( | ||||
| type StatefulSet struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the desired identities of pods in this set. | ||||
| 	// +optional | ||||
|   | ||||
| @@ -32,7 +32,7 @@ import ( | ||||
| type StatefulSet struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the desired identities of pods in this set. | ||||
| 	// +optional | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package authentication | ||||
|  | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -43,9 +42,9 @@ const ( | ||||
| // TokenReview attempts to authenticate a token to a known user. | ||||
| type TokenReview struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// ObjectMeta fulfills the meta.ObjectMetaAccessor interface so that the stock | ||||
| 	// ObjectMeta fulfills the metav1.ObjectMetaAccessor interface so that the stock | ||||
| 	// REST handler paths work | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec holds information about the request being evaluated | ||||
| 	Spec TokenReviewSpec | ||||
|   | ||||
| @@ -20,7 +20,6 @@ import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| ) | ||||
|  | ||||
| // +genclient=true | ||||
| @@ -33,7 +32,7 @@ import ( | ||||
| type TokenReview struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec holds information about the request being evaluated | ||||
| 	Spec TokenReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package authorization | ||||
|  | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| ) | ||||
|  | ||||
| // +genclient=true | ||||
| @@ -29,7 +28,7 @@ import ( | ||||
| // spec.namespace means "in all namespaces". | ||||
| type SubjectAccessReview struct { | ||||
| 	metav1.TypeMeta | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec holds information about the request being evaluated | ||||
| 	Spec SubjectAccessReviewSpec | ||||
| @@ -47,7 +46,7 @@ type SubjectAccessReview struct { | ||||
| // to check whether they can perform an action | ||||
| type SelfSubjectAccessReview struct { | ||||
| 	metav1.TypeMeta | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec holds information about the request being evaluated. | ||||
| 	Spec SelfSubjectAccessReviewSpec | ||||
| @@ -64,7 +63,7 @@ type SelfSubjectAccessReview struct { | ||||
| // checking. | ||||
| type LocalSubjectAccessReview struct { | ||||
| 	metav1.TypeMeta | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec holds information about the request being evaluated.  spec.namespace must be equal to the namespace | ||||
| 	// you made the request against.  If empty, it is defaulted. | ||||
|   | ||||
| @@ -20,7 +20,6 @@ import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| ) | ||||
|  | ||||
| // +genclient=true | ||||
| @@ -31,7 +30,7 @@ import ( | ||||
| type SubjectAccessReview struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec holds information about the request being evaluated | ||||
| 	Spec SubjectAccessReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` | ||||
| @@ -51,7 +50,7 @@ type SubjectAccessReview struct { | ||||
| type SelfSubjectAccessReview struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec holds information about the request being evaluated.  user and groups must be empty | ||||
| 	Spec SelfSubjectAccessReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` | ||||
| @@ -70,7 +69,7 @@ type SelfSubjectAccessReview struct { | ||||
| type LocalSubjectAccessReview struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec holds information about the request being evaluated.  spec.namespace must be equal to the namespace | ||||
| 	// you made the request against.  If empty, it is defaulted. | ||||
|   | ||||
| @@ -17,6 +17,7 @@ limitations under the License. | ||||
| package validation | ||||
|  | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/util/validation/field" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	authorizationapi "k8s.io/kubernetes/pkg/apis/authorization" | ||||
| @@ -51,7 +52,7 @@ func ValidateSelfSubjectAccessReviewSpec(spec authorizationapi.SelfSubjectAccess | ||||
|  | ||||
| func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) field.ErrorList { | ||||
| 	allErrs := ValidateSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec")) | ||||
| 	if !api.Semantic.DeepEqual(api.ObjectMeta{}, sar.ObjectMeta) { | ||||
| 	if !api.Semantic.DeepEqual(metav1.ObjectMeta{}, sar.ObjectMeta) { | ||||
| 		allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty`)) | ||||
| 	} | ||||
| 	return allErrs | ||||
| @@ -59,7 +60,7 @@ func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) fiel | ||||
|  | ||||
| func ValidateSelfSubjectAccessReview(sar *authorizationapi.SelfSubjectAccessReview) field.ErrorList { | ||||
| 	allErrs := ValidateSelfSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec")) | ||||
| 	if !api.Semantic.DeepEqual(api.ObjectMeta{}, sar.ObjectMeta) { | ||||
| 	if !api.Semantic.DeepEqual(metav1.ObjectMeta{}, sar.ObjectMeta) { | ||||
| 		allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty`)) | ||||
| 	} | ||||
| 	return allErrs | ||||
| @@ -70,7 +71,7 @@ func ValidateLocalSubjectAccessReview(sar *authorizationapi.LocalSubjectAccessRe | ||||
|  | ||||
| 	objectMetaShallowCopy := sar.ObjectMeta | ||||
| 	objectMetaShallowCopy.Namespace = "" | ||||
| 	if !api.Semantic.DeepEqual(api.ObjectMeta{}, objectMetaShallowCopy) { | ||||
| 	if !api.Semantic.DeepEqual(metav1.ObjectMeta{}, objectMetaShallowCopy) { | ||||
| 		allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty except for namespace`)) | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -20,8 +20,8 @@ import ( | ||||
| 	"strings" | ||||
| 	"testing" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/util/validation/field" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	authorizationapi "k8s.io/kubernetes/pkg/apis/authorization" | ||||
| ) | ||||
|  | ||||
| @@ -158,7 +158,7 @@ func TestValidateLocalSAR(t *testing.T) { | ||||
| 		{ | ||||
| 			name: "name", | ||||
| 			obj: &authorizationapi.LocalSubjectAccessReview{ | ||||
| 				ObjectMeta: api.ObjectMeta{Name: "a"}, | ||||
| 				ObjectMeta: metav1.ObjectMeta{Name: "a"}, | ||||
| 				Spec: authorizationapi.SubjectAccessReviewSpec{ | ||||
| 					ResourceAttributes: &authorizationapi.ResourceAttributes{}, | ||||
| 					User:               "user", | ||||
| @@ -169,7 +169,7 @@ func TestValidateLocalSAR(t *testing.T) { | ||||
| 		{ | ||||
| 			name: "namespace conflict", | ||||
| 			obj: &authorizationapi.LocalSubjectAccessReview{ | ||||
| 				ObjectMeta: api.ObjectMeta{Namespace: "a"}, | ||||
| 				ObjectMeta: metav1.ObjectMeta{Namespace: "a"}, | ||||
| 				Spec: authorizationapi.SubjectAccessReviewSpec{ | ||||
| 					ResourceAttributes: &authorizationapi.ResourceAttributes{}, | ||||
| 					User:               "user", | ||||
| @@ -180,7 +180,7 @@ func TestValidateLocalSAR(t *testing.T) { | ||||
| 		{ | ||||
| 			name: "nonresource", | ||||
| 			obj: &authorizationapi.LocalSubjectAccessReview{ | ||||
| 				ObjectMeta: api.ObjectMeta{Namespace: "a"}, | ||||
| 				ObjectMeta: metav1.ObjectMeta{Namespace: "a"}, | ||||
| 				Spec: authorizationapi.SubjectAccessReviewSpec{ | ||||
| 					NonResourceAttributes: &authorizationapi.NonResourceAttributes{}, | ||||
| 					User: "user", | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package autoscaling | ||||
|  | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| ) | ||||
|  | ||||
| // Scale represents a scaling request for a resource. | ||||
| @@ -26,7 +25,7 @@ type Scale struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata. | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. | ||||
| 	// +optional | ||||
| @@ -113,7 +112,7 @@ type HorizontalPodAutoscalerStatus struct { | ||||
| type HorizontalPodAutoscaler struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. | ||||
| 	// +optional | ||||
|   | ||||
| @@ -78,7 +78,7 @@ type HorizontalPodAutoscaler struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. | ||||
| 	// +optional | ||||
| @@ -105,7 +105,7 @@ type Scale struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata. | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. | ||||
| 	// +optional | ||||
|   | ||||
| @@ -22,6 +22,7 @@ import ( | ||||
|  | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/apis/autoscaling" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/controller/podautoscaler" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -29,7 +29,7 @@ type Job struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec is a structure defining the expected behavior of a job. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -60,7 +60,7 @@ type JobTemplate struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Template defines jobs that will be created from this template | ||||
| 	// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -73,7 +73,7 @@ type JobTemplateSpec struct { | ||||
| 	// Standard object's metadata of the jobs created from this template. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Specification of the desired behavior of the job. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -196,7 +196,7 @@ type CronJob struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec is a structure defining the expected behavior of a job, including the schedule. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import ( | ||||
| 	"reflect" | ||||
| 	"testing" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	_ "k8s.io/kubernetes/pkg/api/install" | ||||
| @@ -39,7 +40,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 			original: &Job{ | ||||
| 				Spec: JobSpec{ | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -53,12 +54,12 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 		}, | ||||
| 		"both unspecified -> sets both to 1 and no default labels": { | ||||
| 			original: &Job{ | ||||
| 				ObjectMeta: v1.ObjectMeta{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Labels: map[string]string{"mylabel": "myvalue"}, | ||||
| 				}, | ||||
| 				Spec: JobSpec{ | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -74,7 +75,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 				Spec: JobSpec{ | ||||
| 					Parallelism: newInt32(0), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -90,7 +91,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 				Spec: JobSpec{ | ||||
| 					Parallelism: newInt32(2), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -106,7 +107,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 				Spec: JobSpec{ | ||||
| 					Completions: newInt32(2), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -124,7 +125,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 					Completions: newInt32(10), | ||||
| 					Parallelism: newInt32(11), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -133,7 +134,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 					Completions: newInt32(10), | ||||
| 					Parallelism: newInt32(11), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -145,7 +146,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 					Completions: newInt32(11), | ||||
| 					Parallelism: newInt32(10), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
|   | ||||
| @@ -29,7 +29,7 @@ type Job struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec is a structure defining the expected behavior of a job. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import ( | ||||
| 	"reflect" | ||||
| 	"testing" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	_ "k8s.io/kubernetes/pkg/api/install" | ||||
| @@ -39,7 +40,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 			original: &Job{ | ||||
| 				Spec: JobSpec{ | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -53,12 +54,12 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 		}, | ||||
| 		"both unspecified -> sets both to 1 and no default labels": { | ||||
| 			original: &Job{ | ||||
| 				ObjectMeta: v1.ObjectMeta{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Labels: map[string]string{"mylabel": "myvalue"}, | ||||
| 				}, | ||||
| 				Spec: JobSpec{ | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -74,7 +75,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 				Spec: JobSpec{ | ||||
| 					Parallelism: newInt32(0), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -90,7 +91,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 				Spec: JobSpec{ | ||||
| 					Parallelism: newInt32(2), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -106,7 +107,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 				Spec: JobSpec{ | ||||
| 					Completions: newInt32(2), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -124,7 +125,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 					Completions: newInt32(10), | ||||
| 					Parallelism: newInt32(11), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -133,7 +134,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 					Completions: newInt32(10), | ||||
| 					Parallelism: newInt32(11), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -145,7 +146,7 @@ func TestSetDefaultJob(t *testing.T) { | ||||
| 					Completions: newInt32(11), | ||||
| 					Parallelism: newInt32(10), | ||||
| 					Template: v1.PodTemplateSpec{ | ||||
| 						ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, | ||||
| 						ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
|   | ||||
| @@ -29,7 +29,7 @@ type Job struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec is a structure defining the expected behavior of a job. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -60,7 +60,7 @@ type JobTemplate struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Template defines jobs that will be created from this template | ||||
| 	// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -73,7 +73,7 @@ type JobTemplateSpec struct { | ||||
| 	// Standard object's metadata of the jobs created from this template. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Specification of the desired behavior of the job. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -202,7 +202,7 @@ type CronJob struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec is a structure defining the expected behavior of a job, including the schedule. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
|   | ||||
| @@ -28,7 +28,7 @@ import ( | ||||
| type CertificateSigningRequest struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// The certificate request itself and any additional information. | ||||
| 	// +optional | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package v1alpha1 | ||||
|  | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| ) | ||||
|  | ||||
| // +genclient=true | ||||
| @@ -28,7 +27,7 @@ import ( | ||||
| type CertificateSigningRequest struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// The certificate request itself and any additional information. | ||||
| 	// +optional | ||||
|   | ||||
| @@ -68,7 +68,7 @@ type Scale struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata. | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. | ||||
| 	// +optional | ||||
| @@ -117,7 +117,7 @@ type ThirdPartyResource struct { | ||||
|  | ||||
| 	// Standard object metadata | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Description is the description of this object. | ||||
| 	// +optional | ||||
| @@ -150,7 +150,7 @@ type ThirdPartyResourceData struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// Standard object metadata. | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Data is the raw JSON data for this data. | ||||
| 	// +optional | ||||
| @@ -162,7 +162,7 @@ type ThirdPartyResourceData struct { | ||||
| type Deployment struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Specification of the desired behavior of the Deployment. | ||||
| 	// +optional | ||||
| @@ -492,7 +492,7 @@ type DaemonSet struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the desired behavior of this daemon set. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -541,7 +541,7 @@ type Ingress struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec is the desired state of the Ingress. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -702,7 +702,7 @@ type IngressBackend struct { | ||||
| type ReplicaSet struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the desired behavior of this ReplicaSet. | ||||
| 	// +optional | ||||
| @@ -810,7 +810,7 @@ type ReplicaSetCondition struct { | ||||
| type PodSecurityPolicy struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec defines the policy enforced. | ||||
| 	// +optional | ||||
| @@ -1017,7 +1017,7 @@ type PodSecurityPolicyList struct { | ||||
| type NetworkPolicy struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Specification of the desired behavior for this NetworkPolicy. | ||||
| 	// +optional | ||||
|   | ||||
| @@ -57,7 +57,7 @@ type Scale struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata. | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. | ||||
| 	// +optional | ||||
| @@ -162,7 +162,7 @@ type HorizontalPodAutoscaler struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. | ||||
| 	// +optional | ||||
| @@ -194,7 +194,7 @@ type ThirdPartyResource struct { | ||||
|  | ||||
| 	// Standard object metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Description is the description of this object. | ||||
| 	// +optional | ||||
| @@ -229,7 +229,7 @@ type ThirdPartyResourceData struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object metadata. | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Data is the raw JSON data for this data. | ||||
| 	// +optional | ||||
| @@ -243,7 +243,7 @@ type Deployment struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object metadata. | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Specification of the desired behavior of the Deployment. | ||||
| 	// +optional | ||||
| @@ -582,7 +582,7 @@ type DaemonSet struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the desired behavior of this daemon set. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -633,7 +633,7 @@ type Ingress struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec is the desired state of the Ingress. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -798,7 +798,7 @@ type ReplicaSet struct { | ||||
| 	// be the same as the Pod(s) that the ReplicaSet manages. | ||||
| 	// Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec defines the specification of the desired behavior of the ReplicaSet. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | ||||
| @@ -920,7 +920,7 @@ type PodSecurityPolicy struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// spec defines the policy enforced. | ||||
| 	// +optional | ||||
| @@ -1128,7 +1128,7 @@ type NetworkPolicy struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Specification of the desired behavior for this NetworkPolicy. | ||||
| 	// +optional | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package imagepolicy | ||||
|  | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| ) | ||||
|  | ||||
| // +genclient=true | ||||
| @@ -28,7 +27,7 @@ import ( | ||||
| // ImageReview checks if the set of images in a pod are allowed. | ||||
| type ImageReview struct { | ||||
| 	metav1.TypeMeta | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Spec holds information about the pod being evaluated | ||||
| 	Spec ImageReviewSpec | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package v1alpha1 | ||||
|  | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| ) | ||||
|  | ||||
| // +genclient=true | ||||
| @@ -29,7 +28,7 @@ import ( | ||||
| type ImageReview struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Spec holds information about the pod being evaluated | ||||
| 	Spec ImageReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` | ||||
|   | ||||
| @@ -77,7 +77,7 @@ type PodDisruptionBudgetStatus struct { | ||||
| type PodDisruptionBudget struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Specification of the desired behavior of the PodDisruptionBudget. | ||||
| 	// +optional | ||||
| @@ -106,7 +106,7 @@ type Eviction struct { | ||||
|  | ||||
| 	// ObjectMeta describes the pod that is being evicted. | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// DeleteOptions may be provided | ||||
| 	// +optional | ||||
|   | ||||
| @@ -59,7 +59,7 @@ type PodDisruptionBudgetStatus struct { | ||||
| type PodDisruptionBudget struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Specification of the desired behavior of the PodDisruptionBudget. | ||||
| 	// +optional | ||||
| @@ -85,7 +85,7 @@ type Eviction struct { | ||||
|  | ||||
| 	// ObjectMeta describes the pod that is being evicted. | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// DeleteOptions may be provided | ||||
| 	// +optional | ||||
|   | ||||
| @@ -73,8 +73,8 @@ type PodDisruptionBudgetStatus struct { | ||||
|  | ||||
| // PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods | ||||
| type PodDisruptionBudget struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	v1.ObjectMeta   `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.TypeMeta   `json:",inline"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Specification of the desired behavior of the PodDisruptionBudget. | ||||
| 	Spec PodDisruptionBudgetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` | ||||
| @@ -99,7 +99,7 @@ type Eviction struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
|  | ||||
| 	// ObjectMeta describes the pod that is being evicted. | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// DeleteOptions may be provided | ||||
| 	DeleteOptions *v1.DeleteOptions `json:"deleteOptions,omitempty" protobuf:"bytes,2,opt,name=deleteOptions"` | ||||
|   | ||||
| @@ -20,9 +20,9 @@ import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||
| 	"k8s.io/apimachinery/pkg/util/sets" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| ) | ||||
|  | ||||
| func RoleRefGroupKind(roleRef RoleRef) schema.GroupKind { | ||||
| @@ -208,7 +208,7 @@ type ClusterRoleBindingBuilder struct { | ||||
| func NewClusterBinding(clusterRoleName string) *ClusterRoleBindingBuilder { | ||||
| 	return &ClusterRoleBindingBuilder{ | ||||
| 		ClusterRoleBinding: ClusterRoleBinding{ | ||||
| 			ObjectMeta: api.ObjectMeta{Name: clusterRoleName}, | ||||
| 			ObjectMeta: metav1.ObjectMeta{Name: clusterRoleName}, | ||||
| 			RoleRef: RoleRef{ | ||||
| 				APIGroup: GroupName, | ||||
| 				Kind:     "ClusterRole", | ||||
|   | ||||
| @@ -19,7 +19,6 @@ package rbac | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| ) | ||||
|  | ||||
| // Authorization is calculated against | ||||
| @@ -94,7 +93,7 @@ type RoleRef struct { | ||||
| type Role struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// Standard object's metadata. | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Rules holds all the PolicyRules for this Role | ||||
| 	Rules []PolicyRule | ||||
| @@ -107,7 +106,7 @@ type Role struct { | ||||
| // namespace only have effect in that namespace. | ||||
| type RoleBinding struct { | ||||
| 	metav1.TypeMeta | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Subjects holds references to the objects the role applies to. | ||||
| 	Subjects []Subject | ||||
| @@ -144,7 +143,7 @@ type RoleList struct { | ||||
| type ClusterRole struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// Standard object's metadata. | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Rules holds all the PolicyRules for this ClusterRole | ||||
| 	Rules []PolicyRule | ||||
| @@ -158,7 +157,7 @@ type ClusterRole struct { | ||||
| type ClusterRoleBinding struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// Standard object's metadata. | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// Subjects holds references to the objects the role applies to. | ||||
| 	Subjects []Subject | ||||
|   | ||||
| @@ -19,7 +19,7 @@ package v1alpha1 | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| ) | ||||
|  | ||||
| // +k8s:deepcopy-gen=false | ||||
|   | ||||
| @@ -19,7 +19,6 @@ package v1alpha1 | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| ) | ||||
|  | ||||
| // Authorization is calculated against | ||||
| @@ -106,7 +105,7 @@ type Role struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object's metadata. | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Rules holds all the PolicyRules for this Role | ||||
| 	Rules []PolicyRule `json:"rules" protobuf:"bytes,2,rep,name=rules"` | ||||
| @@ -121,7 +120,7 @@ type RoleBinding struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object's metadata. | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Subjects holds references to the objects the role applies to. | ||||
| 	Subjects []Subject `json:"subjects" protobuf:"bytes,2,rep,name=subjects"` | ||||
| @@ -161,7 +160,7 @@ type ClusterRole struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object's metadata. | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Rules holds all the PolicyRules for this ClusterRole | ||||
| 	Rules []PolicyRule `json:"rules" protobuf:"bytes,2,rep,name=rules"` | ||||
| @@ -176,7 +175,7 @@ type ClusterRoleBinding struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// Standard object's metadata. | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Subjects holds references to the objects the role applies to. | ||||
| 	Subjects []Subject `json:"subjects" protobuf:"bytes,2,rep,name=subjects"` | ||||
|   | ||||
| @@ -19,6 +19,7 @@ package validation | ||||
| import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/util/validation/field" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/apis/rbac" | ||||
|   | ||||
| @@ -33,7 +33,7 @@ import ( | ||||
| type StorageClass struct { | ||||
| 	metav1.TypeMeta | ||||
| 	// +optional | ||||
| 	api.ObjectMeta | ||||
| 	metav1.ObjectMeta | ||||
|  | ||||
| 	// provisioner is the driver expected to handle this StorageClass. | ||||
| 	// This is an optionally-prefixed name, like a label key. | ||||
|   | ||||
| @@ -18,6 +18,7 @@ package util | ||||
|  | ||||
| import ( | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| ) | ||||
|  | ||||
| // IsDefaultStorageClassAnnotation represents a StorageClass annotation that | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package v1beta1 | ||||
|  | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| ) | ||||
|  | ||||
| // +genclient=true | ||||
| @@ -34,7 +33,7 @@ type StorageClass struct { | ||||
| 	// Standard object's metadata. | ||||
| 	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` | ||||
|  | ||||
| 	// Provisioner indicates the type of the provisioner. | ||||
| 	Provisioner string `json:"provisioner" protobuf:"bytes,2,opt,name=provisioner"` | ||||
|   | ||||
| @@ -16,7 +16,10 @@ limitations under the License. | ||||
|  | ||||
| package util | ||||
|  | ||||
| import "k8s.io/kubernetes/pkg/api/v1" | ||||
| import ( | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| ) | ||||
|  | ||||
| // IsDefaultStorageClassAnnotation represents a StorageClass annotation that | ||||
| // marks a class as the default StorageClass | ||||
|   | ||||
| @@ -20,7 +20,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"testing" | ||||
|  | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/apis/storage" | ||||
| ) | ||||
|  | ||||
|   | ||||
							
								
								
									
										3
									
								
								pkg/client/cache/listers_core.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								pkg/client/cache/listers_core.go
									
									
									
									
										vendored
									
									
								
							| @@ -20,6 +20,7 @@ import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"k8s.io/apimachinery/pkg/api/errors" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/labels" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| @@ -183,7 +184,7 @@ func (s *StoreToReplicationControllerLister) GetPodControllers(pod *v1.Pod) (con | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	key := &v1.ReplicationController{ObjectMeta: v1.ObjectMeta{Namespace: pod.Namespace}} | ||||
| 	key := &v1.ReplicationController{ObjectMeta: metav1.ObjectMeta{Namespace: pod.Namespace}} | ||||
| 	items, err := s.Indexer.Index(NamespaceIndex, key) | ||||
| 	if err != nil { | ||||
| 		return | ||||
|   | ||||
| @@ -20,6 +20,7 @@ package internalversion | ||||
|  | ||||
| import ( | ||||
| 	"k8s.io/apimachinery/pkg/api/errors" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/labels" | ||||
| 	api "k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/client/cache" | ||||
|   | ||||
| @@ -20,6 +20,7 @@ package internalversion | ||||
|  | ||||
| import ( | ||||
| 	"k8s.io/apimachinery/pkg/api/errors" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/labels" | ||||
| 	api "k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/client/cache" | ||||
|   | ||||
| @@ -20,6 +20,7 @@ package internalversion | ||||
|  | ||||
| import ( | ||||
| 	"k8s.io/apimachinery/pkg/api/errors" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/labels" | ||||
| 	api "k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/client/cache" | ||||
|   | ||||
| @@ -20,6 +20,7 @@ package internalversion | ||||
|  | ||||
| import ( | ||||
| 	"k8s.io/apimachinery/pkg/api/errors" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/labels" | ||||
| 	api "k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/client/cache" | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import ( | ||||
| 	"sync" | ||||
|  | ||||
| 	"k8s.io/apimachinery/pkg/api/meta" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/apimachinery/pkg/types" | ||||
| 	"k8s.io/apimachinery/pkg/watch" | ||||
| @@ -114,7 +115,7 @@ func (f *FakeControllerSource) DeleteDropWatch(lastValue runtime.Object) { | ||||
| 	f.Change(watch.Event{Type: watch.Deleted, Object: lastValue}, 0) | ||||
| } | ||||
|  | ||||
| func (f *FakeControllerSource) key(accessor meta.Object) nnu { | ||||
| func (f *FakeControllerSource) key(accessor metav1.Object) nnu { | ||||
| 	return nnu{accessor.GetNamespace(), accessor.GetName(), accessor.GetUID()} | ||||
| } | ||||
|  | ||||
| @@ -173,7 +174,7 @@ func (f *FakeControllerSource) List(options v1.ListOptions) (runtime.Object, err | ||||
| 	if err := meta.SetList(listObj, list); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	objMeta, err := api.ListMetaFor(listObj) | ||||
| 	objMeta, err := metav1.ListMetaFor(listObj) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -194,7 +195,7 @@ func (f *FakePVControllerSource) List(options v1.ListOptions) (runtime.Object, e | ||||
| 	if err := meta.SetList(listObj, list); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	objMeta, err := api.ListMetaFor(listObj) | ||||
| 	objMeta, err := metav1.ListMetaFor(listObj) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -215,7 +216,7 @@ func (f *FakePVCControllerSource) List(options v1.ListOptions) (runtime.Object, | ||||
| 	if err := meta.SetList(listObj, list); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	objMeta, err := api.ListMetaFor(listObj) | ||||
| 	objMeta, err := metav1.ListMetaFor(listObj) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
| @@ -24,6 +24,7 @@ import ( | ||||
| 	"github.com/golang/glog" | ||||
| 	"github.com/robfig/cron" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||
| 	"k8s.io/apimachinery/pkg/types" | ||||
|   | ||||
| @@ -127,7 +127,7 @@ func newPod(podName string, nodeName string, label map[string]string) *v1.Pod { | ||||
| 			DNSPolicy: v1.DNSDefault, | ||||
| 		}, | ||||
| 	} | ||||
| 	v1.GenerateName(v1.SimpleNameGenerator, &pod.ObjectMeta) | ||||
| 	metav1.GenerateName(v1.SimpleNameGenerator, &pod.ObjectMeta) | ||||
| 	return pod | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -212,7 +212,7 @@ func referencesDiffs(old []metav1.OwnerReference, new []metav1.OwnerReference) ( | ||||
| 	return added, removed | ||||
| } | ||||
|  | ||||
| func shouldOrphanDependents(e *event, accessor meta.Object) bool { | ||||
| func shouldOrphanDependents(e *event, accessor metav1.Object) bool { | ||||
| 	// The delta_fifo may combine the creation and update of the object into one | ||||
| 	// event, so we need to check AddEvent as well. | ||||
| 	if e.oldObj == nil { | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package metaonly | ||||
|  | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| ) | ||||
|  | ||||
| // MetadataOnlyObject allows decoding only the apiVersion, kind, and metadata fields of | ||||
| @@ -27,7 +26,7 @@ import ( | ||||
| type MetadataOnlyObject struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// +optional | ||||
| 	v1.ObjectMeta `json:"metadata,omitempty"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty"` | ||||
| } | ||||
|  | ||||
| // MetadataOnlyObjectList allows decoding from JSON data only the typemeta and metadata of | ||||
|   | ||||
| @@ -21,12 +21,12 @@ import ( | ||||
| 	"sync" | ||||
|  | ||||
| 	"github.com/golang/groupcache/lru" | ||||
| 	"k8s.io/apimachinery/pkg/api/meta" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	hashutil "k8s.io/kubernetes/pkg/util/hash" | ||||
| ) | ||||
|  | ||||
| type objectWithMeta interface { | ||||
| 	meta.Object | ||||
| 	metav1.Object | ||||
| } | ||||
|  | ||||
| // keyFunc returns the key of an object, which is used to look up in the cache for it's matching object. | ||||
|   | ||||
| @@ -1,373 +0,0 @@ | ||||
| /* | ||||
| Copyright 2015 The Kubernetes Authors. | ||||
|  | ||||
| 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 metrics | ||||
|  | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"k8s.io/kubernetes/pkg/api/resource" | ||||
| 	metav1 "k8s.io/kubernetes/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/api/v1" | ||||
| 	_ "k8s.io/kubernetes/pkg/apimachinery/registered" | ||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake" | ||||
| 	"k8s.io/kubernetes/pkg/client/restclient" | ||||
| 	"k8s.io/kubernetes/pkg/client/testing/core" | ||||
| 	"k8s.io/kubernetes/pkg/labels" | ||||
| 	"k8s.io/kubernetes/pkg/runtime" | ||||
|  | ||||
| 	heapster "k8s.io/heapster/metrics/api/v1/types" | ||||
| 	metricsapi "k8s.io/heapster/metrics/apis/metrics/v1alpha1" | ||||
|  | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| ) | ||||
|  | ||||
| var fixedTimestamp = time.Date(2015, time.November, 10, 12, 30, 0, 0, time.UTC) | ||||
|  | ||||
| func (w fakeResponseWrapper) DoRaw() ([]byte, error) { | ||||
| 	return w.raw, nil | ||||
| } | ||||
|  | ||||
| func (w fakeResponseWrapper) Stream() (io.ReadCloser, error) { | ||||
| 	return nil, nil | ||||
| } | ||||
|  | ||||
| func newFakeResponseWrapper(raw []byte) fakeResponseWrapper { | ||||
| 	return fakeResponseWrapper{raw: raw} | ||||
| } | ||||
|  | ||||
| type fakeResponseWrapper struct { | ||||
| 	raw []byte | ||||
| } | ||||
|  | ||||
| // timestamp is used for establishing order on metricPoints | ||||
| type metricPoint struct { | ||||
| 	level     uint64 | ||||
| 	timestamp int | ||||
| } | ||||
|  | ||||
| type testCase struct { | ||||
| 	desiredResourceValues PodResourceInfo | ||||
| 	desiredMetricValues   PodMetricsInfo | ||||
| 	desiredError          error | ||||
|  | ||||
| 	replicas              int | ||||
| 	targetTimestamp       int | ||||
| 	reportedMetricsPoints [][]metricPoint | ||||
| 	reportedPodMetrics    [][]int64 | ||||
|  | ||||
| 	namespace    string | ||||
| 	selector     labels.Selector | ||||
| 	resourceName v1.ResourceName | ||||
| 	metricName   string | ||||
| } | ||||
|  | ||||
| func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset { | ||||
| 	namespace := "test-namespace" | ||||
| 	tc.namespace = namespace | ||||
| 	podNamePrefix := "test-pod" | ||||
| 	podLabels := map[string]string{"name": podNamePrefix} | ||||
| 	tc.selector = labels.SelectorFromSet(podLabels) | ||||
|  | ||||
| 	// it's a resource test if we have a resource name | ||||
| 	isResource := len(tc.resourceName) > 0 | ||||
|  | ||||
| 	fakeClient := &fake.Clientset{} | ||||
|  | ||||
| 	fakeClient.AddReactor("list", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) { | ||||
| 		obj := &v1.PodList{} | ||||
| 		for i := 0; i < tc.replicas; i++ { | ||||
| 			podName := fmt.Sprintf("%s-%d", podNamePrefix, i) | ||||
| 			pod := buildPod(namespace, podName, podLabels, v1.PodRunning, "1024") | ||||
| 			obj.Items = append(obj.Items, pod) | ||||
| 		} | ||||
| 		return true, obj, nil | ||||
| 	}) | ||||
|  | ||||
| 	if isResource { | ||||
| 		fakeClient.AddProxyReactor("services", func(action core.Action) (handled bool, ret restclient.ResponseWrapper, err error) { | ||||
| 			metrics := metricsapi.PodMetricsList{} | ||||
| 			for i, containers := range tc.reportedPodMetrics { | ||||
| 				metric := metricsapi.PodMetrics{ | ||||
| 					ObjectMeta: v1.ObjectMeta{ | ||||
| 						Name:      fmt.Sprintf("%s-%d", podNamePrefix, i), | ||||
| 						Namespace: namespace, | ||||
| 					}, | ||||
| 					Timestamp:  metav1.Time{Time: fixedTimestamp.Add(time.Duration(tc.targetTimestamp) * time.Minute)}, | ||||
| 					Containers: []metricsapi.ContainerMetrics{}, | ||||
| 				} | ||||
| 				for j, cpu := range containers { | ||||
| 					cm := metricsapi.ContainerMetrics{ | ||||
| 						Name: fmt.Sprintf("%s-%d-container-%d", podNamePrefix, i, j), | ||||
| 						Usage: v1.ResourceList{ | ||||
| 							v1.ResourceCPU: *resource.NewMilliQuantity( | ||||
| 								cpu, | ||||
| 								resource.DecimalSI), | ||||
| 							v1.ResourceMemory: *resource.NewQuantity( | ||||
| 								int64(1024*1024), | ||||
| 								resource.BinarySI), | ||||
| 						}, | ||||
| 					} | ||||
| 					metric.Containers = append(metric.Containers, cm) | ||||
| 				} | ||||
| 				metrics.Items = append(metrics.Items, metric) | ||||
| 			} | ||||
| 			heapsterRawMemResponse, _ := json.Marshal(&metrics) | ||||
| 			return true, newFakeResponseWrapper(heapsterRawMemResponse), nil | ||||
| 		}) | ||||
| 	} else { | ||||
| 		fakeClient.AddProxyReactor("services", func(action core.Action) (handled bool, ret restclient.ResponseWrapper, err error) { | ||||
| 			metrics := heapster.MetricResultList{} | ||||
| 			var latestTimestamp time.Time | ||||
| 			for _, reportedMetricPoints := range tc.reportedMetricsPoints { | ||||
| 				var heapsterMetricPoints []heapster.MetricPoint | ||||
| 				for _, reportedMetricPoint := range reportedMetricPoints { | ||||
| 					timestamp := fixedTimestamp.Add(time.Duration(reportedMetricPoint.timestamp) * time.Minute) | ||||
| 					if latestTimestamp.Before(timestamp) { | ||||
| 						latestTimestamp = timestamp | ||||
| 					} | ||||
| 					heapsterMetricPoint := heapster.MetricPoint{Timestamp: timestamp, Value: reportedMetricPoint.level, FloatValue: nil} | ||||
| 					heapsterMetricPoints = append(heapsterMetricPoints, heapsterMetricPoint) | ||||
| 				} | ||||
| 				metric := heapster.MetricResult{ | ||||
| 					Metrics:         heapsterMetricPoints, | ||||
| 					LatestTimestamp: latestTimestamp, | ||||
| 				} | ||||
| 				metrics.Items = append(metrics.Items, metric) | ||||
| 			} | ||||
| 			heapsterRawMemResponse, _ := json.Marshal(&metrics) | ||||
| 			return true, newFakeResponseWrapper(heapsterRawMemResponse), nil | ||||
| 		}) | ||||
| 	} | ||||
|  | ||||
| 	return fakeClient | ||||
| } | ||||
|  | ||||
| func buildPod(namespace, podName string, podLabels map[string]string, phase v1.PodPhase, request string) v1.Pod { | ||||
| 	return v1.Pod{ | ||||
| 		ObjectMeta: v1.ObjectMeta{ | ||||
| 			Name:      podName, | ||||
| 			Namespace: namespace, | ||||
| 			Labels:    podLabels, | ||||
| 		}, | ||||
| 		Spec: v1.PodSpec{ | ||||
| 			Containers: []v1.Container{ | ||||
| 				{ | ||||
| 					Resources: v1.ResourceRequirements{ | ||||
| 						Requests: v1.ResourceList{ | ||||
| 							v1.ResourceCPU: resource.MustParse(request), | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		Status: v1.PodStatus{ | ||||
| 			Phase: phase, | ||||
| 			Conditions: []v1.PodCondition{ | ||||
| 				{ | ||||
| 					Type:   v1.PodReady, | ||||
| 					Status: v1.ConditionTrue, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (tc *testCase) verifyResults(t *testing.T, metrics interface{}, timestamp time.Time, err error) { | ||||
| 	if tc.desiredError != nil { | ||||
| 		assert.Error(t, err, "there should be an error retrieving the metrics") | ||||
| 		assert.Contains(t, fmt.Sprintf("%v", err), fmt.Sprintf("%v", tc.desiredError), "the error message should be eas expected") | ||||
| 		return | ||||
| 	} | ||||
| 	assert.NoError(t, err, "there should be no error retrieving the metrics") | ||||
| 	assert.NotNil(t, metrics, "there should be metrics returned") | ||||
|  | ||||
| 	if metricsInfo, wasRaw := metrics.(PodMetricsInfo); wasRaw { | ||||
| 		assert.Equal(t, tc.desiredMetricValues, metricsInfo, "the raw metrics values should be as expected") | ||||
| 	} else if resourceInfo, wasResource := metrics.(PodResourceInfo); wasResource { | ||||
| 		assert.Equal(t, tc.desiredResourceValues, resourceInfo, "the resource metrics values be been as expected") | ||||
| 	} else { | ||||
| 		assert.False(t, true, "should return either resource metrics info or raw metrics info") | ||||
| 	} | ||||
|  | ||||
| 	targetTimestamp := fixedTimestamp.Add(time.Duration(tc.targetTimestamp) * time.Minute) | ||||
| 	assert.True(t, targetTimestamp.Equal(timestamp), fmt.Sprintf("the timestamp should be as expected (%s) but was %s", targetTimestamp, timestamp)) | ||||
| } | ||||
|  | ||||
| func (tc *testCase) runTest(t *testing.T) { | ||||
| 	testClient := tc.prepareTestClient(t) | ||||
| 	metricsClient := NewHeapsterMetricsClient(testClient, DefaultHeapsterNamespace, DefaultHeapsterScheme, DefaultHeapsterService, DefaultHeapsterPort) | ||||
| 	isResource := len(tc.resourceName) > 0 | ||||
| 	if isResource { | ||||
| 		info, timestamp, err := metricsClient.GetResourceMetric(tc.resourceName, tc.namespace, tc.selector) | ||||
| 		tc.verifyResults(t, info, timestamp, err) | ||||
| 	} else { | ||||
| 		info, timestamp, err := metricsClient.GetRawMetric(tc.metricName, tc.namespace, tc.selector) | ||||
| 		tc.verifyResults(t, info, timestamp, err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestCPU(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas: 3, | ||||
| 		desiredResourceValues: PodResourceInfo{ | ||||
| 			"test-pod-0": 5000, "test-pod-1": 5000, "test-pod-2": 5000, | ||||
| 		}, | ||||
| 		resourceName:       v1.ResourceCPU, | ||||
| 		targetTimestamp:    1, | ||||
| 		reportedPodMetrics: [][]int64{{5000}, {5000}, {5000}}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func TestQPS(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas: 3, | ||||
| 		desiredMetricValues: PodMetricsInfo{ | ||||
| 			"test-pod-0": 10, "test-pod-1": 20, "test-pod-2": 10, | ||||
| 		}, | ||||
| 		metricName:            "qps", | ||||
| 		targetTimestamp:       1, | ||||
| 		reportedMetricsPoints: [][]metricPoint{{{10, 1}}, {{20, 1}}, {{10, 1}}}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func TestQpsSumEqualZero(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas: 3, | ||||
| 		desiredMetricValues: PodMetricsInfo{ | ||||
| 			"test-pod-0": 0, "test-pod-1": 0, "test-pod-2": 0, | ||||
| 		}, | ||||
| 		metricName:            "qps", | ||||
| 		targetTimestamp:       0, | ||||
| 		reportedMetricsPoints: [][]metricPoint{{{0, 0}}, {{0, 0}}, {{0, 0}}}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func TestCPUMoreMetrics(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas: 5, | ||||
| 		desiredResourceValues: PodResourceInfo{ | ||||
| 			"test-pod-0": 5000, "test-pod-1": 5000, "test-pod-2": 5000, | ||||
| 			"test-pod-3": 5000, "test-pod-4": 5000, | ||||
| 		}, | ||||
| 		resourceName:       v1.ResourceCPU, | ||||
| 		targetTimestamp:    10, | ||||
| 		reportedPodMetrics: [][]int64{{1000, 2000, 2000}, {5000}, {1000, 1000, 1000, 2000}, {4000, 1000}, {5000}}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func TestCPUMissingMetrics(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas: 3, | ||||
| 		desiredResourceValues: PodResourceInfo{ | ||||
| 			"test-pod-0": 4000, | ||||
| 		}, | ||||
| 		resourceName:       v1.ResourceCPU, | ||||
| 		reportedPodMetrics: [][]int64{{4000}}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func TestQpsMissingMetrics(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas:              3, | ||||
| 		desiredError:          fmt.Errorf("requested metrics for 3 pods, got metrics for 1"), | ||||
| 		metricName:            "qps", | ||||
| 		targetTimestamp:       1, | ||||
| 		reportedMetricsPoints: [][]metricPoint{{{4000, 4}}}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func TestQpsSuperfluousMetrics(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas:              3, | ||||
| 		desiredError:          fmt.Errorf("requested metrics for 3 pods, got metrics for 6"), | ||||
| 		metricName:            "qps", | ||||
| 		reportedMetricsPoints: [][]metricPoint{{{1000, 1}}, {{2000, 4}}, {{2000, 1}}, {{4000, 5}}, {{2000, 1}}, {{4000, 4}}}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func TestCPUEmptyMetrics(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas:              3, | ||||
| 		resourceName:          v1.ResourceCPU, | ||||
| 		desiredError:          fmt.Errorf("no metrics returned from heapster"), | ||||
| 		reportedMetricsPoints: [][]metricPoint{}, | ||||
| 		reportedPodMetrics:    [][]int64{}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func TestQpsEmptyEntries(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas:   3, | ||||
| 		metricName: "qps", | ||||
| 		desiredMetricValues: PodMetricsInfo{ | ||||
| 			"test-pod-0": 4000, "test-pod-2": 2000, | ||||
| 		}, | ||||
| 		targetTimestamp:       4, | ||||
| 		reportedMetricsPoints: [][]metricPoint{{{4000, 4}}, {}, {{2000, 4}}}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func TestCPUZeroReplicas(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas:           0, | ||||
| 		resourceName:       v1.ResourceCPU, | ||||
| 		desiredError:       fmt.Errorf("no metrics returned from heapster"), | ||||
| 		reportedPodMetrics: [][]int64{}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func TestCPUEmptyMetricsForOnePod(t *testing.T) { | ||||
| 	tc := testCase{ | ||||
| 		replicas:     3, | ||||
| 		resourceName: v1.ResourceCPU, | ||||
| 		desiredResourceValues: PodResourceInfo{ | ||||
| 			"test-pod-0": 100, "test-pod-1": 700, | ||||
| 		}, | ||||
| 		reportedPodMetrics: [][]int64{{100}, {300, 400}, {}}, | ||||
| 	} | ||||
| 	tc.runTest(t) | ||||
| } | ||||
|  | ||||
| func testCollapseTimeSamples(t *testing.T) { | ||||
| 	now := time.Now() | ||||
| 	metrics := heapster.MetricResult{ | ||||
| 		Metrics: []heapster.MetricPoint{ | ||||
| 			{Timestamp: now, Value: 50, FloatValue: nil}, | ||||
| 			{Timestamp: now.Add(-15 * time.Second), Value: 100, FloatValue: nil}, | ||||
| 			{Timestamp: now.Add(-60 * time.Second), Value: 100000, FloatValue: nil}}, | ||||
| 		LatestTimestamp: now, | ||||
| 	} | ||||
|  | ||||
| 	val, timestamp, hadMetrics := collapseTimeSamples(metrics, time.Minute) | ||||
| 	assert.True(t, hadMetrics, "should report that it received a populated list of metrics") | ||||
| 	assert.InEpsilon(t, float64(75), val, 0.1, "collapsed sample value should be as expected") | ||||
| 	assert.True(t, timestamp.Equal(now), "timestamp should be the current time (the newest)") | ||||
| } | ||||
| @@ -134,7 +134,7 @@ func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *v1.PersistentVol | ||||
| 			// with existing PVs, findByClaim must find only PVs that are | ||||
| 			// pre-bound to the claim (by dynamic provisioning). TODO: remove in | ||||
| 			// 1.5 | ||||
| 			if v1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) { | ||||
| 			if metav1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) { | ||||
| 				continue | ||||
| 			} | ||||
|  | ||||
|   | ||||
| @@ -218,7 +218,7 @@ type PersistentVolumeController struct { | ||||
| func (ctrl *PersistentVolumeController) syncClaim(claim *v1.PersistentVolumeClaim) error { | ||||
| 	glog.V(4).Infof("synchronizing PersistentVolumeClaim[%s]: %s", claimToClaimKey(claim), getClaimStatusForLogging(claim)) | ||||
|  | ||||
| 	if !v1.HasAnnotation(claim.ObjectMeta, annBindCompleted) { | ||||
| 	if !metav1.HasAnnotation(claim.ObjectMeta, annBindCompleted) { | ||||
| 		return ctrl.syncUnboundClaim(claim) | ||||
| 	} else { | ||||
| 		return ctrl.syncBoundClaim(claim) | ||||
| @@ -243,7 +243,7 @@ func (ctrl *PersistentVolumeController) syncUnboundClaim(claim *v1.PersistentVol | ||||
| 			glog.V(4).Infof("synchronizing unbound PersistentVolumeClaim[%s]: no volume found", claimToClaimKey(claim)) | ||||
| 			// No PV could be found | ||||
| 			// OBSERVATION: pvc is "Pending", will retry | ||||
| 			if storageutil.GetClaimStorageClass(claim) != "" || v1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) { | ||||
| 			if storageutil.GetClaimStorageClass(claim) != "" || metav1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) { | ||||
| 				if err = ctrl.provisionClaim(claim); err != nil { | ||||
| 					return err | ||||
| 				} | ||||
| @@ -315,7 +315,7 @@ func (ctrl *PersistentVolumeController) syncUnboundClaim(claim *v1.PersistentVol | ||||
| 			} else { | ||||
| 				// User asked for a PV that is claimed by someone else | ||||
| 				// OBSERVATION: pvc is "Pending", pv is "Bound" | ||||
| 				if !v1.HasAnnotation(claim.ObjectMeta, annBoundByController) { | ||||
| 				if !metav1.HasAnnotation(claim.ObjectMeta, annBoundByController) { | ||||
| 					glog.V(4).Infof("synchronizing unbound PersistentVolumeClaim[%s]: volume already bound to different claim by user, will retry later", claimToClaimKey(claim)) | ||||
| 					// User asked for a specific PV, retry later | ||||
| 					if _, err = ctrl.updateClaimStatus(claim, v1.ClaimPending, nil); err != nil { | ||||
| @@ -480,7 +480,7 @@ func (ctrl *PersistentVolumeController) syncVolume(volume *v1.PersistentVolume) | ||||
| 			} | ||||
| 			return nil | ||||
| 		} else if claim.Spec.VolumeName == "" { | ||||
| 			if v1.HasAnnotation(volume.ObjectMeta, annBoundByController) { | ||||
| 			if metav1.HasAnnotation(volume.ObjectMeta, annBoundByController) { | ||||
| 				// The binding is not completed; let PVC sync handle it | ||||
| 				glog.V(4).Infof("synchronizing PersistentVolume[%s]: volume not bound yet, waiting for syncClaim to fix it", volume.Name) | ||||
| 			} else { | ||||
| @@ -507,7 +507,7 @@ func (ctrl *PersistentVolumeController) syncVolume(volume *v1.PersistentVolume) | ||||
| 			return nil | ||||
| 		} else { | ||||
| 			// Volume is bound to a claim, but the claim is bound elsewhere | ||||
| 			if v1.HasAnnotation(volume.ObjectMeta, annDynamicallyProvisioned) && volume.Spec.PersistentVolumeReclaimPolicy == v1.PersistentVolumeReclaimDelete { | ||||
| 			if metav1.HasAnnotation(volume.ObjectMeta, annDynamicallyProvisioned) && volume.Spec.PersistentVolumeReclaimPolicy == v1.PersistentVolumeReclaimDelete { | ||||
| 				// This volume was dynamically provisioned for this claim. The | ||||
| 				// claim got bound elsewhere, and thus this volume is not | ||||
| 				// needed. Delete it. | ||||
| @@ -531,7 +531,7 @@ func (ctrl *PersistentVolumeController) syncVolume(volume *v1.PersistentVolume) | ||||
| 			} else { | ||||
| 				// Volume is bound to a claim, but the claim is bound elsewhere | ||||
| 				// and it's not dynamically provisioned. | ||||
| 				if v1.HasAnnotation(volume.ObjectMeta, annBoundByController) { | ||||
| 				if metav1.HasAnnotation(volume.ObjectMeta, annBoundByController) { | ||||
| 					// This is part of the normal operation of the controller; the | ||||
| 					// controller tried to use this volume for a claim but the claim | ||||
| 					// was fulfilled by another volume. We did this; fix it. | ||||
| @@ -755,8 +755,8 @@ func (ctrl *PersistentVolumeController) bindVolumeToClaim(volume *v1.PersistentV | ||||
| 	} | ||||
|  | ||||
| 	// Set annBoundByController if it is not set yet | ||||
| 	if shouldSetBoundByController && !v1.HasAnnotation(volumeClone.ObjectMeta, annBoundByController) { | ||||
| 		v1.SetMetaDataAnnotation(&volumeClone.ObjectMeta, annBoundByController, "yes") | ||||
| 	if shouldSetBoundByController && !metav1.HasAnnotation(volumeClone.ObjectMeta, annBoundByController) { | ||||
| 		metav1.SetMetaDataAnnotation(&volumeClone.ObjectMeta, annBoundByController, "yes") | ||||
| 		dirty = true | ||||
| 	} | ||||
|  | ||||
| @@ -812,14 +812,14 @@ func (ctrl *PersistentVolumeController) bindClaimToVolume(claim *v1.PersistentVo | ||||
| 	} | ||||
|  | ||||
| 	// Set annBoundByController if it is not set yet | ||||
| 	if shouldSetBoundByController && !v1.HasAnnotation(claimClone.ObjectMeta, annBoundByController) { | ||||
| 		v1.SetMetaDataAnnotation(&claimClone.ObjectMeta, annBoundByController, "yes") | ||||
| 	if shouldSetBoundByController && !metav1.HasAnnotation(claimClone.ObjectMeta, annBoundByController) { | ||||
| 		metav1.SetMetaDataAnnotation(&claimClone.ObjectMeta, annBoundByController, "yes") | ||||
| 		dirty = true | ||||
| 	} | ||||
|  | ||||
| 	// Set annBindCompleted if it is not set yet | ||||
| 	if !v1.HasAnnotation(claimClone.ObjectMeta, annBindCompleted) { | ||||
| 		v1.SetMetaDataAnnotation(&claimClone.ObjectMeta, annBindCompleted, "yes") | ||||
| 	if !metav1.HasAnnotation(claimClone.ObjectMeta, annBindCompleted) { | ||||
| 		metav1.SetMetaDataAnnotation(&claimClone.ObjectMeta, annBindCompleted, "yes") | ||||
| 		dirty = true | ||||
| 	} | ||||
|  | ||||
| @@ -905,7 +905,7 @@ func (ctrl *PersistentVolumeController) unbindVolume(volume *v1.PersistentVolume | ||||
| 		return fmt.Errorf("Unexpected volume cast error : %v", volumeClone) | ||||
| 	} | ||||
|  | ||||
| 	if v1.HasAnnotation(volume.ObjectMeta, annBoundByController) { | ||||
| 	if metav1.HasAnnotation(volume.ObjectMeta, annBoundByController) { | ||||
| 		// The volume was bound by the controller. | ||||
| 		volumeClone.Spec.ClaimRef = nil | ||||
| 		delete(volumeClone.Annotations, annBoundByController) | ||||
| @@ -1335,13 +1335,13 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa | ||||
| 	volume.Status.Phase = v1.VolumeBound | ||||
|  | ||||
| 	// Add annBoundByController (used in deleting the volume) | ||||
| 	v1.SetMetaDataAnnotation(&volume.ObjectMeta, annBoundByController, "yes") | ||||
| 	v1.SetMetaDataAnnotation(&volume.ObjectMeta, annDynamicallyProvisioned, plugin.GetPluginName()) | ||||
| 	metav1.SetMetaDataAnnotation(&volume.ObjectMeta, annBoundByController, "yes") | ||||
| 	metav1.SetMetaDataAnnotation(&volume.ObjectMeta, annDynamicallyProvisioned, plugin.GetPluginName()) | ||||
| 	// For Alpha provisioning behavior, do not add storage.BetaStorageClassAnnotations for volumes created | ||||
| 	// by storage.AlphaStorageClassAnnotation | ||||
| 	// TODO: remove this check in 1.5, storage.StorageClassAnnotation will be always non-empty there. | ||||
| 	if claimClass != "" { | ||||
| 		v1.SetMetaDataAnnotation(&volume.ObjectMeta, storageutil.StorageClassAnnotation, claimClass) | ||||
| 		metav1.SetMetaDataAnnotation(&volume.ObjectMeta, storageutil.StorageClassAnnotation, claimClass) | ||||
| 	} | ||||
|  | ||||
| 	// Try to create the PV object several times | ||||
| @@ -1445,8 +1445,8 @@ func (ctrl *PersistentVolumeController) newRecyclerEventRecorder(volume *v1.Pers | ||||
| // provisioner is requested. | ||||
| func (ctrl *PersistentVolumeController) findProvisionablePlugin(claim *v1.PersistentVolumeClaim) (vol.ProvisionableVolumePlugin, *storage.StorageClass, error) { | ||||
| 	// TODO: remove this alpha behavior in 1.5 | ||||
| 	alpha := v1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) | ||||
| 	beta := v1.HasAnnotation(claim.ObjectMeta, storageutil.BetaStorageClassAnnotation) | ||||
| 	alpha := metav1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) | ||||
| 	beta := metav1.HasAnnotation(claim.ObjectMeta, storageutil.BetaStorageClassAnnotation) | ||||
| 	if alpha && beta { | ||||
| 		// Both Alpha and Beta annotations are set. Do beta. | ||||
| 		alpha = false | ||||
| @@ -1512,7 +1512,7 @@ func (ctrl *PersistentVolumeController) findAlphaProvisionablePlugin() (vol.Prov | ||||
| func (ctrl *PersistentVolumeController) findDeletablePlugin(volume *v1.PersistentVolume) (vol.DeletableVolumePlugin, error) { | ||||
| 	// Find a plugin. Try to find the same plugin that provisioned the volume | ||||
| 	var plugin vol.DeletableVolumePlugin | ||||
| 	if v1.HasAnnotation(volume.ObjectMeta, annDynamicallyProvisioned) { | ||||
| 	if metav1.HasAnnotation(volume.ObjectMeta, annDynamicallyProvisioned) { | ||||
| 		provisionPluginName := volume.Annotations[annDynamicallyProvisioned] | ||||
| 		if provisionPluginName != "" { | ||||
| 			plugin, err := ctrl.volumePluginMgr.FindDeletablePluginByName(provisionPluginName) | ||||
|   | ||||
| @@ -510,7 +510,7 @@ func (ctrl *PersistentVolumeController) setClaimProvisioner(claim *v1.Persistent | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("Unexpected claim cast error : %v", claimClone) | ||||
| 	} | ||||
| 	v1.SetMetaDataAnnotation(&claimClone.ObjectMeta, annStorageProvisioner, class.Provisioner) | ||||
| 	metav1.SetMetaDataAnnotation(&claimClone.ObjectMeta, annStorageProvisioner, class.Provisioner) | ||||
| 	newClaim, err := ctrl.kubeClient.Core().PersistentVolumeClaims(claim.Namespace).Update(claimClone) | ||||
| 	if err != nil { | ||||
| 		return newClaim, err | ||||
| @@ -525,14 +525,14 @@ func (ctrl *PersistentVolumeController) setClaimProvisioner(claim *v1.Persistent | ||||
| // Stateless functions | ||||
|  | ||||
| func getClaimStatusForLogging(claim *v1.PersistentVolumeClaim) string { | ||||
| 	bound := v1.HasAnnotation(claim.ObjectMeta, annBindCompleted) | ||||
| 	boundByController := v1.HasAnnotation(claim.ObjectMeta, annBoundByController) | ||||
| 	bound := metav1.HasAnnotation(claim.ObjectMeta, annBindCompleted) | ||||
| 	boundByController := metav1.HasAnnotation(claim.ObjectMeta, annBoundByController) | ||||
|  | ||||
| 	return fmt.Sprintf("phase: %s, bound to: %q, bindCompleted: %v, boundByController: %v", claim.Status.Phase, claim.Spec.VolumeName, bound, boundByController) | ||||
| } | ||||
|  | ||||
| func getVolumeStatusForLogging(volume *v1.PersistentVolume) string { | ||||
| 	boundByController := v1.HasAnnotation(volume.ObjectMeta, annBoundByController) | ||||
| 	boundByController := metav1.HasAnnotation(volume.ObjectMeta, annBoundByController) | ||||
| 	claimName := "" | ||||
| 	if volume.Spec.ClaimRef != nil { | ||||
| 		claimName = fmt.Sprintf("%s/%s (uid: %s)", volume.Spec.ClaimRef.Namespace, volume.Spec.ClaimRef.Name, volume.Spec.ClaimRef.UID) | ||||
|   | ||||
| @@ -18,6 +18,7 @@ package rest | ||||
|  | ||||
| import ( | ||||
| 	"k8s.io/apimachinery/pkg/api/errors" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||
| 	"k8s.io/apimachinery/pkg/util/validation/field" | ||||
|   | ||||
| @@ -19,12 +19,11 @@ package rest | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	genericapirequest "k8s.io/apiserver/pkg/request" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/util/uuid" | ||||
| ) | ||||
|  | ||||
| // FillObjectMetaSystemFields populates fields that are managed by the system on ObjectMeta. | ||||
| func FillObjectMetaSystemFields(ctx genericapirequest.Context, meta *api.ObjectMeta) { | ||||
| func FillObjectMetaSystemFields(ctx genericapirequest.Context, meta *metav1.ObjectMeta) { | ||||
| 	meta.CreationTimestamp = metav1.Now() | ||||
| 	// allows admission controllers to assign a UID earlier in the request processing | ||||
| 	// to support tracking resources pending creation. | ||||
| @@ -38,7 +37,7 @@ func FillObjectMetaSystemFields(ctx genericapirequest.Context, meta *api.ObjectM | ||||
|  | ||||
| // ValidNamespace returns false if the namespace on the context differs from the resource.  If the resource has no namespace, it is set to the value in the context. | ||||
| // TODO(sttts): move into pkg/genericapiserver/api | ||||
| func ValidNamespace(ctx genericapirequest.Context, resource *api.ObjectMeta) bool { | ||||
| func ValidNamespace(ctx genericapirequest.Context, resource *metav1.ObjectMeta) bool { | ||||
| 	ns, ok := genericapirequest.NamespaceFrom(ctx) | ||||
| 	if len(resource.Namespace) == 0 { | ||||
| 		resource.Namespace = ns | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import ( | ||||
|  | ||||
| 	"k8s.io/apimachinery/pkg/api/errors" | ||||
| 	"k8s.io/apimachinery/pkg/api/meta" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/apimachinery/pkg/util/validation/field" | ||||
| 	genericapirequest "k8s.io/apiserver/pkg/request" | ||||
|   | ||||
| @@ -24,7 +24,7 @@ import ( | ||||
|  | ||||
| type Simple struct { | ||||
| 	metav1.TypeMeta  `json:",inline"` | ||||
| 	apiv1.ObjectMeta `json:"metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata"` | ||||
| 	// +optional | ||||
| 	Other string `json:"other,omitempty"` | ||||
| 	// +optional | ||||
| @@ -35,7 +35,7 @@ func (obj *Simple) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } | ||||
|  | ||||
| type SimpleRoot struct { | ||||
| 	metav1.TypeMeta  `json:",inline"` | ||||
| 	apiv1.ObjectMeta `json:"metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata"` | ||||
| 	// +optional | ||||
| 	Other string `json:"other,omitempty"` | ||||
| 	// +optional | ||||
|   | ||||
| @@ -294,7 +294,7 @@ func validateAnnotations(removeAnnotations []string, newAnnotations map[string]s | ||||
| } | ||||
|  | ||||
| // validateNoAnnotationOverwrites validates that when overwrite is false, to-be-updated annotations don't exist in the object annotation map (yet) | ||||
| func validateNoAnnotationOverwrites(accessor meta.Object, annotations map[string]string) error { | ||||
| func validateNoAnnotationOverwrites(accessor metav1.Object, annotations map[string]string) error { | ||||
| 	var buf bytes.Buffer | ||||
| 	for key := range annotations { | ||||
| 		// change-cause annotation can always be overwritten | ||||
|   | ||||
| @@ -276,7 +276,7 @@ func (o *LabelOptions) RunLabel(f cmdutil.Factory, cmd *cobra.Command) error { | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func validateNoOverwrites(accessor meta.Object, labels map[string]string) error { | ||||
| func validateNoOverwrites(accessor metav1.Object, labels map[string]string) error { | ||||
| 	allErrs := []error{} | ||||
| 	for key := range labels { | ||||
| 		if value, found := accessor.GetLabels()[key]; found { | ||||
|   | ||||
| @@ -131,7 +131,7 @@ func deleteTaint(taints []api.Taint, taintToDelete api.Taint) ([]api.Taint, erro | ||||
|  | ||||
| // reorganizeTaints returns the updated set of taints, taking into account old taints that were not updated, | ||||
| // old taints that were updated, old taints that were deleted, and new taints. | ||||
| func reorganizeTaints(accessor meta.Object, overwrite bool, taintsToAdd []api.Taint, taintsToRemove []api.Taint) ([]api.Taint, error) { | ||||
| func reorganizeTaints(accessor metav1.Object, overwrite bool, taintsToAdd []api.Taint, taintsToRemove []api.Taint) ([]api.Taint, error) { | ||||
| 	newTaints := append([]api.Taint{}, taintsToAdd...) | ||||
|  | ||||
| 	var oldTaints []api.Taint | ||||
| @@ -362,7 +362,7 @@ func (o TaintOptions) RunTaint() error { | ||||
| } | ||||
|  | ||||
| // validateNoTaintOverwrites validates that when overwrite is false, to-be-updated taints don't exist in the node taint list (yet) | ||||
| func validateNoTaintOverwrites(accessor meta.Object, taints []api.Taint) error { | ||||
| func validateNoTaintOverwrites(accessor metav1.Object, taints []api.Taint) error { | ||||
| 	annotations := accessor.GetAnnotations() | ||||
| 	if annotations == nil { | ||||
| 		return nil | ||||
|   | ||||
| @@ -22,7 +22,6 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"k8s.io/apimachinery/pkg/api/errors" | ||||
| 	"k8s.io/apimachinery/pkg/api/meta" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/labels" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||
| @@ -138,7 +137,7 @@ type StatefulSetReaper struct { | ||||
|  | ||||
| type objInterface interface { | ||||
| 	Delete(name string) error | ||||
| 	Get(name string) (meta.Object, error) | ||||
| 	Get(name string) (metav1.Object, error) | ||||
| } | ||||
|  | ||||
| // getOverlappingControllers finds rcs that this controller overlaps, as well as rcs overlapping this controller. | ||||
|   | ||||
| @@ -25,7 +25,7 @@ import ( | ||||
| type TestStruct struct { | ||||
| 	metav1.TypeMeta `json:",inline"` | ||||
| 	// +optional | ||||
| 	apiv1.ObjectMeta `json:"metadata,omitempty"` | ||||
| 	metav1.ObjectMeta `json:"metadata,omitempty"` | ||||
| 	Key              string         `json:"Key"` | ||||
| 	Map              map[string]int `json:"Map"` | ||||
| 	StringList       []string       `json:"StringList"` | ||||
|   | ||||
| @@ -479,13 +479,7 @@ func encodeToJSON(obj *extensions.ThirdPartyResourceData, stream io.Writer) erro | ||||
| 		return fmt.Errorf("unexpected type: %v", objOut) | ||||
| 	} | ||||
|  | ||||
| 	// Convert to a serializable type | ||||
| 	versionedObjectMeta := &v1.ObjectMeta{} | ||||
| 	if err := v1.Convert_api_ObjectMeta_To_v1_ObjectMeta(&obj.ObjectMeta, versionedObjectMeta, nil); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	objMap["metadata"] = versionedObjectMeta | ||||
| 	objMap["metadata"] = &obj.ObjectMeta | ||||
| 	encoder := json.NewEncoder(stream) | ||||
| 	return encoder.Encode(objMap) | ||||
| } | ||||
|   | ||||
| @@ -481,7 +481,7 @@ var ( | ||||
| // When deciding whether to add the OrphanDependent finalizer, factors in the | ||||
| // order of highest to lowest priority are: options.OrphanDependents, existing | ||||
| // finalizers of the object, e.DeleteStrategy.DefaultGarbageCollectionPolicy. | ||||
| func shouldUpdateFinalizers(e *Store, accessor meta.Object, options *api.DeleteOptions) (shouldUpdate bool, newFinalizers []string) { | ||||
| func shouldUpdateFinalizers(e *Store, accessor metav1.Object, options *api.DeleteOptions) (shouldUpdate bool, newFinalizers []string) { | ||||
| 	shouldOrphan := false | ||||
| 	// Get default orphan policy from this REST object type | ||||
| 	if gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy); ok { | ||||
| @@ -890,7 +890,7 @@ func (e *Store) calculateTTL(obj runtime.Object, defaultTTL int64, update bool) | ||||
| 	return ttl, err | ||||
| } | ||||
|  | ||||
| func exportObjectMeta(accessor meta.Object, exact bool) { | ||||
| func exportObjectMeta(accessor metav1.Object, exact bool) { | ||||
| 	accessor.SetUID("") | ||||
| 	if !exact { | ||||
| 		accessor.SetNamespace("") | ||||
|   | ||||
| @@ -25,7 +25,7 @@ import ( | ||||
|  | ||||
| 	"k8s.io/apimachinery/pkg/util/diff" | ||||
| 	"k8s.io/apiserver/pkg/authentication/user" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/kubernetes/pkg/apis/rbac" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -45,7 +45,7 @@ func (a APIObjectVersioner) UpdateObject(obj runtime.Object, resourceVersion uin | ||||
|  | ||||
| // UpdateList implements Versioner | ||||
| func (a APIObjectVersioner) UpdateList(obj runtime.Object, resourceVersion uint64) error { | ||||
| 	listMeta, err := api.ListMetaFor(obj) | ||||
| 	listMeta, err := metav1.ListMetaFor(obj) | ||||
| 	if err != nil || listMeta == nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -24,7 +24,7 @@ import ( | ||||
|  | ||||
| type TestResource struct { | ||||
| 	metav1.TypeMeta  `json:",inline"` | ||||
| 	apiv1.ObjectMeta `json:"metadata"` | ||||
| 	metav1.ObjectMeta `json:"metadata"` | ||||
| 	Value            int `json:"value"` | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import ( | ||||
| 	"sync" | ||||
|  | ||||
| 	"github.com/golang/glog" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/types" | ||||
| 	utilerrors "k8s.io/apimachinery/pkg/util/errors" | ||||
| 	"k8s.io/apimachinery/pkg/util/validation" | ||||
|   | ||||
| @@ -36,7 +36,6 @@ import ( | ||||
| 	apierrors "k8s.io/client-go/pkg/api/errors" | ||||
| 	"k8s.io/client-go/pkg/apis/imagepolicy/v1alpha1" | ||||
| 	"k8s.io/client-go/rest" | ||||
|  | ||||
| 	"k8s.io/kubernetes/pkg/admission" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
|  | ||||
|   | ||||
| @@ -172,7 +172,7 @@ func TestAdmitSeccomp(t *testing.T) { | ||||
| 		psp := restrictivePSP() | ||||
| 		psp.Annotations = v.pspAnnotations | ||||
| 		pod := &kapi.Pod{ | ||||
| 			ObjectMeta: kapi.ObjectMeta{ | ||||
| 			ObjectMeta: metav1.ObjectMeta{ | ||||
| 				Annotations: v.podAnnotations, | ||||
| 			}, | ||||
| 			Spec: kapi.PodSpec{ | ||||
| @@ -1457,7 +1457,7 @@ func TestCreateProvidersFromConstraints(t *testing.T) { | ||||
| 		"valid psp": { | ||||
| 			psp: func() *extensions.PodSecurityPolicy { | ||||
| 				return &extensions.PodSecurityPolicy{ | ||||
| 					ObjectMeta: kapi.ObjectMeta{ | ||||
| 					ObjectMeta: metav1.ObjectMeta{ | ||||
| 						Name: "valid psp", | ||||
| 					}, | ||||
| 					Spec: extensions.PodSecurityPolicySpec{ | ||||
| @@ -1480,7 +1480,7 @@ func TestCreateProvidersFromConstraints(t *testing.T) { | ||||
| 		"bad psp strategy options": { | ||||
| 			psp: func() *extensions.PodSecurityPolicy { | ||||
| 				return &extensions.PodSecurityPolicy{ | ||||
| 					ObjectMeta: kapi.ObjectMeta{ | ||||
| 					ObjectMeta: metav1.ObjectMeta{ | ||||
| 						Name: "bad psp user options", | ||||
| 					}, | ||||
| 					Spec: extensions.PodSecurityPolicySpec{ | ||||
| @@ -1650,7 +1650,7 @@ func TestGetMatchingPolicies(t *testing.T) { | ||||
|  | ||||
| func restrictivePSP() *extensions.PodSecurityPolicy { | ||||
| 	return &extensions.PodSecurityPolicy{ | ||||
| 		ObjectMeta: kapi.ObjectMeta{ | ||||
| 		ObjectMeta: metav1.ObjectMeta{ | ||||
| 			Name:        "restrictive", | ||||
| 			Annotations: map[string]string{}, | ||||
| 		}, | ||||
| @@ -1685,7 +1685,7 @@ func restrictivePSP() *extensions.PodSecurityPolicy { | ||||
|  | ||||
| func createNamespaceForTest() *kapi.Namespace { | ||||
| 	return &kapi.Namespace{ | ||||
| 		ObjectMeta: kapi.ObjectMeta{ | ||||
| 		ObjectMeta: metav1.ObjectMeta{ | ||||
| 			Name: "default", | ||||
| 		}, | ||||
| 	} | ||||
| @@ -1693,7 +1693,7 @@ func createNamespaceForTest() *kapi.Namespace { | ||||
|  | ||||
| func createSAForTest() *kapi.ServiceAccount { | ||||
| 	return &kapi.ServiceAccount{ | ||||
| 		ObjectMeta: kapi.ObjectMeta{ | ||||
| 		ObjectMeta: metav1.ObjectMeta{ | ||||
| 			Namespace: "default", | ||||
| 			Name:      "default", | ||||
| 		}, | ||||
| @@ -1705,7 +1705,7 @@ func createSAForTest() *kapi.ServiceAccount { | ||||
| // psp when defaults are filled in. | ||||
| func goodPod() *kapi.Pod { | ||||
| 	return &kapi.Pod{ | ||||
| 		ObjectMeta: kapi.ObjectMeta{ | ||||
| 		ObjectMeta: metav1.ObjectMeta{ | ||||
| 			Annotations: map[string]string{}, | ||||
| 		}, | ||||
| 		Spec: kapi.PodSpec{ | ||||
|   | ||||
| @@ -21,7 +21,7 @@ import ( | ||||
|  | ||||
| 	"github.com/golang/glog" | ||||
|  | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	rbac "k8s.io/kubernetes/pkg/apis/rbac" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -18,7 +18,7 @@ package bootstrappolicy | ||||
|  | ||||
| import ( | ||||
| 	"k8s.io/apiserver/pkg/authentication/user" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	rbac "k8s.io/kubernetes/pkg/apis/rbac" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package meta | ||||
|  | ||||
| import ( | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||
| 	"k8s.io/apimachinery/pkg/types" | ||||
| @@ -30,46 +29,6 @@ type VersionInterfaces struct { | ||||
| 	MetadataAccessor | ||||
| } | ||||
|  | ||||
| type ObjectMetaAccessor interface { | ||||
| 	GetObjectMeta() Object | ||||
| } | ||||
|  | ||||
| // Object lets you work with object 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 (Name, UID, Namespace on lists) will be a no-op and return | ||||
| // a default value. | ||||
| type Object interface { | ||||
| 	GetNamespace() string | ||||
| 	SetNamespace(namespace string) | ||||
| 	GetName() string | ||||
| 	SetName(name string) | ||||
| 	GetGenerateName() string | ||||
| 	SetGenerateName(name string) | ||||
| 	GetUID() types.UID | ||||
| 	SetUID(uid types.UID) | ||||
| 	GetResourceVersion() string | ||||
| 	SetResourceVersion(version string) | ||||
| 	GetSelfLink() string | ||||
| 	SetSelfLink(selfLink string) | ||||
| 	GetCreationTimestamp() metav1.Time | ||||
| 	SetCreationTimestamp(timestamp metav1.Time) | ||||
| 	GetDeletionTimestamp() *metav1.Time | ||||
| 	SetDeletionTimestamp(timestamp *metav1.Time) | ||||
| 	GetLabels() map[string]string | ||||
| 	SetLabels(labels map[string]string) | ||||
| 	GetAnnotations() map[string]string | ||||
| 	SetAnnotations(annotations map[string]string) | ||||
| 	GetFinalizers() []string | ||||
| 	SetFinalizers(finalizers []string) | ||||
| 	GetOwnerReferences() []metav1.OwnerReference | ||||
| 	SetOwnerReferences([]metav1.OwnerReference) | ||||
| 	GetClusterName() string | ||||
| 	SetClusterName(clusterName string) | ||||
| } | ||||
|  | ||||
| // TODO: move me to pkg/apis/meta/v1/unstructured once Object is moved to pkg/apis/meta/v1 | ||||
| var _ Object = &unstructured.Unstructured{} | ||||
|  | ||||
| type ListMetaAccessor interface { | ||||
| 	GetListMeta() List | ||||
| } | ||||
|   | ||||
| @@ -20,13 +20,13 @@ import ( | ||||
| 	"fmt" | ||||
| 	"reflect" | ||||
|  | ||||
| 	"github.com/golang/glog" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/conversion" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||
| 	"k8s.io/apimachinery/pkg/types" | ||||
|  | ||||
| 	"github.com/golang/glog" | ||||
| ) | ||||
|  | ||||
| // errNotList is returned when an object implements the Object style interfaces but not the List style | ||||
| @@ -54,9 +54,9 @@ func ListAccessor(obj interface{}) (List, error) { | ||||
| 			return m, nil | ||||
| 		} | ||||
| 		return nil, errNotList | ||||
| 	case Object: | ||||
| 	case metav1.Object: | ||||
| 		return t, nil | ||||
| 	case ObjectMetaAccessor: | ||||
| 	case metav1.ObjectMetaAccessor: | ||||
| 		if m := t.GetObjectMeta(); m != nil { | ||||
| 			return m, nil | ||||
| 		} | ||||
| @@ -75,11 +75,11 @@ var errNotObject = fmt.Errorf("object does not implement the Object interfaces") | ||||
| // required fields are missing. Fields that are not required return the default | ||||
| // value and are a no-op if set. | ||||
| // TODO: return bool instead of error | ||||
| func Accessor(obj interface{}) (Object, error) { | ||||
| func Accessor(obj interface{}) (metav1.Object, error) { | ||||
| 	switch t := obj.(type) { | ||||
| 	case Object: | ||||
| 	case metav1.Object: | ||||
| 		return t, nil | ||||
| 	case ObjectMetaAccessor: | ||||
| 	case metav1.ObjectMetaAccessor: | ||||
| 		if m := t.GetObjectMeta(); m != nil { | ||||
| 			return m, nil | ||||
| 		} | ||||
|   | ||||
| @@ -181,3 +181,17 @@ func ExtractGroupVersions(l *APIGroupList) []string { | ||||
| 	} | ||||
| 	return groupVersions | ||||
| } | ||||
|  | ||||
| // HasAnnotation returns a bool if passed in annotation exists | ||||
| func HasAnnotation(obj ObjectMeta, ann string) bool { | ||||
| 	_, found := obj.Annotations[ann] | ||||
| 	return found | ||||
| } | ||||
|  | ||||
| // SetMetaDataAnnotation sets the annotation and value | ||||
| func SetMetaDataAnnotation(obj *ObjectMeta, ann string, value string) { | ||||
| 	if obj.Annotations == nil { | ||||
| 		obj.Annotations = make(map[string]string) | ||||
| 	} | ||||
| 	obj.Annotations[ann] = value | ||||
| } | ||||
|   | ||||
| @@ -17,11 +17,78 @@ limitations under the License. | ||||
| package v1 | ||||
|  | ||||
| import ( | ||||
| 	"k8s.io/apimachinery/pkg/conversion" | ||||
| 	"k8s.io/apimachinery/pkg/runtime" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||
| 	"k8s.io/apimachinery/pkg/types" | ||||
| ) | ||||
|  | ||||
| // ObjectMetaFor returns a pointer to a provided object's ObjectMeta. | ||||
| // TODO: allow runtime.Unknown to extract this object | ||||
| // TODO: Remove this function and use meta.ObjectMetaAccessor() instead. | ||||
| func ObjectMetaFor(obj runtime.Object) (*ObjectMeta, error) { | ||||
| 	v, err := conversion.EnforcePtr(obj) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	var meta *ObjectMeta | ||||
| 	err = runtime.FieldPtr(v, "ObjectMeta", &meta) | ||||
| 	return meta, err | ||||
| } | ||||
|  | ||||
| // ListMetaFor returns a pointer to a provided object's ListMeta, | ||||
| // or an error if the object does not have that pointer. | ||||
| // TODO: allow runtime.Unknown to extract this object | ||||
| // TODO: Remove this function and use meta.ObjectMetaAccessor() instead. | ||||
| func ListMetaFor(obj runtime.Object) (*ListMeta, error) { | ||||
| 	v, err := conversion.EnforcePtr(obj) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	var meta *ListMeta | ||||
| 	err = runtime.FieldPtr(v, "ListMeta", &meta) | ||||
| 	return meta, err | ||||
| } | ||||
|  | ||||
| // TODO: move this, Object, List, and Type to a different package | ||||
| type ObjectMetaAccessor interface { | ||||
| 	GetObjectMeta() Object | ||||
| } | ||||
|  | ||||
| // Object lets you work with object 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 (Name, UID, Namespace on lists) will be a no-op and return | ||||
| // a default value. | ||||
| type Object interface { | ||||
| 	GetNamespace() string | ||||
| 	SetNamespace(namespace string) | ||||
| 	GetName() string | ||||
| 	SetName(name string) | ||||
| 	GetGenerateName() string | ||||
| 	SetGenerateName(name string) | ||||
| 	GetUID() types.UID | ||||
| 	SetUID(uid types.UID) | ||||
| 	GetResourceVersion() string | ||||
| 	SetResourceVersion(version string) | ||||
| 	GetSelfLink() string | ||||
| 	SetSelfLink(selfLink string) | ||||
| 	GetCreationTimestamp() Time | ||||
| 	SetCreationTimestamp(timestamp Time) | ||||
| 	GetDeletionTimestamp() *Time | ||||
| 	SetDeletionTimestamp(timestamp *Time) | ||||
| 	GetLabels() map[string]string | ||||
| 	SetLabels(labels map[string]string) | ||||
| 	GetAnnotations() map[string]string | ||||
| 	SetAnnotations(annotations map[string]string) | ||||
| 	GetFinalizers() []string | ||||
| 	SetFinalizers(finalizers []string) | ||||
| 	GetOwnerReferences() []OwnerReference | ||||
| 	SetOwnerReferences([]OwnerReference) | ||||
| 	GetClusterName() string | ||||
| 	SetClusterName(clusterName string) | ||||
| } | ||||
|  | ||||
| // ListMetaAccessor retrieves the list interface from an object | ||||
| // TODO: move this, and TypeMeta and ListMeta, to a different package | ||||
| type ListMetaAccessor interface { | ||||
| 	GetListMeta() List | ||||
| } | ||||
| @@ -64,3 +131,71 @@ func (obj *TypeMeta) GroupVersionKind() schema.GroupVersionKind { | ||||
| } | ||||
|  | ||||
| func (obj *ListMeta) GetListMeta() List { return obj } | ||||
|  | ||||
| func (obj *ObjectMeta) GetObjectMeta() Object { return obj } | ||||
|  | ||||
| // Namespace implements metav1.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() Time          { return meta.CreationTimestamp } | ||||
| func (meta *ObjectMeta) SetCreationTimestamp(creationTimestamp Time) { | ||||
| 	meta.CreationTimestamp = creationTimestamp | ||||
| } | ||||
| func (meta *ObjectMeta) GetDeletionTimestamp() *Time { return meta.DeletionTimestamp } | ||||
| func (meta *ObjectMeta) SetDeletionTimestamp(deletionTimestamp *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() []OwnerReference { | ||||
| 	ret := make([]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 []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 | ||||
| } | ||||
|  | ||||
| func (meta *ObjectMeta) GetClusterName() string { | ||||
| 	return meta.ClusterName | ||||
| } | ||||
| func (meta *ObjectMeta) SetClusterName(clusterName string) { | ||||
| 	meta.ClusterName = clusterName | ||||
| } | ||||
|   | ||||
| @@ -48,6 +48,7 @@ type Unstructured struct { | ||||
| 	Object map[string]interface{} | ||||
| } | ||||
|  | ||||
| var _ metav1.Object = &Unstructured{} | ||||
| var _ runtime.Unstructured = &Unstructured{} | ||||
| var _ runtime.Unstructured = &UnstructuredList{} | ||||
|  | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	 Clayton Coleman
					Clayton Coleman