Move APIs and core code to use metav1.ObjectMeta

This commit is contained in:
Clayton Coleman 2017-01-11 15:28:46 -05:00
parent 54d8ed001d
commit 36acd90aba
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3
104 changed files with 486 additions and 865 deletions

View File

@ -75,7 +75,7 @@ type APIServiceStatus struct {
// Name must be "version.group". // Name must be "version.group".
type APIService struct { type APIService struct {
metav1.TypeMeta metav1.TypeMeta
kapi.ObjectMeta metav1.ObjectMeta
// Spec contains information for locating and communicating with a server // Spec contains information for locating and communicating with a server
Spec APIServiceSpec Spec APIServiceSpec

View File

@ -75,7 +75,7 @@ type APIServiceStatus struct {
// Name must be "version.group". // Name must be "version.group".
type APIService struct { type APIService struct {
metav1.TypeMeta `json:",inline"` 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 contains information for locating and communicating with a server
Spec APIServiceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` Spec APIServiceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`

View File

@ -277,9 +277,9 @@ func TestAPIs(t *testing.T) {
for _, o := range tc.apiservices { for _, o := range tc.apiservices {
indexer.Add(o) 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{ endpointsIndexer.Add(&corev1.Endpoints{
ObjectMeta: corev1.ObjectMeta{Namespace: "ns", Name: "api"}, ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "api"},
Subsets: []corev1.EndpointSubset{ Subsets: []corev1.EndpointSubset{
{Addresses: []corev1.EndpointAddress{{}}}, {Addresses: []corev1.EndpointAddress{{}}},
}, },
@ -434,9 +434,9 @@ func TestAPIGroup(t *testing.T) {
for _, o := range tc.apiservices { for _, o := range tc.apiservices {
indexer.Add(o) 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{ endpointsIndexer.Add(&corev1.Endpoints{
ObjectMeta: corev1.ObjectMeta{Namespace: "ns", Name: "api"}, ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: "api"},
Subsets: []corev1.EndpointSubset{ Subsets: []corev1.EndpointSubset{
{Addresses: []corev1.EndpointAddress{{}}}, {Addresses: []corev1.EndpointAddress{{}}},
}, },

View File

@ -25,7 +25,7 @@ import (
type TestType struct { type TestType struct {
metav1.TypeMeta metav1.TypeMeta
api.ObjectMeta metav1.ObjectMeta
Status TestTypeStatus Status TestTypeStatus
} }

View File

@ -30,7 +30,7 @@ type TestType struct {
// unversioned objects in the generate file that is not used anywhere other than this test type. // unversioned objects in the generate file that is not used anywhere other than this test type.
// +k8s:openapi-gen=false // +k8s:openapi-gen=false
// +optional // +optional
apiv1.ObjectMeta `json:"metadata,omitempty"` metav1.ObjectMeta `json:"metadata,omitempty"`
// +optional // +optional
Status TestTypeStatus `json:"status,omitempty"` Status TestTypeStatus `json:"status,omitempty"`
} }

View File

@ -99,7 +99,7 @@ type Cluster struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Spec defines the behavior of the Cluster. // Spec defines the behavior of the Cluster.
// +optional // +optional

View File

@ -99,7 +99,7 @@ type Cluster struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Spec defines the behavior of the Cluster.
// +optional // +optional

View File

@ -24,6 +24,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/davecgh/go-spew/spew"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion" "k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
@ -33,8 +35,6 @@ import (
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/fields"
"github.com/davecgh/go-spew/spew"
) )
// Conversion error conveniently packages up errors in conversions. // 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. // SingleObject returns a ListOptions for watching a single object.
func SingleObject(meta ObjectMeta) ListOptions { func SingleObject(meta metav1.ObjectMeta) ListOptions {
return ListOptions{ return ListOptions{
FieldSelector: fields.OneTermEqualSelector("metadata.name", meta.Name), FieldSelector: fields.OneTermEqualSelector("metadata.name", meta.Name),
ResourceVersion: meta.ResourceVersion, ResourceVersion: meta.ResourceVersion,

View File

@ -356,7 +356,7 @@ func TestGetAvoidPodsFromNode(t *testing.T) {
}, },
{ {
node: &Node{ node: &Node{
ObjectMeta: ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{ Annotations: map[string]string{
PreferAvoidPodsAnnotationKey: ` PreferAvoidPodsAnnotationKey: `
{ {
@ -401,7 +401,7 @@ func TestGetAvoidPodsFromNode(t *testing.T) {
{ {
node: &Node{ node: &Node{
// Missing end symbol of "podController" and "podSignature" // Missing end symbol of "podController" and "podSignature"
ObjectMeta: ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{ Annotations: map[string]string{
PreferAvoidPodsAnnotationKey: ` PreferAvoidPodsAnnotationKey: `
{ {

View File

@ -28,7 +28,7 @@ import (
) )
func TestResourceVersioner(t *testing.T) { 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) version, err := accessor.ResourceVersion(&pod)
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
@ -106,7 +106,7 @@ func TestRESTMapper(t *testing.T) {
t.Errorf("unexpected: %#v, expected: %#v", mapping, interfaces) 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) name, err := mapping.MetadataAccessor.Name(rc)
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)

View File

@ -17,109 +17,11 @@ limitations under the License.
package api package api
import ( import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 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. // 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() || return !meta.CreationTimestamp.Time.IsZero() ||
len(meta.UID) != 0 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
}

View File

@ -29,7 +29,7 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
) )
var _ meta.Object = &api.ObjectMeta{} var _ metav1.Object = &metav1.ObjectMeta{}
func getObjectMetaAndOwnerReferences() (objectMeta api.ObjectMeta, metaOwnerReferences []metav1.OwnerReference) { func getObjectMetaAndOwnerReferences() (objectMeta api.ObjectMeta, metaOwnerReferences []metav1.OwnerReference) {
fuzz.New().NilChance(.5).NumElements(1, 5).Fuzz(&objectMeta) 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) t.Errorf("%v (%v) does not implement runtime.Object", gv.WithKind(kind), knownType)
} }
lm, isLM := obj.(meta.ListMetaAccessor) lm, isLM := obj.(meta.ListMetaAccessor)
om, isOM := obj.(meta.ObjectMetaAccessor) om, isOM := obj.(metav1.ObjectMetaAccessor)
switch { switch {
case isLM && isOM: case isLM && isOM:
t.Errorf("%v (%v) implements ListMetaAccessor and ObjectMetaAccessor", gv.WithKind(kind), knownType) t.Errorf("%v (%v) implements ListMetaAccessor and ObjectMetaAccessor", gv.WithKind(kind), knownType)

View File

@ -31,7 +31,7 @@ func (obj *FakeAPIObject) GetObjectKind() schema.ObjectKind { return schema.Empt
type ExtensionAPIObject struct { type ExtensionAPIObject struct {
metav1.TypeMeta metav1.TypeMeta
ObjectMeta metav1.ObjectMeta
} }
func (obj *ExtensionAPIObject) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } func (obj *ExtensionAPIObject) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
@ -53,7 +53,7 @@ func TestGetReference(t *testing.T) {
}{ }{
"pod": { "pod": {
obj: &Pod{ obj: &Pod{
ObjectMeta: ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foo", Name: "foo",
UID: "bar", UID: "bar",
ResourceVersion: "42", ResourceVersion: "42",
@ -88,7 +88,7 @@ func TestGetReference(t *testing.T) {
TypeMeta: metav1.TypeMeta{ TypeMeta: metav1.TypeMeta{
Kind: "ExtensionAPIObject", Kind: "ExtensionAPIObject",
}, },
ObjectMeta: ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foo", Name: "foo",
UID: "bar", UID: "bar",
ResourceVersion: "42", ResourceVersion: "42",

View File

@ -23,6 +23,7 @@ import (
"testing" "testing"
"github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer/protobuf" "k8s.io/apimachinery/pkg/runtime/serializer/protobuf"

View File

@ -23,6 +23,8 @@ import (
"strconv" "strconv"
"testing" "testing"
"github.com/google/gofuzz"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -40,8 +42,6 @@ import (
"k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
"github.com/google/gofuzz"
) )
// FuzzerFor can randomly populate api objects that are destined for version. // FuzzerFor can randomly populate api objects that are destined for version.

View File

@ -57,7 +57,7 @@ import (
// ObjectMeta is metadata that all persisted resources must have, which includes all objects // ObjectMeta is metadata that all persisted resources must have, which includes all objects
// users must create. // 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 { type ObjectMeta struct {
// Name is unique within a namespace. Name is required when creating resources, although // 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 // some resources may allow a client to request the generation of an appropriate name
@ -371,7 +371,7 @@ type PersistentVolumeClaimVolumeSource struct {
type PersistentVolume struct { type PersistentVolume struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
//Spec defines a persistent volume owned by the cluster //Spec defines a persistent volume owned by the cluster
// +optional // +optional
@ -442,7 +442,7 @@ type PersistentVolumeList struct {
type PersistentVolumeClaim struct { type PersistentVolumeClaim struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Spec defines the volume requested by a pod author // Spec defines the volume requested by a pod author
// +optional // +optional
@ -1982,7 +1982,7 @@ type PodStatus struct {
type PodStatusResult struct { type PodStatusResult struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Status represents the current information about a pod. This data may not be up // Status represents the current information about a pod. This data may not be up
// to date. // to date.
// +optional // +optional
@ -1995,7 +1995,7 @@ type PodStatusResult struct {
type Pod struct { type Pod struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Spec defines the behavior of a pod. // Spec defines the behavior of a pod.
// +optional // +optional
@ -2011,7 +2011,7 @@ type Pod struct {
type PodTemplateSpec struct { type PodTemplateSpec struct {
// Metadata of the pods created from this template. // Metadata of the pods created from this template.
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Spec defines the behavior of a pod. // Spec defines the behavior of a pod.
// +optional // +optional
@ -2024,7 +2024,7 @@ type PodTemplateSpec struct {
type PodTemplate struct { type PodTemplate struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Template defines the pods that will be created from this pod template // Template defines the pods that will be created from this pod template
// +optional // +optional
@ -2129,7 +2129,7 @@ type ReplicationControllerCondition struct {
type ReplicationController struct { type ReplicationController struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Spec defines the desired behavior of this replication controller. // Spec defines the desired behavior of this replication controller.
// +optional // +optional
@ -2334,7 +2334,7 @@ type ServicePort struct {
type Service struct { type Service struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Spec defines the behavior of a service. // Spec defines the behavior of a service.
// +optional // +optional
@ -2354,7 +2354,7 @@ type Service struct {
type ServiceAccount struct { type ServiceAccount struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Secrets is the list of secrets allowed to be used by pods running using this ServiceAccount // Secrets is the list of secrets allowed to be used by pods running using this ServiceAccount
Secrets []ObjectReference Secrets []ObjectReference
@ -2392,7 +2392,7 @@ type ServiceAccountList struct {
type Endpoints struct { type Endpoints struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// The set of all endpoints is the union of all subsets. // The set of all endpoints is the union of all subsets.
Subsets []EndpointSubset Subsets []EndpointSubset
@ -2714,7 +2714,7 @@ type ResourceList map[ResourceName]resource.Quantity
type Node struct { type Node struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Spec defines the behavior of a node. // Spec defines the behavior of a node.
// +optional // +optional
@ -2774,7 +2774,7 @@ const (
type Namespace struct { type Namespace struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Spec defines the behavior of the Namespace. // Spec defines the behavior of the Namespace.
// +optional // +optional
@ -2799,7 +2799,7 @@ type Binding struct {
metav1.TypeMeta metav1.TypeMeta
// ObjectMeta describes the object that is being bound. // ObjectMeta describes the object that is being bound.
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Target is the object to bind to. // Target is the object to bind to.
Target ObjectReference Target ObjectReference
@ -3027,7 +3027,7 @@ const (
type Event struct { type Event struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Required. The object that this event is about. // Required. The object that this event is about.
// +optional // +optional
@ -3130,7 +3130,7 @@ type LimitRangeSpec struct {
type LimitRange struct { type LimitRange struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Spec defines the limits enforced // Spec defines the limits enforced
// +optional // +optional
@ -3220,7 +3220,7 @@ type ResourceQuotaStatus struct {
type ResourceQuota struct { type ResourceQuota struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Spec defines the desired quota // Spec defines the desired quota
// +optional // +optional
@ -3248,7 +3248,7 @@ type ResourceQuotaList struct {
type Secret struct { type Secret struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Data contains the secret data. Each key must be a valid DNS_SUBDOMAIN // Data contains the secret data. Each key must be a valid DNS_SUBDOMAIN
// or leading dot followed by valid DNS_SUBDOMAIN. // or leading dot followed by valid DNS_SUBDOMAIN.
@ -3363,7 +3363,7 @@ type SecretList struct {
type ConfigMap struct { type ConfigMap struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// Data contains the configuration data. // Data contains the configuration data.
// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot. // Each key must be a valid DNS_SUBDOMAIN with an optional leading dot.
@ -3446,7 +3446,7 @@ type ComponentCondition struct {
type ComponentStatus struct { type ComponentStatus struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
ObjectMeta metav1.ObjectMeta
// +optional // +optional
Conditions []ComponentCondition Conditions []ComponentCondition
@ -3525,7 +3525,7 @@ type SELinuxOptions struct {
type RangeAllocation struct { type RangeAllocation struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +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 // 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 // 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. // a start and end unless there is an implicit end.

View File

@ -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 { 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 { out.ObjectMeta = in.ObjectMeta
return err
}
if err := Convert_v1_ReplicationControllerSpec_to_extensions_ReplicaSetSpec(&in.Spec, &out.Spec, s); err != nil { if err := Convert_v1_ReplicationControllerSpec_to_extensions_ReplicaSetSpec(&in.Spec, &out.Spec, s); err != nil {
return err 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 { 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 { out.ObjectMeta = in.ObjectMeta
return err
}
if err := Convert_extensions_ReplicaSetSpec_to_v1_ReplicationControllerSpec(&in.Spec, &out.Spec, s); err != nil { if err := Convert_extensions_ReplicaSetSpec_to_v1_ReplicationControllerSpec(&in.Spec, &out.Spec, s); err != nil {
fieldErr, ok := err.(*field.Error) fieldErr, ok := err.(*field.Error)
if !ok { if !ok {

View File

@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
) )

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"strings" "strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection" "k8s.io/apimachinery/pkg/selection"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
@ -86,26 +87,12 @@ var standardFinalizers = sets.NewString(
FinalizerOrphan, 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 { func IsStandardFinalizerName(str string) bool {
return standardFinalizers.Has(str) return standardFinalizers.Has(str)
} }
// SingleObject returns a ListOptions for watching a single object. // SingleObject returns a ListOptions for watching a single object.
func SingleObject(meta ObjectMeta) ListOptions { func SingleObject(meta metav1.ObjectMeta) ListOptions {
return ListOptions{ return ListOptions{
FieldSelector: fields.OneTermEqualSelector("metadata.name", meta.Name).String(), FieldSelector: fields.OneTermEqualSelector("metadata.name", meta.Name).String(),
ResourceVersion: meta.ResourceVersion, ResourceVersion: meta.ResourceVersion,

View File

@ -190,7 +190,7 @@ func TestGetAffinityFromPod(t *testing.T) {
}, },
{ {
pod: &Pod{ pod: &Pod{
ObjectMeta: ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{ Annotations: map[string]string{
AffinityAnnotationKey: ` AffinityAnnotationKey: `
{"nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": { {"nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": {
@ -209,7 +209,7 @@ func TestGetAffinityFromPod(t *testing.T) {
}, },
{ {
pod: &Pod{ pod: &Pod{
ObjectMeta: ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{ Annotations: map[string]string{
AffinityAnnotationKey: ` AffinityAnnotationKey: `
{"nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": { {"nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": {
@ -350,7 +350,7 @@ func TestGetAvoidPodsFromNode(t *testing.T) {
}, },
{ {
node: &Node{ node: &Node{
ObjectMeta: ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{ Annotations: map[string]string{
PreferAvoidPodsAnnotationKey: ` PreferAvoidPodsAnnotationKey: `
{ {
@ -395,7 +395,7 @@ func TestGetAvoidPodsFromNode(t *testing.T) {
{ {
node: &Node{ node: &Node{
// Missing end symbol of "podController" and "podSignature" // Missing end symbol of "podController" and "podSignature"
ObjectMeta: ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{ Annotations: map[string]string{
PreferAvoidPodsAnnotationKey: ` PreferAvoidPodsAnnotationKey: `
{ {

View File

@ -17,14 +17,13 @@ limitations under the License.
package v1 package v1
import ( import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "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. // fast, direct access to metadata fields for API objects.
func (meta *ObjectMeta) GetNamespace() string { return meta.Namespace } func (meta *ObjectMeta) GetNamespace() string { return meta.Namespace }
func (meta *ObjectMeta) SetNamespace(namespace string) { meta.Namespace = namespace } func (meta *ObjectMeta) SetNamespace(namespace string) { meta.Namespace = namespace }

View File

@ -65,7 +65,7 @@ import (
// ObjectMeta is metadata that all persisted resources must have, which includes all objects // ObjectMeta is metadata that all persisted resources must have, which includes all objects
// users must create. // 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 // +k8s:openapi-gen=false
type ObjectMeta struct { type ObjectMeta struct {
// Name must be unique within a namespace. Is required when creating resources, although // Name must be unique within a namespace. Is required when creating resources, although
@ -424,7 +424,7 @@ type PersistentVolume struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Spec defines a specification of a persistent volume owned by the cluster.
// Provisioned by an administrator. // Provisioned by an administrator.
@ -516,7 +516,7 @@ type PersistentVolumeClaim struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Spec defines the desired characteristics of a volume requested by a pod author.
// More info: http://kubernetes.io/docs/user-guide/persistent-volumes#persistentvolumeclaims // More info: http://kubernetes.io/docs/user-guide/persistent-volumes#persistentvolumeclaims
@ -2254,7 +2254,7 @@ type PodStatusResult struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Most recently observed status of the pod.
// This data may not be up to date. // This data may not be up to date.
// Populated by the system. // Populated by the system.
@ -2273,7 +2273,7 @@ type Pod struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Specification of the desired behavior of the pod.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Specification of the desired behavior of the pod.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // 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 // 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. // 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 // Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // 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 // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Spec defines the behavior of a service.
// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
@ -2721,7 +2721,7 @@ type ServiceAccount struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // 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 // More info: http://kubernetes.io/docs/user-guide/secrets
@ -2768,7 +2768,7 @@ type Endpoints struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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 // 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, // subsets according to the IPs they share. A single address with multiple ports,
@ -3126,7 +3126,7 @@ type Node struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Spec defines the behavior of a node.
// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
@ -3198,7 +3198,7 @@ type Namespace struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Spec defines the behavior of the Namespace.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // The target object that you want to bind to the standard object.
Target ObjectReference `json:"target" protobuf:"bytes,2,opt,name=target"` Target ObjectReference `json:"target" protobuf:"bytes,2,opt,name=target"`
@ -3519,7 +3519,7 @@ type Event struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#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. // The object that this event is about.
InvolvedObject ObjectReference `json:"involvedObject" protobuf:"bytes,2,opt,name=involvedObject"` InvolvedObject ObjectReference `json:"involvedObject" protobuf:"bytes,2,opt,name=involvedObject"`
@ -3628,7 +3628,7 @@ type LimitRange struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Spec defines the limits enforced.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Spec defines the desired quota.
// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status
@ -3761,7 +3761,7 @@ type Secret struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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 // Data contains the secret data. Each key must be a valid DNS_SUBDOMAIN
// or leading dot followed by valid DNS_SUBDOMAIN. // or leading dot followed by valid DNS_SUBDOMAIN.
@ -3888,7 +3888,7 @@ type ConfigMap struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Data contains the configuration data.
// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot. // Each key must be a valid DNS_SUBDOMAIN with an optional leading dot.
@ -3943,7 +3943,7 @@ type ComponentStatus struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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 // List of component conditions observed
// +optional // +optional
@ -4061,7 +4061,7 @@ type RangeAllocation struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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 is string that identifies the range represented by 'data'.
Range string `json:"range" protobuf:"bytes,2,opt,name=range"` Range string `json:"range" protobuf:"bytes,2,opt,name=range"`

View File

@ -20,6 +20,7 @@ import (
"testing" "testing"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
func TestValidateEvent(t *testing.T) { func TestValidateEvent(t *testing.T) {

View File

@ -26,7 +26,6 @@ import (
apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation" apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api"
) )
const ( const (
@ -38,7 +37,7 @@ const (
// Ensure custom name functions are allowed // Ensure custom name functions are allowed
func TestValidateObjectMetaCustomName(t *testing.T) { func TestValidateObjectMetaCustomName(t *testing.T) {
errs := ValidateObjectMeta( errs := ValidateObjectMeta(
&api.ObjectMeta{Name: "test", GenerateName: "foo"}, &metav1.ObjectMeta{Name: "test", GenerateName: "foo"},
false, false,
func(s string, prefix bool) []string { func(s string, prefix bool) []string {
if s == "test" { if s == "test" {
@ -58,7 +57,7 @@ func TestValidateObjectMetaCustomName(t *testing.T) {
// Ensure namespace names follow dns label format // Ensure namespace names follow dns label format
func TestValidateObjectMetaNamespaces(t *testing.T) { func TestValidateObjectMetaNamespaces(t *testing.T) {
errs := ValidateObjectMeta( errs := ValidateObjectMeta(
&api.ObjectMeta{Name: "test", Namespace: "foo.bar"}, &metav1.ObjectMeta{Name: "test", Namespace: "foo.bar"},
true, true,
func(s string, prefix bool) []string { func(s string, prefix bool) []string {
return nil return nil
@ -77,7 +76,7 @@ func TestValidateObjectMetaNamespaces(t *testing.T) {
b[i] = letters[rand.Intn(len(letters))] b[i] = letters[rand.Intn(len(letters))]
} }
errs = ValidateObjectMeta( errs = ValidateObjectMeta(
&api.ObjectMeta{Name: "test", Namespace: string(b)}, &metav1.ObjectMeta{Name: "test", Namespace: string(b)},
true, true,
func(s string, prefix bool) []string { func(s string, prefix bool) []string {
return nil return nil
@ -198,7 +197,7 @@ func TestValidateObjectMetaOwnerReferences(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
errs := ValidateObjectMeta( errs := ValidateObjectMeta(
&api.ObjectMeta{Name: "test", Namespace: "test", OwnerReferences: tc.ownerReferences}, &metav1.ObjectMeta{Name: "test", Namespace: "test", OwnerReferences: tc.ownerReferences},
true, true,
func(s string, prefix bool) []string { func(s string, prefix bool) []string {
return nil return nil
@ -218,22 +217,22 @@ func TestValidateObjectMetaOwnerReferences(t *testing.T) {
func TestValidateObjectMetaUpdateIgnoresCreationTimestamp(t *testing.T) { func TestValidateObjectMetaUpdateIgnoresCreationTimestamp(t *testing.T) {
if errs := ValidateObjectMetaUpdate( if errs := ValidateObjectMetaUpdate(
&api.ObjectMeta{Name: "test", ResourceVersion: "1"}, &metav1.ObjectMeta{Name: "test", ResourceVersion: "1"},
&api.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))}, &metav1.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))},
field.NewPath("field"), field.NewPath("field"),
); len(errs) != 0 { ); len(errs) != 0 {
t.Fatalf("unexpected errors: %v", errs) t.Fatalf("unexpected errors: %v", errs)
} }
if errs := ValidateObjectMetaUpdate( if errs := ValidateObjectMetaUpdate(
&api.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))}, &metav1.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))},
&api.ObjectMeta{Name: "test", ResourceVersion: "1"}, &metav1.ObjectMeta{Name: "test", ResourceVersion: "1"},
field.NewPath("field"), field.NewPath("field"),
); len(errs) != 0 { ); len(errs) != 0 {
t.Fatalf("unexpected errors: %v", errs) t.Fatalf("unexpected errors: %v", errs)
} }
if errs := ValidateObjectMetaUpdate( if errs := ValidateObjectMetaUpdate(
&api.ObjectMeta{Name: "test", ResourceVersion: "1", CreationTimestamp: metav1.NewTime(time.Unix(10, 0))}, &metav1.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(11, 0))},
field.NewPath("field"), field.NewPath("field"),
); len(errs) != 0 { ); len(errs) != 0 {
t.Fatalf("unexpected errors: %v", errs) t.Fatalf("unexpected errors: %v", errs)
@ -242,28 +241,28 @@ func TestValidateObjectMetaUpdateIgnoresCreationTimestamp(t *testing.T) {
func TestValidateFinalizersUpdate(t *testing.T) { func TestValidateFinalizersUpdate(t *testing.T) {
testcases := map[string]struct { testcases := map[string]struct {
Old api.ObjectMeta Old metav1.ObjectMeta
New api.ObjectMeta New metav1.ObjectMeta
ExpectedErr string ExpectedErr string
}{ }{
"invalid adding finalizers": { "invalid adding finalizers": {
Old: 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"}},
New: api.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", "y/b"}},
ExpectedErr: "y/b", ExpectedErr: "y/b",
}, },
"invalid changing finalizers": { "invalid changing finalizers": {
Old: 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"}},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/b"}}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &metav1.Time{}, Finalizers: []string{"x/b"}},
ExpectedErr: "x/b", ExpectedErr: "x/b",
}, },
"valid removing finalizers": { "valid removing finalizers": {
Old: 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", "y/b"}},
New: api.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"}},
ExpectedErr: "", ExpectedErr: "",
}, },
"valid adding finalizers for objects not being deleted": { "valid adding finalizers for objects not being deleted": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1", Finalizers: []string{"x/a"}}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Finalizers: []string{"x/a"}},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1", Finalizers: []string{"x/a", "y/b"}}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Finalizers: []string{"x/a", "y/b"}},
ExpectedErr: "", ExpectedErr: "",
}, },
} }
@ -286,59 +285,59 @@ func TestValidateObjectMetaUpdatePreventsDeletionFieldMutation(t *testing.T) {
gracePeriodLong := int64(40) gracePeriodLong := int64(40)
testcases := map[string]struct { testcases := map[string]struct {
Old api.ObjectMeta Old metav1.ObjectMeta
New api.ObjectMeta New metav1.ObjectMeta
ExpectedNew api.ObjectMeta ExpectedNew metav1.ObjectMeta
ExpectedErrs []string ExpectedErrs []string
}{ }{
"valid without deletion fields": { "valid without deletion fields": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1"}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1"},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1"}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1"},
ExpectedNew: api.ObjectMeta{Name: "test", ResourceVersion: "1"}, ExpectedNew: metav1.ObjectMeta{Name: "test", ResourceVersion: "1"},
ExpectedErrs: []string{}, ExpectedErrs: []string{},
}, },
"valid with deletion fields": { "valid with deletion fields": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort},
ExpectedNew: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort}, ExpectedNew: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now, DeletionGracePeriodSeconds: &gracePeriodShort},
ExpectedErrs: []string{}, ExpectedErrs: []string{},
}, },
"invalid set deletionTimestamp": { "invalid set deletionTimestamp": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1"}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1"},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now},
ExpectedNew: api.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"}, ExpectedErrs: []string{"field.deletionTimestamp: Invalid value: \"1970-01-01T00:16:40Z\": field is immutable; may only be changed via deletion"},
}, },
"invalid clear deletionTimestamp": { "invalid clear deletionTimestamp": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1"}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1"},
ExpectedNew: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, ExpectedNew: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now},
ExpectedErrs: []string{}, // no errors, validation copies the old value ExpectedErrs: []string{}, // no errors, validation copies the old value
}, },
"invalid change deletionTimestamp": { "invalid change deletionTimestamp": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &later}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &later},
ExpectedNew: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now}, ExpectedNew: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionTimestamp: &now},
ExpectedErrs: []string{}, // no errors, validation copies the old value ExpectedErrs: []string{}, // no errors, validation copies the old value
}, },
"invalid set deletionGracePeriodSeconds": { "invalid set deletionGracePeriodSeconds": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1"}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1"},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort},
ExpectedNew: api.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"}, ExpectedErrs: []string{"field.deletionGracePeriodSeconds: Invalid value: 30: field is immutable; may only be changed via deletion"},
}, },
"invalid clear deletionGracePeriodSeconds": { "invalid clear deletionGracePeriodSeconds": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1"}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1"},
ExpectedNew: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, ExpectedNew: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort},
ExpectedErrs: []string{}, // no errors, validation copies the old value ExpectedErrs: []string{}, // no errors, validation copies the old value
}, },
"invalid change deletionGracePeriodSeconds": { "invalid change deletionGracePeriodSeconds": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodShort},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodLong}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", DeletionGracePeriodSeconds: &gracePeriodLong},
ExpectedNew: api.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"}, 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) { func TestObjectMetaGenerationUpdate(t *testing.T) {
testcases := map[string]struct { testcases := map[string]struct {
Old api.ObjectMeta Old metav1.ObjectMeta
New api.ObjectMeta New metav1.ObjectMeta
ExpectedErrs []string ExpectedErrs []string
}{ }{
"invalid generation change - decremented": { "invalid generation change - decremented": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 4}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 4},
ExpectedErrs: []string{"field.generation: Invalid value: 4: must not be decremented"}, ExpectedErrs: []string{"field.generation: Invalid value: 4: must not be decremented"},
}, },
"valid generation change - incremented by one": { "valid generation change - incremented by one": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 1}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 1},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 2}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 2},
ExpectedErrs: []string{}, ExpectedErrs: []string{},
}, },
"valid generation field - not updated": { "valid generation field - not updated": {
Old: api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5}, Old: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5},
New: api.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5}, New: metav1.ObjectMeta{Name: "test", ResourceVersion: "1", Generation: 5},
ExpectedErrs: []string{}, ExpectedErrs: []string{},
}, },
} }
@ -408,7 +407,7 @@ func TestObjectMetaGenerationUpdate(t *testing.T) {
// Ensure trailing slash is allowed in generate name // Ensure trailing slash is allowed in generate name
func TestValidateObjectMetaTrimsTrailingSlash(t *testing.T) { func TestValidateObjectMetaTrimsTrailingSlash(t *testing.T) {
errs := ValidateObjectMeta( errs := ValidateObjectMeta(
&api.ObjectMeta{Name: "test", GenerateName: "foo-"}, &metav1.ObjectMeta{Name: "test", GenerateName: "foo-"},
false, false,
apimachineryvalidation.NameIsDNSSubdomain, apimachineryvalidation.NameIsDNSSubdomain,
field.NewPath("field")) field.NewPath("field"))

View File

@ -21,6 +21,7 @@ import (
"testing" "testing"
"k8s.io/apimachinery/pkg/api/meta" "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/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"

View File

@ -49,13 +49,13 @@ func TestAPIObjectMeta(t *testing.T) {
}, },
}, },
} }
var _ meta.Object = &j.ObjectMeta var _ metav1.Object = &j.ObjectMeta
var _ meta.ObjectMetaAccessor = j var _ metav1.ObjectMetaAccessor = j
accessor, err := meta.Accessor(j) accessor, err := meta.Accessor(j)
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) 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) t.Fatalf("should have returned the same pointer: %#v\n\n%#v", accessor, j)
} }
if e, a := "bar", accessor.GetNamespace(); e != a { if e, a := "bar", accessor.GetNamespace(); e != a {

View File

@ -32,7 +32,7 @@ import (
type StatefulSet struct { type StatefulSet struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Spec defines the desired identities of pods in this set. // Spec defines the desired identities of pods in this set.
// +optional // +optional

View File

@ -32,7 +32,7 @@ import (
type StatefulSet struct { type StatefulSet struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +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. // Spec defines the desired identities of pods in this set.
// +optional // +optional

View File

@ -18,7 +18,6 @@ package authentication
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
) )
const ( const (
@ -43,9 +42,9 @@ const (
// TokenReview attempts to authenticate a token to a known user. // TokenReview attempts to authenticate a token to a known user.
type TokenReview struct { type TokenReview struct {
metav1.TypeMeta 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 // REST handler paths work
api.ObjectMeta metav1.ObjectMeta
// Spec holds information about the request being evaluated // Spec holds information about the request being evaluated
Spec TokenReviewSpec Spec TokenReviewSpec

View File

@ -20,7 +20,6 @@ import (
"fmt" "fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api/v1"
) )
// +genclient=true // +genclient=true
@ -33,7 +32,7 @@ import (
type TokenReview struct { type TokenReview struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +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 holds information about the request being evaluated
Spec TokenReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` Spec TokenReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`

View File

@ -18,7 +18,6 @@ package authorization
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
) )
// +genclient=true // +genclient=true
@ -29,7 +28,7 @@ import (
// spec.namespace means "in all namespaces". // spec.namespace means "in all namespaces".
type SubjectAccessReview struct { type SubjectAccessReview struct {
metav1.TypeMeta metav1.TypeMeta
api.ObjectMeta metav1.ObjectMeta
// Spec holds information about the request being evaluated // Spec holds information about the request being evaluated
Spec SubjectAccessReviewSpec Spec SubjectAccessReviewSpec
@ -47,7 +46,7 @@ type SubjectAccessReview struct {
// to check whether they can perform an action // to check whether they can perform an action
type SelfSubjectAccessReview struct { type SelfSubjectAccessReview struct {
metav1.TypeMeta metav1.TypeMeta
api.ObjectMeta metav1.ObjectMeta
// Spec holds information about the request being evaluated. // Spec holds information about the request being evaluated.
Spec SelfSubjectAccessReviewSpec Spec SelfSubjectAccessReviewSpec
@ -64,7 +63,7 @@ type SelfSubjectAccessReview struct {
// checking. // checking.
type LocalSubjectAccessReview struct { type LocalSubjectAccessReview struct {
metav1.TypeMeta metav1.TypeMeta
api.ObjectMeta metav1.ObjectMeta
// Spec holds information about the request being evaluated. spec.namespace must be equal to the namespace // 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. // you made the request against. If empty, it is defaulted.

View File

@ -20,7 +20,6 @@ import (
"fmt" "fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api/v1"
) )
// +genclient=true // +genclient=true
@ -31,7 +30,7 @@ import (
type SubjectAccessReview struct { type SubjectAccessReview struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +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 holds information about the request being evaluated
Spec SubjectAccessReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` Spec SubjectAccessReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
@ -51,7 +50,7 @@ type SubjectAccessReview struct {
type SelfSubjectAccessReview struct { type SelfSubjectAccessReview struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +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 holds information about the request being evaluated. user and groups must be empty
Spec SelfSubjectAccessReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` Spec SelfSubjectAccessReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
@ -70,7 +69,7 @@ type SelfSubjectAccessReview struct {
type LocalSubjectAccessReview struct { type LocalSubjectAccessReview struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +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 // 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. // you made the request against. If empty, it is defaulted.

View File

@ -17,6 +17,7 @@ limitations under the License.
package validation package validation
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
authorizationapi "k8s.io/kubernetes/pkg/apis/authorization" authorizationapi "k8s.io/kubernetes/pkg/apis/authorization"
@ -51,7 +52,7 @@ func ValidateSelfSubjectAccessReviewSpec(spec authorizationapi.SelfSubjectAccess
func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) field.ErrorList { func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) field.ErrorList {
allErrs := ValidateSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec")) 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`)) allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty`))
} }
return allErrs return allErrs
@ -59,7 +60,7 @@ func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) fiel
func ValidateSelfSubjectAccessReview(sar *authorizationapi.SelfSubjectAccessReview) field.ErrorList { func ValidateSelfSubjectAccessReview(sar *authorizationapi.SelfSubjectAccessReview) field.ErrorList {
allErrs := ValidateSelfSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec")) 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`)) allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty`))
} }
return allErrs return allErrs
@ -70,7 +71,7 @@ func ValidateLocalSubjectAccessReview(sar *authorizationapi.LocalSubjectAccessRe
objectMetaShallowCopy := sar.ObjectMeta objectMetaShallowCopy := sar.ObjectMeta
objectMetaShallowCopy.Namespace = "" 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`)) allErrs = append(allErrs, field.Invalid(field.NewPath("metadata"), sar.ObjectMeta, `must be empty except for namespace`))
} }

View File

@ -20,8 +20,8 @@ import (
"strings" "strings"
"testing" "testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api"
authorizationapi "k8s.io/kubernetes/pkg/apis/authorization" authorizationapi "k8s.io/kubernetes/pkg/apis/authorization"
) )
@ -158,7 +158,7 @@ func TestValidateLocalSAR(t *testing.T) {
{ {
name: "name", name: "name",
obj: &authorizationapi.LocalSubjectAccessReview{ obj: &authorizationapi.LocalSubjectAccessReview{
ObjectMeta: api.ObjectMeta{Name: "a"}, ObjectMeta: metav1.ObjectMeta{Name: "a"},
Spec: authorizationapi.SubjectAccessReviewSpec{ Spec: authorizationapi.SubjectAccessReviewSpec{
ResourceAttributes: &authorizationapi.ResourceAttributes{}, ResourceAttributes: &authorizationapi.ResourceAttributes{},
User: "user", User: "user",
@ -169,7 +169,7 @@ func TestValidateLocalSAR(t *testing.T) {
{ {
name: "namespace conflict", name: "namespace conflict",
obj: &authorizationapi.LocalSubjectAccessReview{ obj: &authorizationapi.LocalSubjectAccessReview{
ObjectMeta: api.ObjectMeta{Namespace: "a"}, ObjectMeta: metav1.ObjectMeta{Namespace: "a"},
Spec: authorizationapi.SubjectAccessReviewSpec{ Spec: authorizationapi.SubjectAccessReviewSpec{
ResourceAttributes: &authorizationapi.ResourceAttributes{}, ResourceAttributes: &authorizationapi.ResourceAttributes{},
User: "user", User: "user",
@ -180,7 +180,7 @@ func TestValidateLocalSAR(t *testing.T) {
{ {
name: "nonresource", name: "nonresource",
obj: &authorizationapi.LocalSubjectAccessReview{ obj: &authorizationapi.LocalSubjectAccessReview{
ObjectMeta: api.ObjectMeta{Namespace: "a"}, ObjectMeta: metav1.ObjectMeta{Namespace: "a"},
Spec: authorizationapi.SubjectAccessReviewSpec{ Spec: authorizationapi.SubjectAccessReviewSpec{
NonResourceAttributes: &authorizationapi.NonResourceAttributes{}, NonResourceAttributes: &authorizationapi.NonResourceAttributes{},
User: "user", User: "user",

View File

@ -18,7 +18,6 @@ package autoscaling
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
) )
// Scale represents a scaling request for a resource. // Scale represents a scaling request for a resource.
@ -26,7 +25,7 @@ type Scale struct {
metav1.TypeMeta metav1.TypeMeta
// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata. // Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.
// +optional // +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. // defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.
// +optional // +optional
@ -113,7 +112,7 @@ type HorizontalPodAutoscalerStatus struct {
type HorizontalPodAutoscaler struct { type HorizontalPodAutoscaler struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. // behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.
// +optional // +optional

View File

@ -78,7 +78,7 @@ type HorizontalPodAutoscaler struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // Standard object metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.
// +optional // +optional
@ -105,7 +105,7 @@ type Scale struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata. // Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.
// +optional // +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. // defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.
// +optional // +optional

View File

@ -22,6 +22,7 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/autoscaling" "k8s.io/kubernetes/pkg/apis/autoscaling"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/controller/podautoscaler" "k8s.io/kubernetes/pkg/controller/podautoscaler"
) )

View File

@ -29,7 +29,7 @@ type Job struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Spec is a structure defining the expected behavior of a job. // 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 // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Template defines jobs that will be created from this template // Template defines jobs that will be created from this template
// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // Standard object's metadata of the jobs created from this template.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Specification of the desired behavior of the job. // Specification of the desired behavior of the job.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Spec is a structure defining the expected behavior of a job, including the schedule. // 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 // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status

View File

@ -20,6 +20,7 @@ import (
"reflect" "reflect"
"testing" "testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
_ "k8s.io/kubernetes/pkg/api/install" _ "k8s.io/kubernetes/pkg/api/install"
@ -39,7 +40,7 @@ func TestSetDefaultJob(t *testing.T) {
original: &Job{ original: &Job{
Spec: JobSpec{ Spec: JobSpec{
Template: v1.PodTemplateSpec{ 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": { "both unspecified -> sets both to 1 and no default labels": {
original: &Job{ original: &Job{
ObjectMeta: v1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"mylabel": "myvalue"}, Labels: map[string]string{"mylabel": "myvalue"},
}, },
Spec: JobSpec{ Spec: JobSpec{
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
}, },
}, },
@ -74,7 +75,7 @@ func TestSetDefaultJob(t *testing.T) {
Spec: JobSpec{ Spec: JobSpec{
Parallelism: newInt32(0), Parallelism: newInt32(0),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
}, },
}, },
@ -90,7 +91,7 @@ func TestSetDefaultJob(t *testing.T) {
Spec: JobSpec{ Spec: JobSpec{
Parallelism: newInt32(2), Parallelism: newInt32(2),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
}, },
}, },
@ -106,7 +107,7 @@ func TestSetDefaultJob(t *testing.T) {
Spec: JobSpec{ Spec: JobSpec{
Completions: newInt32(2), Completions: newInt32(2),
Template: v1.PodTemplateSpec{ 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), Completions: newInt32(10),
Parallelism: newInt32(11), Parallelism: newInt32(11),
Template: v1.PodTemplateSpec{ 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), Completions: newInt32(10),
Parallelism: newInt32(11), Parallelism: newInt32(11),
Template: v1.PodTemplateSpec{ 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), Completions: newInt32(11),
Parallelism: newInt32(10), Parallelism: newInt32(10),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
}, },
}, },

View File

@ -29,7 +29,7 @@ type Job struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // 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 // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status

View File

@ -20,6 +20,7 @@ import (
"reflect" "reflect"
"testing" "testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
_ "k8s.io/kubernetes/pkg/api/install" _ "k8s.io/kubernetes/pkg/api/install"
@ -39,7 +40,7 @@ func TestSetDefaultJob(t *testing.T) {
original: &Job{ original: &Job{
Spec: JobSpec{ Spec: JobSpec{
Template: v1.PodTemplateSpec{ 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": { "both unspecified -> sets both to 1 and no default labels": {
original: &Job{ original: &Job{
ObjectMeta: v1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"mylabel": "myvalue"}, Labels: map[string]string{"mylabel": "myvalue"},
}, },
Spec: JobSpec{ Spec: JobSpec{
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
}, },
}, },
@ -74,7 +75,7 @@ func TestSetDefaultJob(t *testing.T) {
Spec: JobSpec{ Spec: JobSpec{
Parallelism: newInt32(0), Parallelism: newInt32(0),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
}, },
}, },
@ -90,7 +91,7 @@ func TestSetDefaultJob(t *testing.T) {
Spec: JobSpec{ Spec: JobSpec{
Parallelism: newInt32(2), Parallelism: newInt32(2),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
}, },
}, },
@ -106,7 +107,7 @@ func TestSetDefaultJob(t *testing.T) {
Spec: JobSpec{ Spec: JobSpec{
Completions: newInt32(2), Completions: newInt32(2),
Template: v1.PodTemplateSpec{ 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), Completions: newInt32(10),
Parallelism: newInt32(11), Parallelism: newInt32(11),
Template: v1.PodTemplateSpec{ 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), Completions: newInt32(10),
Parallelism: newInt32(11), Parallelism: newInt32(11),
Template: v1.PodTemplateSpec{ 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), Completions: newInt32(11),
Parallelism: newInt32(10), Parallelism: newInt32(10),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
}, },
}, },

View File

@ -29,7 +29,7 @@ type Job struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // 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 // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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 // Template defines jobs that will be created from this template
// http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // Standard object's metadata of the jobs created from this template.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Specification of the desired behavior of the job.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // 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 // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status

View File

@ -28,7 +28,7 @@ import (
type CertificateSigningRequest struct { type CertificateSigningRequest struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// The certificate request itself and any additional information. // The certificate request itself and any additional information.
// +optional // +optional

View File

@ -18,7 +18,6 @@ package v1alpha1
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api/v1"
) )
// +genclient=true // +genclient=true
@ -28,7 +27,7 @@ import (
type CertificateSigningRequest struct { type CertificateSigningRequest struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +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. // The certificate request itself and any additional information.
// +optional // +optional

View File

@ -68,7 +68,7 @@ type Scale struct {
metav1.TypeMeta metav1.TypeMeta
// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata. // Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.
// +optional // +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. // defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.
// +optional // +optional
@ -117,7 +117,7 @@ type ThirdPartyResource struct {
// Standard object metadata // Standard object metadata
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Description is the description of this object. // Description is the description of this object.
// +optional // +optional
@ -150,7 +150,7 @@ type ThirdPartyResourceData struct {
metav1.TypeMeta metav1.TypeMeta
// Standard object metadata. // Standard object metadata.
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Data is the raw JSON data for this data. // Data is the raw JSON data for this data.
// +optional // +optional
@ -162,7 +162,7 @@ type ThirdPartyResourceData struct {
type Deployment struct { type Deployment struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Specification of the desired behavior of the Deployment. // Specification of the desired behavior of the Deployment.
// +optional // +optional
@ -492,7 +492,7 @@ type DaemonSet struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Spec defines the desired behavior of this daemon set. // Spec defines the desired behavior of this daemon set.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Spec is the desired state of the Ingress. // Spec is the desired state of the Ingress.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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 { type ReplicaSet struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Spec defines the desired behavior of this ReplicaSet. // Spec defines the desired behavior of this ReplicaSet.
// +optional // +optional
@ -810,7 +810,7 @@ type ReplicaSetCondition struct {
type PodSecurityPolicy struct { type PodSecurityPolicy struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Spec defines the policy enforced. // Spec defines the policy enforced.
// +optional // +optional
@ -1017,7 +1017,7 @@ type PodSecurityPolicyList struct {
type NetworkPolicy struct { type NetworkPolicy struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Specification of the desired behavior for this NetworkPolicy. // Specification of the desired behavior for this NetworkPolicy.
// +optional // +optional

View File

@ -57,7 +57,7 @@ type Scale struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata. // Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.
// +optional // +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. // defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.
// +optional // +optional
@ -162,7 +162,7 @@ type HorizontalPodAutoscaler struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // Standard object metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.
// +optional // +optional
@ -194,7 +194,7 @@ type ThirdPartyResource struct {
// Standard object metadata // Standard object metadata
// +optional // +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. // Description is the description of this object.
// +optional // +optional
@ -229,7 +229,7 @@ type ThirdPartyResourceData struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object metadata. // Standard object metadata.
// +optional // +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. // Data is the raw JSON data for this data.
// +optional // +optional
@ -243,7 +243,7 @@ type Deployment struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object metadata. // Standard object metadata.
// +optional // +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. // Specification of the desired behavior of the Deployment.
// +optional // +optional
@ -582,7 +582,7 @@ type DaemonSet struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Spec defines the desired behavior of this daemon set.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Spec is the desired state of the Ingress.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status // 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. // 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 // Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // 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 // 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. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // spec defines the policy enforced.
// +optional // +optional
@ -1128,7 +1128,7 @@ type NetworkPolicy struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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. // Specification of the desired behavior for this NetworkPolicy.
// +optional // +optional

View File

@ -18,7 +18,6 @@ package imagepolicy
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
) )
// +genclient=true // +genclient=true
@ -28,7 +27,7 @@ import (
// ImageReview checks if the set of images in a pod are allowed. // ImageReview checks if the set of images in a pod are allowed.
type ImageReview struct { type ImageReview struct {
metav1.TypeMeta metav1.TypeMeta
api.ObjectMeta metav1.ObjectMeta
// Spec holds information about the pod being evaluated // Spec holds information about the pod being evaluated
Spec ImageReviewSpec Spec ImageReviewSpec

View File

@ -18,7 +18,6 @@ package v1alpha1
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api/v1"
) )
// +genclient=true // +genclient=true
@ -29,7 +28,7 @@ import (
type ImageReview struct { type ImageReview struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +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 holds information about the pod being evaluated
Spec ImageReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` Spec ImageReviewSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`

View File

@ -77,7 +77,7 @@ type PodDisruptionBudgetStatus struct {
type PodDisruptionBudget struct { type PodDisruptionBudget struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// Specification of the desired behavior of the PodDisruptionBudget. // Specification of the desired behavior of the PodDisruptionBudget.
// +optional // +optional
@ -106,7 +106,7 @@ type Eviction struct {
// ObjectMeta describes the pod that is being evicted. // ObjectMeta describes the pod that is being evicted.
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// DeleteOptions may be provided // DeleteOptions may be provided
// +optional // +optional

View File

@ -59,7 +59,7 @@ type PodDisruptionBudgetStatus struct {
type PodDisruptionBudget struct { type PodDisruptionBudget struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +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. // Specification of the desired behavior of the PodDisruptionBudget.
// +optional // +optional
@ -85,7 +85,7 @@ type Eviction struct {
// ObjectMeta describes the pod that is being evicted. // ObjectMeta describes the pod that is being evicted.
// +optional // +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 // DeleteOptions may be provided
// +optional // +optional

View File

@ -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 // PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods
type PodDisruptionBudget struct { type PodDisruptionBudget struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
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. // Specification of the desired behavior of the PodDisruptionBudget.
Spec PodDisruptionBudgetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` Spec PodDisruptionBudgetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
@ -99,7 +99,7 @@ type Eviction struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// ObjectMeta describes the pod that is being evicted. // 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 may be provided
DeleteOptions *v1.DeleteOptions `json:"deleteOptions,omitempty" protobuf:"bytes,2,opt,name=deleteOptions"` DeleteOptions *v1.DeleteOptions `json:"deleteOptions,omitempty" protobuf:"bytes,2,opt,name=deleteOptions"`

View File

@ -20,9 +20,9 @@ import (
"fmt" "fmt"
"strings" "strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/pkg/api"
) )
func RoleRefGroupKind(roleRef RoleRef) schema.GroupKind { func RoleRefGroupKind(roleRef RoleRef) schema.GroupKind {
@ -208,7 +208,7 @@ type ClusterRoleBindingBuilder struct {
func NewClusterBinding(clusterRoleName string) *ClusterRoleBindingBuilder { func NewClusterBinding(clusterRoleName string) *ClusterRoleBindingBuilder {
return &ClusterRoleBindingBuilder{ return &ClusterRoleBindingBuilder{
ClusterRoleBinding: ClusterRoleBinding{ ClusterRoleBinding: ClusterRoleBinding{
ObjectMeta: api.ObjectMeta{Name: clusterRoleName}, ObjectMeta: metav1.ObjectMeta{Name: clusterRoleName},
RoleRef: RoleRef{ RoleRef: RoleRef{
APIGroup: GroupName, APIGroup: GroupName,
Kind: "ClusterRole", Kind: "ClusterRole",

View File

@ -19,7 +19,6 @@ package rbac
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/api"
) )
// Authorization is calculated against // Authorization is calculated against
@ -94,7 +93,7 @@ type RoleRef struct {
type Role struct { type Role struct {
metav1.TypeMeta metav1.TypeMeta
// Standard object's metadata. // Standard object's metadata.
api.ObjectMeta metav1.ObjectMeta
// Rules holds all the PolicyRules for this Role // Rules holds all the PolicyRules for this Role
Rules []PolicyRule Rules []PolicyRule
@ -107,7 +106,7 @@ type Role struct {
// namespace only have effect in that namespace. // namespace only have effect in that namespace.
type RoleBinding struct { type RoleBinding struct {
metav1.TypeMeta metav1.TypeMeta
api.ObjectMeta metav1.ObjectMeta
// Subjects holds references to the objects the role applies to. // Subjects holds references to the objects the role applies to.
Subjects []Subject Subjects []Subject
@ -144,7 +143,7 @@ type RoleList struct {
type ClusterRole struct { type ClusterRole struct {
metav1.TypeMeta metav1.TypeMeta
// Standard object's metadata. // Standard object's metadata.
api.ObjectMeta metav1.ObjectMeta
// Rules holds all the PolicyRules for this ClusterRole // Rules holds all the PolicyRules for this ClusterRole
Rules []PolicyRule Rules []PolicyRule
@ -158,7 +157,7 @@ type ClusterRole struct {
type ClusterRoleBinding struct { type ClusterRoleBinding struct {
metav1.TypeMeta metav1.TypeMeta
// Standard object's metadata. // Standard object's metadata.
api.ObjectMeta metav1.ObjectMeta
// Subjects holds references to the objects the role applies to. // Subjects holds references to the objects the role applies to.
Subjects []Subject Subjects []Subject

View File

@ -19,7 +19,7 @@ package v1alpha1
import ( import (
"fmt" "fmt"
"k8s.io/kubernetes/pkg/api/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// +k8s:deepcopy-gen=false // +k8s:deepcopy-gen=false

View File

@ -19,7 +19,6 @@ package v1alpha1
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/api/v1"
) )
// Authorization is calculated against // Authorization is calculated against
@ -106,7 +105,7 @@ type Role struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object's metadata. // Standard object's metadata.
// +optional // +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 holds all the PolicyRules for this Role
Rules []PolicyRule `json:"rules" protobuf:"bytes,2,rep,name=rules"` Rules []PolicyRule `json:"rules" protobuf:"bytes,2,rep,name=rules"`
@ -121,7 +120,7 @@ type RoleBinding struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object's metadata. // Standard object's metadata.
// +optional // +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 holds references to the objects the role applies to.
Subjects []Subject `json:"subjects" protobuf:"bytes,2,rep,name=subjects"` Subjects []Subject `json:"subjects" protobuf:"bytes,2,rep,name=subjects"`
@ -161,7 +160,7 @@ type ClusterRole struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object's metadata. // Standard object's metadata.
// +optional // +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 holds all the PolicyRules for this ClusterRole
Rules []PolicyRule `json:"rules" protobuf:"bytes,2,rep,name=rules"` Rules []PolicyRule `json:"rules" protobuf:"bytes,2,rep,name=rules"`
@ -176,7 +175,7 @@ type ClusterRoleBinding struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// Standard object's metadata. // Standard object's metadata.
// +optional // +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 holds references to the objects the role applies to.
Subjects []Subject `json:"subjects" protobuf:"bytes,2,rep,name=subjects"` Subjects []Subject `json:"subjects" protobuf:"bytes,2,rep,name=subjects"`

View File

@ -19,6 +19,7 @@ package validation
import ( import (
"testing" "testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/rbac"

View File

@ -33,7 +33,7 @@ import (
type StorageClass struct { type StorageClass struct {
metav1.TypeMeta metav1.TypeMeta
// +optional // +optional
api.ObjectMeta metav1.ObjectMeta
// provisioner is the driver expected to handle this StorageClass. // provisioner is the driver expected to handle this StorageClass.
// This is an optionally-prefixed name, like a label key. // This is an optionally-prefixed name, like a label key.

View File

@ -18,6 +18,7 @@ package util
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// IsDefaultStorageClassAnnotation represents a StorageClass annotation that // IsDefaultStorageClassAnnotation represents a StorageClass annotation that

View File

@ -18,7 +18,6 @@ package v1beta1
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api/v1"
) )
// +genclient=true // +genclient=true
@ -34,7 +33,7 @@ type StorageClass struct {
// Standard object's metadata. // Standard object's metadata.
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
// +optional // +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 indicates the type of the provisioner.
Provisioner string `json:"provisioner" protobuf:"bytes,2,opt,name=provisioner"` Provisioner string `json:"provisioner" protobuf:"bytes,2,opt,name=provisioner"`

View File

@ -16,7 +16,10 @@ limitations under the License.
package util 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 // IsDefaultStorageClassAnnotation represents a StorageClass annotation that
// marks a class as the default StorageClass // marks a class as the default StorageClass

View File

@ -20,7 +20,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"k8s.io/kubernetes/pkg/api" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/apis/storage" "k8s.io/kubernetes/pkg/apis/storage"
) )

View File

@ -20,6 +20,7 @@ import (
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/api/v1"
@ -183,7 +184,7 @@ func (s *StoreToReplicationControllerLister) GetPodControllers(pod *v1.Pod) (con
return 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) items, err := s.Indexer.Index(NamespaceIndex, key)
if err != nil { if err != nil {
return return

View File

@ -20,6 +20,7 @@ package internalversion
import ( import (
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
api "k8s.io/kubernetes/pkg/api" api "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"

View File

@ -20,6 +20,7 @@ package internalversion
import ( import (
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
api "k8s.io/kubernetes/pkg/api" api "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"

View File

@ -20,6 +20,7 @@ package internalversion
import ( import (
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
api "k8s.io/kubernetes/pkg/api" api "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"

View File

@ -20,6 +20,7 @@ package internalversion
import ( import (
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
api "k8s.io/kubernetes/pkg/api" api "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"

View File

@ -23,6 +23,7 @@ import (
"sync" "sync"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch" "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) 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()} 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 { if err := meta.SetList(listObj, list); err != nil {
return nil, err return nil, err
} }
objMeta, err := api.ListMetaFor(listObj) objMeta, err := metav1.ListMetaFor(listObj)
if err != nil { if err != nil {
return nil, err 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 { if err := meta.SetList(listObj, list); err != nil {
return nil, err return nil, err
} }
objMeta, err := api.ListMetaFor(listObj) objMeta, err := metav1.ListMetaFor(listObj)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -215,7 +216,7 @@ func (f *FakePVCControllerSource) List(options v1.ListOptions) (runtime.Object,
if err := meta.SetList(listObj, list); err != nil { if err := meta.SetList(listObj, list); err != nil {
return nil, err return nil, err
} }
objMeta, err := api.ListMetaFor(listObj) objMeta, err := metav1.ListMetaFor(listObj)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -24,6 +24,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
"github.com/robfig/cron" "github.com/robfig/cron"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"

View File

@ -127,7 +127,7 @@ func newPod(podName string, nodeName string, label map[string]string) *v1.Pod {
DNSPolicy: v1.DNSDefault, DNSPolicy: v1.DNSDefault,
}, },
} }
v1.GenerateName(v1.SimpleNameGenerator, &pod.ObjectMeta) metav1.GenerateName(v1.SimpleNameGenerator, &pod.ObjectMeta)
return pod return pod
} }

View File

@ -212,7 +212,7 @@ func referencesDiffs(old []metav1.OwnerReference, new []metav1.OwnerReference) (
return added, removed 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 // The delta_fifo may combine the creation and update of the object into one
// event, so we need to check AddEvent as well. // event, so we need to check AddEvent as well.
if e.oldObj == nil { if e.oldObj == nil {

View File

@ -18,7 +18,6 @@ package metaonly
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 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 // MetadataOnlyObject allows decoding only the apiVersion, kind, and metadata fields of
@ -27,7 +26,7 @@ import (
type MetadataOnlyObject struct { type MetadataOnlyObject struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +optional
v1.ObjectMeta `json:"metadata,omitempty"` metav1.ObjectMeta `json:"metadata,omitempty"`
} }
// MetadataOnlyObjectList allows decoding from JSON data only the typemeta and metadata of // MetadataOnlyObjectList allows decoding from JSON data only the typemeta and metadata of

View File

@ -21,12 +21,12 @@ import (
"sync" "sync"
"github.com/golang/groupcache/lru" "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" hashutil "k8s.io/kubernetes/pkg/util/hash"
) )
type objectWithMeta interface { 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. // keyFunc returns the key of an object, which is used to look up in the cache for it's matching object.

View File

@ -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)")
}

View File

@ -134,7 +134,7 @@ func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *v1.PersistentVol
// with existing PVs, findByClaim must find only PVs that are // with existing PVs, findByClaim must find only PVs that are
// pre-bound to the claim (by dynamic provisioning). TODO: remove in // pre-bound to the claim (by dynamic provisioning). TODO: remove in
// 1.5 // 1.5
if v1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) { if metav1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) {
continue continue
} }

View File

@ -218,7 +218,7 @@ type PersistentVolumeController struct {
func (ctrl *PersistentVolumeController) syncClaim(claim *v1.PersistentVolumeClaim) error { func (ctrl *PersistentVolumeController) syncClaim(claim *v1.PersistentVolumeClaim) error {
glog.V(4).Infof("synchronizing PersistentVolumeClaim[%s]: %s", claimToClaimKey(claim), getClaimStatusForLogging(claim)) 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) return ctrl.syncUnboundClaim(claim)
} else { } else {
return ctrl.syncBoundClaim(claim) 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)) glog.V(4).Infof("synchronizing unbound PersistentVolumeClaim[%s]: no volume found", claimToClaimKey(claim))
// No PV could be found // No PV could be found
// OBSERVATION: pvc is "Pending", will retry // 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 { if err = ctrl.provisionClaim(claim); err != nil {
return err return err
} }
@ -315,7 +315,7 @@ func (ctrl *PersistentVolumeController) syncUnboundClaim(claim *v1.PersistentVol
} else { } else {
// User asked for a PV that is claimed by someone else // User asked for a PV that is claimed by someone else
// OBSERVATION: pvc is "Pending", pv is "Bound" // 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)) 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 // User asked for a specific PV, retry later
if _, err = ctrl.updateClaimStatus(claim, v1.ClaimPending, nil); err != nil { if _, err = ctrl.updateClaimStatus(claim, v1.ClaimPending, nil); err != nil {
@ -480,7 +480,7 @@ func (ctrl *PersistentVolumeController) syncVolume(volume *v1.PersistentVolume)
} }
return nil return nil
} else if claim.Spec.VolumeName == "" { } 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 // 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) glog.V(4).Infof("synchronizing PersistentVolume[%s]: volume not bound yet, waiting for syncClaim to fix it", volume.Name)
} else { } else {
@ -507,7 +507,7 @@ func (ctrl *PersistentVolumeController) syncVolume(volume *v1.PersistentVolume)
return nil return nil
} else { } else {
// Volume is bound to a claim, but the claim is bound elsewhere // 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 // This volume was dynamically provisioned for this claim. The
// claim got bound elsewhere, and thus this volume is not // claim got bound elsewhere, and thus this volume is not
// needed. Delete it. // needed. Delete it.
@ -531,7 +531,7 @@ func (ctrl *PersistentVolumeController) syncVolume(volume *v1.PersistentVolume)
} else { } else {
// Volume is bound to a claim, but the claim is bound elsewhere // Volume is bound to a claim, but the claim is bound elsewhere
// and it's not dynamically provisioned. // 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 // This is part of the normal operation of the controller; the
// controller tried to use this volume for a claim but the claim // controller tried to use this volume for a claim but the claim
// was fulfilled by another volume. We did this; fix it. // 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 // Set annBoundByController if it is not set yet
if shouldSetBoundByController && !v1.HasAnnotation(volumeClone.ObjectMeta, annBoundByController) { if shouldSetBoundByController && !metav1.HasAnnotation(volumeClone.ObjectMeta, annBoundByController) {
v1.SetMetaDataAnnotation(&volumeClone.ObjectMeta, annBoundByController, "yes") metav1.SetMetaDataAnnotation(&volumeClone.ObjectMeta, annBoundByController, "yes")
dirty = true dirty = true
} }
@ -812,14 +812,14 @@ func (ctrl *PersistentVolumeController) bindClaimToVolume(claim *v1.PersistentVo
} }
// Set annBoundByController if it is not set yet // Set annBoundByController if it is not set yet
if shouldSetBoundByController && !v1.HasAnnotation(claimClone.ObjectMeta, annBoundByController) { if shouldSetBoundByController && !metav1.HasAnnotation(claimClone.ObjectMeta, annBoundByController) {
v1.SetMetaDataAnnotation(&claimClone.ObjectMeta, annBoundByController, "yes") metav1.SetMetaDataAnnotation(&claimClone.ObjectMeta, annBoundByController, "yes")
dirty = true dirty = true
} }
// Set annBindCompleted if it is not set yet // Set annBindCompleted if it is not set yet
if !v1.HasAnnotation(claimClone.ObjectMeta, annBindCompleted) { if !metav1.HasAnnotation(claimClone.ObjectMeta, annBindCompleted) {
v1.SetMetaDataAnnotation(&claimClone.ObjectMeta, annBindCompleted, "yes") metav1.SetMetaDataAnnotation(&claimClone.ObjectMeta, annBindCompleted, "yes")
dirty = true dirty = true
} }
@ -905,7 +905,7 @@ func (ctrl *PersistentVolumeController) unbindVolume(volume *v1.PersistentVolume
return fmt.Errorf("Unexpected volume cast error : %v", volumeClone) 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. // The volume was bound by the controller.
volumeClone.Spec.ClaimRef = nil volumeClone.Spec.ClaimRef = nil
delete(volumeClone.Annotations, annBoundByController) delete(volumeClone.Annotations, annBoundByController)
@ -1335,13 +1335,13 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa
volume.Status.Phase = v1.VolumeBound volume.Status.Phase = v1.VolumeBound
// Add annBoundByController (used in deleting the volume) // Add annBoundByController (used in deleting the volume)
v1.SetMetaDataAnnotation(&volume.ObjectMeta, annBoundByController, "yes") metav1.SetMetaDataAnnotation(&volume.ObjectMeta, annBoundByController, "yes")
v1.SetMetaDataAnnotation(&volume.ObjectMeta, annDynamicallyProvisioned, plugin.GetPluginName()) metav1.SetMetaDataAnnotation(&volume.ObjectMeta, annDynamicallyProvisioned, plugin.GetPluginName())
// For Alpha provisioning behavior, do not add storage.BetaStorageClassAnnotations for volumes created // For Alpha provisioning behavior, do not add storage.BetaStorageClassAnnotations for volumes created
// by storage.AlphaStorageClassAnnotation // by storage.AlphaStorageClassAnnotation
// TODO: remove this check in 1.5, storage.StorageClassAnnotation will be always non-empty there. // TODO: remove this check in 1.5, storage.StorageClassAnnotation will be always non-empty there.
if claimClass != "" { if claimClass != "" {
v1.SetMetaDataAnnotation(&volume.ObjectMeta, storageutil.StorageClassAnnotation, claimClass) metav1.SetMetaDataAnnotation(&volume.ObjectMeta, storageutil.StorageClassAnnotation, claimClass)
} }
// Try to create the PV object several times // Try to create the PV object several times
@ -1445,8 +1445,8 @@ func (ctrl *PersistentVolumeController) newRecyclerEventRecorder(volume *v1.Pers
// provisioner is requested. // provisioner is requested.
func (ctrl *PersistentVolumeController) findProvisionablePlugin(claim *v1.PersistentVolumeClaim) (vol.ProvisionableVolumePlugin, *storage.StorageClass, error) { func (ctrl *PersistentVolumeController) findProvisionablePlugin(claim *v1.PersistentVolumeClaim) (vol.ProvisionableVolumePlugin, *storage.StorageClass, error) {
// TODO: remove this alpha behavior in 1.5 // TODO: remove this alpha behavior in 1.5
alpha := v1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) alpha := metav1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation)
beta := v1.HasAnnotation(claim.ObjectMeta, storageutil.BetaStorageClassAnnotation) beta := metav1.HasAnnotation(claim.ObjectMeta, storageutil.BetaStorageClassAnnotation)
if alpha && beta { if alpha && beta {
// Both Alpha and Beta annotations are set. Do beta. // Both Alpha and Beta annotations are set. Do beta.
alpha = false alpha = false
@ -1512,7 +1512,7 @@ func (ctrl *PersistentVolumeController) findAlphaProvisionablePlugin() (vol.Prov
func (ctrl *PersistentVolumeController) findDeletablePlugin(volume *v1.PersistentVolume) (vol.DeletableVolumePlugin, error) { func (ctrl *PersistentVolumeController) findDeletablePlugin(volume *v1.PersistentVolume) (vol.DeletableVolumePlugin, error) {
// Find a plugin. Try to find the same plugin that provisioned the volume // Find a plugin. Try to find the same plugin that provisioned the volume
var plugin vol.DeletableVolumePlugin var plugin vol.DeletableVolumePlugin
if v1.HasAnnotation(volume.ObjectMeta, annDynamicallyProvisioned) { if metav1.HasAnnotation(volume.ObjectMeta, annDynamicallyProvisioned) {
provisionPluginName := volume.Annotations[annDynamicallyProvisioned] provisionPluginName := volume.Annotations[annDynamicallyProvisioned]
if provisionPluginName != "" { if provisionPluginName != "" {
plugin, err := ctrl.volumePluginMgr.FindDeletablePluginByName(provisionPluginName) plugin, err := ctrl.volumePluginMgr.FindDeletablePluginByName(provisionPluginName)

View File

@ -510,7 +510,7 @@ func (ctrl *PersistentVolumeController) setClaimProvisioner(claim *v1.Persistent
if !ok { if !ok {
return nil, fmt.Errorf("Unexpected claim cast error : %v", claimClone) 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) newClaim, err := ctrl.kubeClient.Core().PersistentVolumeClaims(claim.Namespace).Update(claimClone)
if err != nil { if err != nil {
return newClaim, err return newClaim, err
@ -525,14 +525,14 @@ func (ctrl *PersistentVolumeController) setClaimProvisioner(claim *v1.Persistent
// Stateless functions // Stateless functions
func getClaimStatusForLogging(claim *v1.PersistentVolumeClaim) string { func getClaimStatusForLogging(claim *v1.PersistentVolumeClaim) string {
bound := v1.HasAnnotation(claim.ObjectMeta, annBindCompleted) bound := metav1.HasAnnotation(claim.ObjectMeta, annBindCompleted)
boundByController := v1.HasAnnotation(claim.ObjectMeta, annBoundByController) 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) 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 { func getVolumeStatusForLogging(volume *v1.PersistentVolume) string {
boundByController := v1.HasAnnotation(volume.ObjectMeta, annBoundByController) boundByController := metav1.HasAnnotation(volume.ObjectMeta, annBoundByController)
claimName := "" claimName := ""
if volume.Spec.ClaimRef != nil { if volume.Spec.ClaimRef != nil {
claimName = fmt.Sprintf("%s/%s (uid: %s)", volume.Spec.ClaimRef.Namespace, volume.Spec.ClaimRef.Name, volume.Spec.ClaimRef.UID) claimName = fmt.Sprintf("%s/%s (uid: %s)", volume.Spec.ClaimRef.Namespace, volume.Spec.ClaimRef.Name, volume.Spec.ClaimRef.UID)

View File

@ -18,6 +18,7 @@ package rest
import ( import (
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"

View File

@ -19,12 +19,11 @@ package rest
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
genericapirequest "k8s.io/apiserver/pkg/request" genericapirequest "k8s.io/apiserver/pkg/request"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util/uuid" "k8s.io/kubernetes/pkg/util/uuid"
) )
// FillObjectMetaSystemFields populates fields that are managed by the system on ObjectMeta. // 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() meta.CreationTimestamp = metav1.Now()
// allows admission controllers to assign a UID earlier in the request processing // allows admission controllers to assign a UID earlier in the request processing
// to support tracking resources pending creation. // 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. // 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 // 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) ns, ok := genericapirequest.NamespaceFrom(ctx)
if len(resource.Namespace) == 0 { if len(resource.Namespace) == 0 {
resource.Namespace = ns resource.Namespace = ns

View File

@ -21,6 +21,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest "k8s.io/apiserver/pkg/request" genericapirequest "k8s.io/apiserver/pkg/request"

View File

@ -24,7 +24,7 @@ import (
type Simple struct { type Simple struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
apiv1.ObjectMeta `json:"metadata"` metav1.ObjectMeta `json:"metadata"`
// +optional // +optional
Other string `json:"other,omitempty"` Other string `json:"other,omitempty"`
// +optional // +optional
@ -35,7 +35,7 @@ func (obj *Simple) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
type SimpleRoot struct { type SimpleRoot struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
apiv1.ObjectMeta `json:"metadata"` metav1.ObjectMeta `json:"metadata"`
// +optional // +optional
Other string `json:"other,omitempty"` Other string `json:"other,omitempty"`
// +optional // +optional

View File

@ -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) // 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 var buf bytes.Buffer
for key := range annotations { for key := range annotations {
// change-cause annotation can always be overwritten // change-cause annotation can always be overwritten

View File

@ -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{} allErrs := []error{}
for key := range labels { for key := range labels {
if value, found := accessor.GetLabels()[key]; found { if value, found := accessor.GetLabels()[key]; found {

View File

@ -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, // 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. // 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...) newTaints := append([]api.Taint{}, taintsToAdd...)
var oldTaints []api.Taint 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) // 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() annotations := accessor.GetAnnotations()
if annotations == nil { if annotations == nil {
return nil return nil

View File

@ -22,7 +22,6 @@ import (
"time" "time"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
@ -138,7 +137,7 @@ type StatefulSetReaper struct {
type objInterface interface { type objInterface interface {
Delete(name string) error 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. // getOverlappingControllers finds rcs that this controller overlaps, as well as rcs overlapping this controller.

View File

@ -25,7 +25,7 @@ import (
type TestStruct struct { type TestStruct struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
// +optional // +optional
apiv1.ObjectMeta `json:"metadata,omitempty"` metav1.ObjectMeta `json:"metadata,omitempty"`
Key string `json:"Key"` Key string `json:"Key"`
Map map[string]int `json:"Map"` Map map[string]int `json:"Map"`
StringList []string `json:"StringList"` StringList []string `json:"StringList"`

View File

@ -479,13 +479,7 @@ func encodeToJSON(obj *extensions.ThirdPartyResourceData, stream io.Writer) erro
return fmt.Errorf("unexpected type: %v", objOut) return fmt.Errorf("unexpected type: %v", objOut)
} }
// Convert to a serializable type objMap["metadata"] = &obj.ObjectMeta
versionedObjectMeta := &v1.ObjectMeta{}
if err := v1.Convert_api_ObjectMeta_To_v1_ObjectMeta(&obj.ObjectMeta, versionedObjectMeta, nil); err != nil {
return err
}
objMap["metadata"] = versionedObjectMeta
encoder := json.NewEncoder(stream) encoder := json.NewEncoder(stream)
return encoder.Encode(objMap) return encoder.Encode(objMap)
} }

View File

@ -481,7 +481,7 @@ var (
// When deciding whether to add the OrphanDependent finalizer, factors in the // When deciding whether to add the OrphanDependent finalizer, factors in the
// order of highest to lowest priority are: options.OrphanDependents, existing // order of highest to lowest priority are: options.OrphanDependents, existing
// finalizers of the object, e.DeleteStrategy.DefaultGarbageCollectionPolicy. // 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 shouldOrphan := false
// Get default orphan policy from this REST object type // Get default orphan policy from this REST object type
if gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy); ok { 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 return ttl, err
} }
func exportObjectMeta(accessor meta.Object, exact bool) { func exportObjectMeta(accessor metav1.Object, exact bool) {
accessor.SetUID("") accessor.SetUID("")
if !exact { if !exact {
accessor.SetNamespace("") accessor.SetNamespace("")

View File

@ -25,7 +25,7 @@ import (
"k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apiserver/pkg/authentication/user" "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" "k8s.io/kubernetes/pkg/apis/rbac"
) )

View File

@ -45,7 +45,7 @@ func (a APIObjectVersioner) UpdateObject(obj runtime.Object, resourceVersion uin
// UpdateList implements Versioner // UpdateList implements Versioner
func (a APIObjectVersioner) UpdateList(obj runtime.Object, resourceVersion uint64) error { 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 { if err != nil || listMeta == nil {
return err return err
} }

View File

@ -24,7 +24,7 @@ import (
type TestResource struct { type TestResource struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
apiv1.ObjectMeta `json:"metadata"` metav1.ObjectMeta `json:"metadata"`
Value int `json:"value"` Value int `json:"value"`
} }

View File

@ -23,6 +23,7 @@ import (
"sync" "sync"
"github.com/golang/glog" "github.com/golang/glog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
utilerrors "k8s.io/apimachinery/pkg/util/errors" utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation"

View File

@ -36,7 +36,6 @@ import (
apierrors "k8s.io/client-go/pkg/api/errors" apierrors "k8s.io/client-go/pkg/api/errors"
"k8s.io/client-go/pkg/apis/imagepolicy/v1alpha1" "k8s.io/client-go/pkg/apis/imagepolicy/v1alpha1"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/admission" "k8s.io/kubernetes/pkg/admission"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"

View File

@ -172,7 +172,7 @@ func TestAdmitSeccomp(t *testing.T) {
psp := restrictivePSP() psp := restrictivePSP()
psp.Annotations = v.pspAnnotations psp.Annotations = v.pspAnnotations
pod := &kapi.Pod{ pod := &kapi.Pod{
ObjectMeta: kapi.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Annotations: v.podAnnotations, Annotations: v.podAnnotations,
}, },
Spec: kapi.PodSpec{ Spec: kapi.PodSpec{
@ -1457,7 +1457,7 @@ func TestCreateProvidersFromConstraints(t *testing.T) {
"valid psp": { "valid psp": {
psp: func() *extensions.PodSecurityPolicy { psp: func() *extensions.PodSecurityPolicy {
return &extensions.PodSecurityPolicy{ return &extensions.PodSecurityPolicy{
ObjectMeta: kapi.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "valid psp", Name: "valid psp",
}, },
Spec: extensions.PodSecurityPolicySpec{ Spec: extensions.PodSecurityPolicySpec{
@ -1480,7 +1480,7 @@ func TestCreateProvidersFromConstraints(t *testing.T) {
"bad psp strategy options": { "bad psp strategy options": {
psp: func() *extensions.PodSecurityPolicy { psp: func() *extensions.PodSecurityPolicy {
return &extensions.PodSecurityPolicy{ return &extensions.PodSecurityPolicy{
ObjectMeta: kapi.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "bad psp user options", Name: "bad psp user options",
}, },
Spec: extensions.PodSecurityPolicySpec{ Spec: extensions.PodSecurityPolicySpec{
@ -1650,7 +1650,7 @@ func TestGetMatchingPolicies(t *testing.T) {
func restrictivePSP() *extensions.PodSecurityPolicy { func restrictivePSP() *extensions.PodSecurityPolicy {
return &extensions.PodSecurityPolicy{ return &extensions.PodSecurityPolicy{
ObjectMeta: kapi.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "restrictive", Name: "restrictive",
Annotations: map[string]string{}, Annotations: map[string]string{},
}, },
@ -1685,7 +1685,7 @@ func restrictivePSP() *extensions.PodSecurityPolicy {
func createNamespaceForTest() *kapi.Namespace { func createNamespaceForTest() *kapi.Namespace {
return &kapi.Namespace{ return &kapi.Namespace{
ObjectMeta: kapi.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "default", Name: "default",
}, },
} }
@ -1693,7 +1693,7 @@ func createNamespaceForTest() *kapi.Namespace {
func createSAForTest() *kapi.ServiceAccount { func createSAForTest() *kapi.ServiceAccount {
return &kapi.ServiceAccount{ return &kapi.ServiceAccount{
ObjectMeta: kapi.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Namespace: "default", Namespace: "default",
Name: "default", Name: "default",
}, },
@ -1705,7 +1705,7 @@ func createSAForTest() *kapi.ServiceAccount {
// psp when defaults are filled in. // psp when defaults are filled in.
func goodPod() *kapi.Pod { func goodPod() *kapi.Pod {
return &kapi.Pod{ return &kapi.Pod{
ObjectMeta: kapi.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{}, Annotations: map[string]string{},
}, },
Spec: kapi.PodSpec{ Spec: kapi.PodSpec{

View File

@ -21,7 +21,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/pkg/api" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
rbac "k8s.io/kubernetes/pkg/apis/rbac" rbac "k8s.io/kubernetes/pkg/apis/rbac"
) )

View File

@ -18,7 +18,7 @@ package bootstrappolicy
import ( import (
"k8s.io/apiserver/pkg/authentication/user" "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" rbac "k8s.io/kubernetes/pkg/apis/rbac"
) )

View File

@ -18,7 +18,6 @@ package meta
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 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"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
@ -30,46 +29,6 @@ type VersionInterfaces struct {
MetadataAccessor 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 { type ListMetaAccessor interface {
GetListMeta() List GetListMeta() List
} }

View File

@ -20,13 +20,13 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"github.com/golang/glog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion" "k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types" "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 // 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 m, nil
} }
return nil, errNotList return nil, errNotList
case Object: case metav1.Object:
return t, nil return t, nil
case ObjectMetaAccessor: case metav1.ObjectMetaAccessor:
if m := t.GetObjectMeta(); m != nil { if m := t.GetObjectMeta(); m != nil {
return 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 // required fields are missing. Fields that are not required return the default
// value and are a no-op if set. // value and are a no-op if set.
// TODO: return bool instead of error // TODO: return bool instead of error
func Accessor(obj interface{}) (Object, error) { func Accessor(obj interface{}) (metav1.Object, error) {
switch t := obj.(type) { switch t := obj.(type) {
case Object: case metav1.Object:
return t, nil return t, nil
case ObjectMetaAccessor: case metav1.ObjectMetaAccessor:
if m := t.GetObjectMeta(); m != nil { if m := t.GetObjectMeta(); m != nil {
return m, nil return m, nil
} }

View File

@ -181,3 +181,17 @@ func ExtractGroupVersions(l *APIGroupList) []string {
} }
return groupVersions 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
}

View File

@ -17,11 +17,78 @@ limitations under the License.
package v1 package v1
import ( import (
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "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 // ListMetaAccessor retrieves the list interface from an object
// TODO: move this, and TypeMeta and ListMeta, to a different package
type ListMetaAccessor interface { type ListMetaAccessor interface {
GetListMeta() List GetListMeta() List
} }
@ -64,3 +131,71 @@ func (obj *TypeMeta) GroupVersionKind() schema.GroupVersionKind {
} }
func (obj *ListMeta) GetListMeta() List { return obj } 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
}

View File

@ -48,6 +48,7 @@ type Unstructured struct {
Object map[string]interface{} Object map[string]interface{}
} }
var _ metav1.Object = &Unstructured{}
var _ runtime.Unstructured = &Unstructured{} var _ runtime.Unstructured = &Unstructured{}
var _ runtime.Unstructured = &UnstructuredList{} var _ runtime.Unstructured = &UnstructuredList{}

Some files were not shown because too many files have changed in this diff Show More