Rename JSONBase -> TypeMeta in preparation for v1beta3

Will make subsequent refactor much easier
pull/6/head
Clayton Coleman 2014-10-07 11:12:16 -04:00
parent e294cef9d4
commit d3e51a0f24
69 changed files with 464 additions and 464 deletions

View File

@ -244,7 +244,7 @@ func runAtomicPutTest(c *client.Client) {
var svc api.Service
err := c.Post().Path("services").Body(
&api.Service{
JSONBase: api.JSONBase{ID: "atomicservice", APIVersion: latest.Version},
TypeMeta: api.TypeMeta{ID: "atomicservice", APIVersion: latest.Version},
Port: 12345,
Labels: map[string]string{
"name": "atomicService",
@ -318,7 +318,7 @@ func runAtomicPutTest(c *client.Client) {
func runServiceTest(client *client.Client) {
ctx := api.NewDefaultContext()
pod := api.Pod{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
DesiredState: api.PodState{
Manifest: api.ContainerManifest{
Version: "v1beta1",
@ -348,7 +348,7 @@ func runServiceTest(client *client.Client) {
glog.Fatalf("FAILED: pod never started running %v", err)
}
svc := api.Service{
JSONBase: api.JSONBase{ID: "service1"},
TypeMeta: api.TypeMeta{ID: "service1"},
Selector: map[string]string{
"name": "thisisalonglabel",
},

View File

@ -342,7 +342,7 @@ func executeAPIRequest(ctx api.Context, method string, c *client.Client) bool {
if err != nil {
glog.Fatalf("error obtaining resource version for update: %v", err)
}
jsonBase, err := runtime.FindJSONBase(obj)
jsonBase, err := runtime.FindTypeMeta(obj)
if err != nil {
glog.Fatalf("error finding json base for update: %v", err)
}
@ -375,7 +375,7 @@ func executeAPIRequest(ctx api.Context, method string, c *client.Client) bool {
if err != nil {
glog.Fatalf("error setting resource version: %v", err)
}
jsonBase, err := runtime.FindJSONBase(obj)
jsonBase, err := runtime.FindTypeMeta(obj)
if err != nil {
glog.Fatalf("error setting resource version: %v", err)
}

View File

@ -41,14 +41,14 @@ func validateObject(obj runtime.Object) (errors []error) {
errors = append(errors, validateObject(&t.Items[i])...)
}
case *api.Service:
api.ValidNamespace(ctx, &t.JSONBase)
api.ValidNamespace(ctx, &t.TypeMeta)
errors = validation.ValidateService(t)
case *api.ServiceList:
for i := range t.Items {
errors = append(errors, validateObject(&t.Items[i])...)
}
case *api.Pod:
api.ValidNamespace(ctx, &t.JSONBase)
api.ValidNamespace(ctx, &t.TypeMeta)
errors = validation.ValidateManifest(&t.DesiredState.Manifest)
case *api.PodList:
for i := range t.Items {

View File

@ -64,7 +64,7 @@ func NamespaceFrom(ctx Context) (string, bool) {
}
// 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.
func ValidNamespace(ctx Context, resource *JSONBase) bool {
func ValidNamespace(ctx Context, resource *TypeMeta) bool {
ns, ok := NamespaceFrom(ctx)
if len(resource.Namespace) == 0 {
resource.Namespace = ns

View File

@ -45,18 +45,18 @@ func TestValidNamespace(t *testing.T) {
ctx := api.NewDefaultContext()
namespace, _ := api.NamespaceFrom(ctx)
resource := api.ReplicationController{}
if !api.ValidNamespace(ctx, &resource.JSONBase) {
if !api.ValidNamespace(ctx, &resource.TypeMeta) {
t.Errorf("expected success")
}
if namespace != resource.Namespace {
t.Errorf("expected resource to have the default namespace assigned during validation")
}
resource = api.ReplicationController{JSONBase: api.JSONBase{Namespace: "other"}}
if api.ValidNamespace(ctx, &resource.JSONBase) {
resource = api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "other"}}
if api.ValidNamespace(ctx, &resource.TypeMeta) {
t.Errorf("Expected error that resource and context errors do not match because resource has different namespace")
}
ctx = api.NewContext()
if api.ValidNamespace(ctx, &resource.JSONBase) {
if api.ValidNamespace(ctx, &resource.TypeMeta) {
t.Errorf("Expected error that resource and context errors do not match since context has no namespace")
}
}

View File

@ -47,13 +47,13 @@ var Codec = v1beta1.Codec
// ResourceVersioner describes a default versioner that can handle all types
// of versioning.
// TODO: when versioning changes, make this part of each API definition.
var ResourceVersioner = runtime.NewJSONBaseResourceVersioner()
var ResourceVersioner = runtime.NewTypeMetaResourceVersioner()
// SelfLinker can set or get the SelfLink field of all API types.
// TODO: when versioning changes, make this part of each API definition.
// TODO(lavalamp): Combine SelfLinker & ResourceVersioner interfaces, force all uses
// to go through the InterfacesFor method below.
var SelfLinker = runtime.NewJSONBaseSelfLinker()
var SelfLinker = runtime.NewTypeMetaSelfLinker()
// VersionInterfaces contains the interfaces one should use for dealing with types of a particular version.
type VersionInterfaces struct {

View File

@ -32,8 +32,8 @@ import (
// apiObjectFuzzer can randomly populate api objects.
var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
func(j *internal.JSONBase, c fuzz.Continue) {
// We have to customize the randomization of JSONBases because their
func(j *internal.TypeMeta, c fuzz.Continue) {
// We have to customize the randomization of TypeMetas because their
// APIVersion and Kind must remain blank in memory.
j.APIVersion = ""
j.Kind = ""
@ -120,7 +120,7 @@ func TestInternalRoundTrip(t *testing.T) {
}
func TestResourceVersioner(t *testing.T) {
pod := internal.Pod{JSONBase: internal.JSONBase{ResourceVersion: 10}}
pod := internal.Pod{TypeMeta: internal.TypeMeta{ResourceVersion: 10}}
version, err := ResourceVersioner.ResourceVersion(&pod)
if err != nil {
t.Fatalf("unexpected error: %v", err)

View File

@ -29,7 +29,7 @@ var versionFromSelfLink = regexp.MustCompile("/api/([^/]*)/")
// object, or an error if the object doesn't follow the conventions
// that would allow this.
func GetReference(obj runtime.Object) (*ObjectReference, error) {
jsonBase, err := runtime.FindJSONBase(obj)
jsonBase, err := runtime.FindTypeMeta(obj)
if err != nil {
return nil, err
}
@ -44,7 +44,7 @@ func GetReference(obj runtime.Object) (*ObjectReference, error) {
return &ObjectReference{
Kind: kind,
APIVersion: version[1],
// TODO: correct Name and UID when JSONBase makes a distinction
// TODO: correct Name and UID when TypeMeta makes a distinction
Name: jsonBase.ID(),
UID: jsonBase.ID(),
ResourceVersion: jsonBase.ResourceVersion(),

View File

@ -35,7 +35,7 @@ func TestGetReference(t *testing.T) {
}{
"pod": {
obj: &Pod{
JSONBase: JSONBase{
TypeMeta: TypeMeta{
ID: "foo",
ResourceVersion: 42,
SelfLink: "/api/v1beta1/pods/foo",
@ -51,7 +51,7 @@ func TestGetReference(t *testing.T) {
},
"serviceList": {
obj: &ServiceList{
JSONBase: JSONBase{
TypeMeta: TypeMeta{
ID: "foo",
ResourceVersion: 42,
SelfLink: "/api/v1beta2/services",
@ -67,7 +67,7 @@ func TestGetReference(t *testing.T) {
},
"badSelfLink": {
obj: &ServiceList{
JSONBase: JSONBase{
TypeMeta: TypeMeta{
ID: "foo",
ResourceVersion: 42,
SelfLink: "v1beta2/services",

View File

@ -40,8 +40,8 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
func(j *runtime.PluginBase, c fuzz.Continue) {
// Do nothing; this struct has only a Kind field and it must stay blank in memory.
},
func(j *runtime.JSONBase, c fuzz.Continue) {
// We have to customize the randomization of JSONBases because their
func(j *runtime.TypeMeta, c fuzz.Continue) {
// We have to customize the randomization of TypeMetas because their
// APIVersion and Kind must remain blank in memory.
j.APIVersion = ""
j.Kind = ""
@ -57,8 +57,8 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
c.Fuzz(&nsec)
j.CreationTimestamp = util.Unix(sec, nsec).Rfc3339Copy()
},
func(j *api.JSONBase, c fuzz.Continue) {
// We have to customize the randomization of JSONBases because their
func(j *api.TypeMeta, c fuzz.Continue) {
// We have to customize the randomization of TypeMetas because their
// APIVersion and Kind must remain blank in memory.
j.APIVersion = ""
j.Kind = ""
@ -110,7 +110,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
func runTest(t *testing.T, codec runtime.Codec, source runtime.Object) {
name := reflect.TypeOf(source).Elem().Name()
apiObjectFuzzer.Fuzz(source)
j, err := runtime.FindJSONBase(source)
j, err := runtime.FindTypeMeta(source)
if err != nil {
t.Fatalf("Unexpected error %v for %#v", err, source)
}

View File

@ -66,7 +66,7 @@ type ContainerManifest struct {
// ContainerManifestList is used to communicate container manifests to kubelet.
type ContainerManifestList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"`
}
@ -265,8 +265,8 @@ type Lifecycle struct {
// The below types are used by kube_client and api_server.
// JSONBase is shared by all objects sent to, or returned from the client.
type JSONBase struct {
// TypeMeta is shared by all objects sent to, or returned from the client.
type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
@ -374,7 +374,7 @@ type PodState struct {
// PodList is a list of Pods.
type PodList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []Pod `json:"items" yaml:"items,omitempty"`
}
@ -382,7 +382,7 @@ func (*PodList) IsAnAPIObject() {}
// Pod is a collection of containers, used as either input (create, update) or as output (list, get).
type Pod struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
CurrentState PodState `json:"currentState,omitempty" yaml:"currentState,omitempty"`
@ -399,7 +399,7 @@ type ReplicationControllerState struct {
// ReplicationControllerList is a collection of replication controllers.
type ReplicationControllerList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []ReplicationController `json:"items,omitempty" yaml:"items,omitempty"`
}
@ -407,7 +407,7 @@ func (*ReplicationControllerList) IsAnAPIObject() {}
// ReplicationController represents the configuration of a replication controller.
type ReplicationController struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
DesiredState ReplicationControllerState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
CurrentState ReplicationControllerState `json:"currentState,omitempty" yaml:"currentState,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
@ -423,7 +423,7 @@ type PodTemplate struct {
// ServiceList holds a list of services.
type ServiceList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []Service `json:"items" yaml:"items"`
}
@ -433,7 +433,7 @@ func (*ServiceList) IsAnAPIObject() {}
// (for example 3306) that the proxy listens on, and the selector that determines which pods
// will answer requests sent through the proxy.
type Service struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// Required.
Port int `json:"port" yaml:"port"`
@ -457,7 +457,7 @@ func (*Service) IsAnAPIObject() {}
// Endpoints is a collection of endpoints that implement the actual service, for example:
// Name: "mysql", Endpoints: ["10.10.1.1:1909", "10.10.2.2:8834"]
type Endpoints struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Endpoints []string `json:"endpoints,omitempty" yaml:"endpoints,omitempty"`
}
@ -465,7 +465,7 @@ func (*Endpoints) IsAnAPIObject() {}
// EndpointsList is a list of endpoints.
type EndpointsList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []Endpoints `json:"items,omitempty" yaml:"items,omitempty"`
}
@ -484,9 +484,9 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString
// Minion is a worker node in Kubernetenes.
// The name of the minion according to etcd is in JSONBase.ID.
// The name of the minion according to etcd is in TypeMeta.ID.
type Minion struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// Queried from cloud provider, if available.
HostIP string `json:"hostIP,omitempty" yaml:"hostIP,omitempty"`
// Resources available on the node
@ -497,7 +497,7 @@ func (*Minion) IsAnAPIObject() {}
// MinionList is a list of minions.
type MinionList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []Minion `json:"items,omitempty" yaml:"items,omitempty"`
}
@ -505,7 +505,7 @@ func (*MinionList) IsAnAPIObject() {}
// Binding is written by a scheduler to cause a pod to be bound to a host.
type Binding struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
PodID string `json:"podID" yaml:"podID"`
Host string `json:"host" yaml:"host"`
}
@ -516,7 +516,7 @@ func (*Binding) IsAnAPIObject() {}
// TODO: this could go in apiserver, but I'm including it here so clients needn't
// import both.
type Status struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// One of: "Success", "Failure", "Working" (for operations not yet completed)
Status string `json:"status,omitempty" yaml:"status,omitempty"`
// A human-readable description of the status of this operation.
@ -670,14 +670,14 @@ const (
// ServerOp is an operation delivered to API clients.
type ServerOp struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
}
func (*ServerOp) IsAnAPIObject() {}
// ServerOpList is a list of operations, as delivered to API clients.
type ServerOpList struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
Items []ServerOp `yaml:"items,omitempty" json:"items,omitempty"`
}
@ -704,7 +704,7 @@ type ObjectReference struct {
// Event is a report of an event somewhere in the cluster.
// TODO: Decide whether to store these separately or with the object they apply to.
type Event struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
// Required. The object that this event is about.
InvolvedObject ObjectReference `json:"involvedObject,omitempty" yaml:"involvedObject,omitempty"`
@ -737,7 +737,7 @@ func (*Event) IsAnAPIObject() {}
// EventList is a list of events.
type EventList struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
Items []Event `yaml:"items,omitempty" json:"items,omitempty"`
}

View File

@ -62,13 +62,13 @@ func init() {
// MinionList.Items had a wrong name in v1beta1
func(in *newer.MinionList, out *MinionList, s conversion.Scope) error {
s.Convert(&in.JSONBase, &out.JSONBase, 0)
s.Convert(&in.TypeMeta, &out.TypeMeta, 0)
s.Convert(&in.Items, &out.Items, 0)
out.Minions = out.Items
return nil
},
func(in *MinionList, out *newer.MinionList, s conversion.Scope) error {
s.Convert(&in.JSONBase, &out.JSONBase, 0)
s.Convert(&in.TypeMeta, &out.TypeMeta, 0)
if len(in.Items) == 0 {
s.Convert(&in.Minions, &out.Items, 0)
} else {

View File

@ -116,10 +116,10 @@ func TestVolumeMountConversionToNew(t *testing.T) {
func TestMinionListConversionToNew(t *testing.T) {
oldMinion := func(id string) v1beta1.Minion {
return v1beta1.Minion{JSONBase: v1beta1.JSONBase{ID: id}}
return v1beta1.Minion{TypeMeta: v1beta1.TypeMeta{ID: id}}
}
newMinion := func(id string) newer.Minion {
return newer.Minion{JSONBase: newer.JSONBase{ID: id}}
return newer.Minion{TypeMeta: newer.TypeMeta{ID: id}}
}
oldMinions := []v1beta1.Minion{
oldMinion("foo"),
@ -163,10 +163,10 @@ func TestMinionListConversionToNew(t *testing.T) {
func TestMinionListConversionToOld(t *testing.T) {
oldMinion := func(id string) v1beta1.Minion {
return v1beta1.Minion{JSONBase: v1beta1.JSONBase{ID: id}}
return v1beta1.Minion{TypeMeta: v1beta1.TypeMeta{ID: id}}
}
newMinion := func(id string) newer.Minion {
return newer.Minion{JSONBase: newer.JSONBase{ID: id}}
return newer.Minion{TypeMeta: newer.TypeMeta{ID: id}}
}
oldMinions := []v1beta1.Minion{
oldMinion("foo"),

View File

@ -65,7 +65,7 @@ type ContainerManifest struct {
// ContainerManifestList is used to communicate container manifests to kubelet.
type ContainerManifestList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"`
}
@ -255,8 +255,8 @@ type Lifecycle struct {
// The below types are used by kube_client and api_server.
// JSONBase is shared by all objects sent to, or returned from the client.
type JSONBase struct {
// TypeMeta is shared by all objects sent to, or returned from the client.
type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
@ -266,7 +266,7 @@ type JSONBase struct {
Namespace string `json:"namespace",omitempty" yaml:"namespace,omitempty"`
}
func (*JSONBase) IsAnAPIObject() {}
func (*TypeMeta) IsAnAPIObject() {}
// PodStatus represents a status of a pod.
type PodStatus string
@ -359,7 +359,7 @@ type PodState struct {
// PodList is a list of Pods.
type PodList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []Pod `json:"items" yaml:"items,omitempty"`
}
@ -367,7 +367,7 @@ func (*PodList) IsAnAPIObject() {}
// Pod is a collection of containers, used as either input (create, update) or as output (list, get).
type Pod struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
CurrentState PodState `json:"currentState,omitempty" yaml:"currentState,omitempty"`
@ -384,7 +384,7 @@ type ReplicationControllerState struct {
// ReplicationControllerList is a collection of replication controllers.
type ReplicationControllerList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []ReplicationController `json:"items,omitempty" yaml:"items,omitempty"`
}
@ -392,7 +392,7 @@ func (*ReplicationControllerList) IsAnAPIObject() {}
// ReplicationController represents the configuration of a replication controller.
type ReplicationController struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
DesiredState ReplicationControllerState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
CurrentState ReplicationControllerState `json:"currentState,omitempty" yaml:"currentState,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
@ -408,7 +408,7 @@ type PodTemplate struct {
// ServiceList holds a list of services.
type ServiceList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []Service `json:"items" yaml:"items"`
}
@ -418,7 +418,7 @@ func (*ServiceList) IsAnAPIObject() {}
// (for example 3306) that the proxy listens on, and the selector that determines which pods
// will answer requests sent through the proxy.
type Service struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// Required.
Port int `json:"port" yaml:"port"`
@ -442,7 +442,7 @@ func (*Service) IsAnAPIObject() {}
// Endpoints is a collection of endpoints that implement the actual service, for example:
// Name: "mysql", Endpoints: ["10.10.1.1:1909", "10.10.2.2:8834"]
type Endpoints struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Endpoints []string `json:"endpoints,omitempty" yaml:"endpoints,omitempty"`
}
@ -450,7 +450,7 @@ func (*Endpoints) IsAnAPIObject() {}
// EndpointsList is a list of endpoints.
type EndpointsList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []Endpoints `json:"items,omitempty" yaml:"items,omitempty"`
}
@ -468,9 +468,9 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString
// Minion is a worker node in Kubernetenes.
// The name of the minion according to etcd is in JSONBase.ID.
// The name of the minion according to etcd is in TypeMeta.ID.
type Minion struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// Queried from cloud provider, if available.
HostIP string `json:"hostIP,omitempty" yaml:"hostIP,omitempty"`
// Resources available on the node
@ -481,7 +481,7 @@ func (*Minion) IsAnAPIObject() {}
// MinionList is a list of minions.
type MinionList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// DEPRECATED: the below Minions is due to a naming mistake and
// will be replaced with Items in the future.
Minions []Minion `json:"minions,omitempty" yaml:"minions,omitempty"`
@ -492,7 +492,7 @@ func (*MinionList) IsAnAPIObject() {}
// Binding is written by a scheduler to cause a pod to be bound to a host.
type Binding struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
PodID string `json:"podID" yaml:"podID"`
Host string `json:"host" yaml:"host"`
}
@ -503,7 +503,7 @@ func (*Binding) IsAnAPIObject() {}
// TODO: this could go in apiserver, but I'm including it here so clients needn't
// import both.
type Status struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// One of: "Success", "Failure", "Working" (for operations not yet completed)
Status string `json:"status,omitempty" yaml:"status,omitempty"`
// A human-readable description of the status of this operation.
@ -644,14 +644,14 @@ const (
// ServerOp is an operation delivered to API clients.
type ServerOp struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
}
func (*ServerOp) IsAnAPIObject() {}
// ServerOpList is a list of operations, as delivered to API clients.
type ServerOpList struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
Items []ServerOp `yaml:"items,omitempty" json:"items,omitempty"`
}
@ -678,7 +678,7 @@ type ObjectReference struct {
// Event is a report of an event somewhere in the cluster.
// TODO: Decide whether to store these separately or with the object they apply to.
type Event struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
// Required. The object that this event is about.
InvolvedObject ObjectReference `json:"involvedObject,omitempty" yaml:"involvedObject,omitempty"`
@ -711,7 +711,7 @@ func (*Event) IsAnAPIObject() {}
// EventList is a list of events.
type EventList struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
Items []Event `yaml:"items,omitempty" json:"items,omitempty"`
}

View File

@ -62,13 +62,13 @@ func init() {
// MinionList.Items had a wrong name in v1beta1
func(in *newer.MinionList, out *MinionList, s conversion.Scope) error {
s.Convert(&in.JSONBase, &out.JSONBase, 0)
s.Convert(&in.TypeMeta, &out.TypeMeta, 0)
s.Convert(&in.Items, &out.Items, 0)
out.Minions = out.Items
return nil
},
func(in *MinionList, out *newer.MinionList, s conversion.Scope) error {
s.Convert(&in.JSONBase, &out.JSONBase, 0)
s.Convert(&in.TypeMeta, &out.TypeMeta, 0)
if len(in.Items) == 0 {
s.Convert(&in.Minions, &out.Items, 0)
} else {

View File

@ -65,7 +65,7 @@ type ContainerManifest struct {
// ContainerManifestList is used to communicate container manifests to kubelet.
type ContainerManifestList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"`
}
@ -253,8 +253,8 @@ type Lifecycle struct {
// The below types are used by kube_client and api_server.
// JSONBase is shared by all objects sent to, or returned from the client.
type JSONBase struct {
// TypeMeta is shared by all objects sent to, or returned from the client.
type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
@ -355,7 +355,7 @@ type PodState struct {
// PodList is a list of Pods.
type PodList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []Pod `json:"items" yaml:"items,omitempty"`
}
@ -363,7 +363,7 @@ func (*PodList) IsAnAPIObject() {}
// Pod is a collection of containers, used as either input (create, update) or as output (list, get).
type Pod struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
CurrentState PodState `json:"currentState,omitempty" yaml:"currentState,omitempty"`
@ -380,7 +380,7 @@ type ReplicationControllerState struct {
// ReplicationControllerList is a collection of replication controllers.
type ReplicationControllerList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []ReplicationController `json:"items,omitempty" yaml:"items,omitempty"`
}
@ -388,7 +388,7 @@ func (*ReplicationControllerList) IsAnAPIObject() {}
// ReplicationController represents the configuration of a replication controller.
type ReplicationController struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
DesiredState ReplicationControllerState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
CurrentState ReplicationControllerState `json:"currentState,omitempty" yaml:"currentState,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
@ -404,7 +404,7 @@ type PodTemplate struct {
// ServiceList holds a list of services.
type ServiceList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []Service `json:"items" yaml:"items"`
}
@ -414,7 +414,7 @@ func (*ServiceList) IsAnAPIObject() {}
// (for example 3306) that the proxy listens on, and the selector that determines which pods
// will answer requests sent through the proxy.
type Service struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// Required.
Port int `json:"port" yaml:"port"`
@ -438,7 +438,7 @@ func (*Service) IsAnAPIObject() {}
// Endpoints is a collection of endpoints that implement the actual service, for example:
// Name: "mysql", Endpoints: ["10.10.1.1:1909", "10.10.2.2:8834"]
type Endpoints struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Endpoints []string `json:"endpoints,omitempty" yaml:"endpoints,omitempty"`
}
@ -446,7 +446,7 @@ func (*Endpoints) IsAnAPIObject() {}
// EndpointsList is a list of endpoints.
type EndpointsList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Items []Endpoints `json:"items,omitempty" yaml:"items,omitempty"`
}
@ -464,9 +464,9 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString
// Minion is a worker node in Kubernetenes.
// The name of the minion according to etcd is in JSONBase.ID.
// The name of the minion according to etcd is in TypeMeta.ID.
type Minion struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// Queried from cloud provider, if available.
HostIP string `json:"hostIP,omitempty" yaml:"hostIP,omitempty"`
// Resources available on the node
@ -477,7 +477,7 @@ func (*Minion) IsAnAPIObject() {}
// MinionList is a list of minions.
type MinionList struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// DEPRECATED: the below Minions is due to a naming mistake and
// will be replaced with Items in the future.
Minions []Minion `json:"minions,omitempty" yaml:"minions,omitempty"`
@ -488,7 +488,7 @@ func (*MinionList) IsAnAPIObject() {}
// Binding is written by a scheduler to cause a pod to be bound to a host.
type Binding struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
PodID string `json:"podID" yaml:"podID"`
Host string `json:"host" yaml:"host"`
}
@ -499,7 +499,7 @@ func (*Binding) IsAnAPIObject() {}
// TODO: this could go in apiserver, but I'm including it here so clients needn't
// import both.
type Status struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
// One of: "Success", "Failure", "Working" (for operations not yet completed)
Status string `json:"status,omitempty" yaml:"status,omitempty"`
// A human-readable description of the status of this operation.
@ -653,14 +653,14 @@ const (
// ServerOp is an operation delivered to API clients.
type ServerOp struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
}
func (*ServerOp) IsAnAPIObject() {}
// ServerOpList is a list of operations, as delivered to API clients.
type ServerOpList struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
Items []ServerOp `yaml:"items,omitempty" json:"items,omitempty"`
}
@ -687,7 +687,7 @@ type ObjectReference struct {
// Event is a report of an event somewhere in the cluster.
// TODO: Decide whether to store these separately or with the object they apply to.
type Event struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
// Required. The object that this event is about.
InvolvedObject ObjectReference `json:"involvedObject,omitempty" yaml:"involvedObject,omitempty"`
@ -720,7 +720,7 @@ func (*Event) IsAnAPIObject() {}
// EventList is a list of events.
type EventList struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
Items []Event `yaml:"items,omitempty" json:"items,omitempty"`
}

View File

@ -580,7 +580,7 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString
// Node is a worker node in Kubernetenes.
// The name of the node according to etcd is in JSONBase.ID.
// The name of the node according to etcd is in TypeMeta.ID.
type Node struct {
TypeMeta `json:",inline" yaml:",inline"`
Metadata ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`

View File

@ -366,7 +366,7 @@ func TestValidateManifest(t *testing.T) {
func TestValidatePod(t *testing.T) {
errs := ValidatePod(&api.Pod{
JSONBase: api.JSONBase{ID: "foo", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
Labels: map[string]string{
"foo": "bar",
},
@ -384,7 +384,7 @@ func TestValidatePod(t *testing.T) {
t.Errorf("Unexpected non-zero error list: %#v", errs)
}
errs = ValidatePod(&api.Pod{
JSONBase: api.JSONBase{ID: "foo", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
Labels: map[string]string{
"foo": "bar",
},
@ -397,7 +397,7 @@ func TestValidatePod(t *testing.T) {
}
errs = ValidatePod(&api.Pod{
JSONBase: api.JSONBase{ID: "foo", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
Labels: map[string]string{
"foo": "bar",
},
@ -424,7 +424,7 @@ func TestValidateService(t *testing.T) {
{
name: "missing id",
svc: api.Service{
JSONBase: api.JSONBase{Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{Namespace: api.NamespaceDefault},
Port: 8675,
Selector: map[string]string{"foo": "bar"},
},
@ -434,7 +434,7 @@ func TestValidateService(t *testing.T) {
{
name: "missing namespace",
svc: api.Service{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Port: 8675,
Selector: map[string]string{"foo": "bar"},
},
@ -444,7 +444,7 @@ func TestValidateService(t *testing.T) {
{
name: "invalid id",
svc: api.Service{
JSONBase: api.JSONBase{ID: "123abc", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "123abc", Namespace: api.NamespaceDefault},
Port: 8675,
Selector: map[string]string{"foo": "bar"},
},
@ -454,7 +454,7 @@ func TestValidateService(t *testing.T) {
{
name: "missing port",
svc: api.Service{
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
Selector: map[string]string{"foo": "bar"},
},
// Should fail because the port number is missing/invalid.
@ -463,7 +463,7 @@ func TestValidateService(t *testing.T) {
{
name: "invalid port",
svc: api.Service{
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
Port: 65536,
Selector: map[string]string{"foo": "bar"},
},
@ -473,7 +473,7 @@ func TestValidateService(t *testing.T) {
{
name: "invalid protocol",
svc: api.Service{
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
Port: 8675,
Protocol: "INVALID",
Selector: map[string]string{"foo": "bar"},
@ -484,7 +484,7 @@ func TestValidateService(t *testing.T) {
{
name: "missing selector",
svc: api.Service{
JSONBase: api.JSONBase{ID: "foo", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
Port: 8675,
},
// Should fail because the selector is missing.
@ -493,7 +493,7 @@ func TestValidateService(t *testing.T) {
{
name: "valid 1",
svc: api.Service{
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
Port: 1,
Protocol: "TCP",
Selector: map[string]string{"foo": "bar"},
@ -503,7 +503,7 @@ func TestValidateService(t *testing.T) {
{
name: "valid 2",
svc: api.Service{
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
Port: 65535,
Protocol: "UDP",
Selector: map[string]string{"foo": "bar"},
@ -513,7 +513,7 @@ func TestValidateService(t *testing.T) {
{
name: "valid 3",
svc: api.Service{
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
Port: 80,
Selector: map[string]string{"foo": "bar"},
},
@ -530,7 +530,7 @@ func TestValidateService(t *testing.T) {
svc := api.Service{
Port: 6502,
JSONBase: api.JSONBase{ID: "foo", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
Selector: map[string]string{"foo": "bar"},
}
errs := ValidateService(&svc)
@ -555,14 +555,14 @@ func TestValidateReplicationController(t *testing.T) {
successCases := []api.ReplicationController{
{
JSONBase: api.JSONBase{ID: "abc", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector,
PodTemplate: validPodTemplate,
},
},
{
JSONBase: api.JSONBase{ID: "abc-123", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc-123", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector,
PodTemplate: validPodTemplate,
@ -577,40 +577,40 @@ func TestValidateReplicationController(t *testing.T) {
errorCases := map[string]api.ReplicationController{
"zero-length ID": {
JSONBase: api.JSONBase{ID: "", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector,
PodTemplate: validPodTemplate,
},
},
"missing-namespace": {
JSONBase: api.JSONBase{ID: "abc-123"},
TypeMeta: api.TypeMeta{ID: "abc-123"},
DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector,
PodTemplate: validPodTemplate,
},
},
"empty selector": {
JSONBase: api.JSONBase{ID: "abc", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{
PodTemplate: validPodTemplate,
},
},
"selector_doesnt_match": {
JSONBase: api.JSONBase{ID: "abc", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{
ReplicaSelector: map[string]string{"foo": "bar"},
PodTemplate: validPodTemplate,
},
},
"invalid manifest": {
JSONBase: api.JSONBase{ID: "abc", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{
ReplicaSelector: validSelector,
},
},
"negative_replicas": {
JSONBase: api.JSONBase{ID: "abc", Namespace: api.NamespaceDefault},
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
DesiredState: api.ReplicationControllerState{
Replicas: -1,
ReplicaSelector: validSelector,

View File

@ -53,14 +53,14 @@ func init() {
}
type Simple struct {
api.JSONBase `yaml:",inline" json:",inline"`
api.TypeMeta `yaml:",inline" json:",inline"`
Name string `yaml:"name,omitempty" json:"name,omitempty"`
}
func (*Simple) IsAnAPIObject() {}
type SimpleList struct {
api.JSONBase `yaml:",inline" json:",inline"`
api.TypeMeta `yaml:",inline" json:",inline"`
Items []Simple `yaml:"items,omitempty" json:"items,omitempty"`
}
@ -107,7 +107,7 @@ func (storage *SimpleRESTStorage) Delete(ctx api.Context, id string) (<-chan run
}
return MakeAsync(func() (runtime.Object, error) {
if storage.injectedFunction != nil {
return storage.injectedFunction(&Simple{JSONBase: api.JSONBase{ID: id}})
return storage.injectedFunction(&Simple{TypeMeta: api.TypeMeta{ID: id}})
}
return &api.Status{Status: api.StatusSuccess}, nil
}), nil
@ -288,7 +288,7 @@ func TestNonEmptyList(t *testing.T) {
simpleStorage := SimpleRESTStorage{
list: []Simple{
{
JSONBase: api.JSONBase{Kind: "Simple"},
TypeMeta: api.TypeMeta{Kind: "Simple"},
Name: "foo",
},
},

View File

@ -125,7 +125,7 @@ func (ops *Operations) List() *api.ServerOpList {
sort.StringSlice(ids).Sort()
ol := &api.ServerOpList{}
for _, id := range ids {
ol.Items = append(ol.Items, api.ServerOp{JSONBase: api.JSONBase{ID: id}})
ol.Items = append(ol.Items, api.ServerOp{TypeMeta: api.TypeMeta{ID: id}})
}
return ol
}

View File

@ -43,7 +43,7 @@ func TestOperation(t *testing.T) {
time.Sleep(time.Millisecond)
go func() {
time.Sleep(500 * time.Millisecond)
c <- &Simple{JSONBase: api.JSONBase{ID: "All done"}}
c <- &Simple{TypeMeta: api.TypeMeta{ID: "All done"}}
}()
if op.expired(time.Now().Add(-time.Minute)) {

View File

@ -78,7 +78,7 @@ func (r *Reflector) listAndWatch() {
glog.Errorf("Failed to list %v: %v", r.expectedType, err)
return
}
jsonBase, err := runtime.FindJSONBase(list)
jsonBase, err := runtime.FindTypeMeta(list)
if err != nil {
glog.Errorf("Unable to understand list result %#v", list)
return
@ -112,7 +112,7 @@ func (r *Reflector) listAndWatch() {
func (r *Reflector) syncWith(items []runtime.Object) error {
found := map[string]interface{}{}
for _, item := range items {
jsonBase, err := runtime.FindJSONBase(item)
jsonBase, err := runtime.FindTypeMeta(item)
if err != nil {
return fmt.Errorf("unexpected item in list: %v", err)
}
@ -139,7 +139,7 @@ func (r *Reflector) watchHandler(w watch.Interface, resourceVersion *uint64) err
glog.Errorf("expected type %v, but watch event object had type %v", e, a)
continue
}
jsonBase, err := runtime.FindJSONBase(event.Object)
jsonBase, err := runtime.FindTypeMeta(event.Object)
if err != nil {
glog.Errorf("unable to understand watch event %#v", event)
continue

View File

@ -53,13 +53,13 @@ func TestReflector_watchHandler(t *testing.T) {
s := NewStore()
g := NewReflector(&testLW{}, &api.Pod{}, s)
fw := watch.NewFake()
s.Add("foo", &api.Pod{JSONBase: api.JSONBase{ID: "foo"}})
s.Add("bar", &api.Pod{JSONBase: api.JSONBase{ID: "bar"}})
s.Add("foo", &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}})
s.Add("bar", &api.Pod{TypeMeta: api.TypeMeta{ID: "bar"}})
go func() {
fw.Add(&api.Service{JSONBase: api.JSONBase{ID: "rejected"}})
fw.Delete(&api.Pod{JSONBase: api.JSONBase{ID: "foo"}})
fw.Modify(&api.Pod{JSONBase: api.JSONBase{ID: "bar", ResourceVersion: 55}})
fw.Add(&api.Pod{JSONBase: api.JSONBase{ID: "baz", ResourceVersion: 32}})
fw.Add(&api.Service{TypeMeta: api.TypeMeta{ID: "rejected"}})
fw.Delete(&api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}})
fw.Modify(&api.Pod{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: 55}})
fw.Add(&api.Pod{TypeMeta: api.TypeMeta{ID: "baz", ResourceVersion: 32}})
fw.Stop()
}()
var resumeRV uint64
@ -117,7 +117,7 @@ func TestReflector_listAndWatch(t *testing.T) {
return fw, nil
},
ListFunc: func() (runtime.Object, error) {
return &api.PodList{JSONBase: api.JSONBase{ResourceVersion: 1}}, nil
return &api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: 1}}, nil
},
}
s := NewFIFO()
@ -131,7 +131,7 @@ func TestReflector_listAndWatch(t *testing.T) {
fw = <-createdFakes
}
sendingRV := uint64(i + 2)
fw.Add(&api.Pod{JSONBase: api.JSONBase{ID: id, ResourceVersion: sendingRV}})
fw.Add(&api.Pod{TypeMeta: api.TypeMeta{ID: id, ResourceVersion: sendingRV}})
if sendingRV == 3 {
// Inject a failure.
fw.Stop()
@ -157,10 +157,10 @@ func TestReflector_listAndWatch(t *testing.T) {
func TestReflector_listAndWatchWithErrors(t *testing.T) {
mkPod := func(id string, rv uint64) *api.Pod {
return &api.Pod{JSONBase: api.JSONBase{ID: id, ResourceVersion: rv}}
return &api.Pod{TypeMeta: api.TypeMeta{ID: id, ResourceVersion: rv}}
}
mkList := func(rv uint64, pods ...*api.Pod) *api.PodList {
list := &api.PodList{JSONBase: api.JSONBase{ResourceVersion: rv}}
list := &api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: rv}}
for _, pod := range pods {
list.Items = append(list.Items, *pod)
}

View File

@ -265,7 +265,7 @@ func TestCreatePod(t *testing.T) {
func TestUpdatePod(t *testing.T) {
requestPod := &api.Pod{
JSONBase: api.JSONBase{ID: "foo", ResourceVersion: 1},
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: 1},
CurrentState: api.PodState{
Status: "Foobar",
},
@ -289,7 +289,7 @@ func TestListControllers(t *testing.T) {
Body: &api.ReplicationControllerList{
Items: []api.ReplicationController{
{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
DesiredState: api.ReplicationControllerState{
Replicas: 2,
},
@ -313,7 +313,7 @@ func TestGetController(t *testing.T) {
Response: Response{
StatusCode: 200,
Body: &api.ReplicationController{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
DesiredState: api.ReplicationControllerState{
Replicas: 2,
},
@ -330,14 +330,14 @@ func TestGetController(t *testing.T) {
func TestUpdateController(t *testing.T) {
requestController := &api.ReplicationController{
JSONBase: api.JSONBase{ID: "foo", ResourceVersion: 1},
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: 1},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: "/replicationControllers/foo"},
Response: Response{
StatusCode: 200,
Body: &api.ReplicationController{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
DesiredState: api.ReplicationControllerState{
Replicas: 2,
},
@ -363,14 +363,14 @@ func TestDeleteController(t *testing.T) {
func TestCreateController(t *testing.T) {
requestController := &api.ReplicationController{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
}
c := &testClient{
Request: testRequest{Method: "POST", Path: "/replicationControllers", Body: requestController},
Response: Response{
StatusCode: 200,
Body: &api.ReplicationController{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
DesiredState: api.ReplicationControllerState{
Replicas: 2,
},
@ -401,7 +401,7 @@ func TestListServices(t *testing.T) {
Body: &api.ServiceList{
Items: []api.Service{
{
JSONBase: api.JSONBase{ID: "name"},
TypeMeta: api.TypeMeta{ID: "name"},
Labels: map[string]string{
"foo": "bar",
"name": "baz",
@ -425,7 +425,7 @@ func TestListServicesLabels(t *testing.T) {
Body: &api.ServiceList{
Items: []api.Service{
{
JSONBase: api.JSONBase{ID: "name"},
TypeMeta: api.TypeMeta{ID: "name"},
Labels: map[string]string{
"foo": "bar",
"name": "baz",
@ -448,7 +448,7 @@ func TestListServicesLabels(t *testing.T) {
func TestGetService(t *testing.T) {
c := &testClient{
Request: testRequest{Method: "GET", Path: "/services/1"},
Response: Response{StatusCode: 200, Body: &api.Service{JSONBase: api.JSONBase{ID: "service-1"}}},
Response: Response{StatusCode: 200, Body: &api.Service{TypeMeta: api.TypeMeta{ID: "service-1"}}},
}
response, err := c.Setup().GetService(api.NewDefaultContext(), "1")
c.Validate(t, response, err)
@ -456,15 +456,15 @@ func TestGetService(t *testing.T) {
func TestCreateService(t *testing.T) {
c := &testClient{
Request: testRequest{Method: "POST", Path: "/services", Body: &api.Service{JSONBase: api.JSONBase{ID: "service-1"}}},
Response: Response{StatusCode: 200, Body: &api.Service{JSONBase: api.JSONBase{ID: "service-1"}}},
Request: testRequest{Method: "POST", Path: "/services", Body: &api.Service{TypeMeta: api.TypeMeta{ID: "service-1"}}},
Response: Response{StatusCode: 200, Body: &api.Service{TypeMeta: api.TypeMeta{ID: "service-1"}}},
}
response, err := c.Setup().CreateService(api.NewDefaultContext(), &api.Service{JSONBase: api.JSONBase{ID: "service-1"}})
response, err := c.Setup().CreateService(api.NewDefaultContext(), &api.Service{TypeMeta: api.TypeMeta{ID: "service-1"}})
c.Validate(t, response, err)
}
func TestUpdateService(t *testing.T) {
svc := &api.Service{JSONBase: api.JSONBase{ID: "service-1", ResourceVersion: 1}}
svc := &api.Service{TypeMeta: api.TypeMeta{ID: "service-1", ResourceVersion: 1}}
c := &testClient{
Request: testRequest{Method: "PUT", Path: "/services/service-1", Body: svc},
Response: Response{StatusCode: 200, Body: svc},
@ -489,7 +489,7 @@ func TestListEndpooints(t *testing.T) {
Body: &api.EndpointsList{
Items: []api.Endpoints{
{
JSONBase: api.JSONBase{ID: "endpoint-1"},
TypeMeta: api.TypeMeta{ID: "endpoint-1"},
Endpoints: []string{"10.245.1.2:8080", "10.245.1.3:8080"},
},
},
@ -503,7 +503,7 @@ func TestListEndpooints(t *testing.T) {
func TestGetEndpoints(t *testing.T) {
c := &testClient{
Request: testRequest{Method: "GET", Path: "/endpoints/endpoint-1"},
Response: Response{StatusCode: 200, Body: &api.Endpoints{JSONBase: api.JSONBase{ID: "endpoint-1"}}},
Response: Response{StatusCode: 200, Body: &api.Endpoints{TypeMeta: api.TypeMeta{ID: "endpoint-1"}}},
}
response, err := c.Setup().GetEndpoints(api.NewDefaultContext(), "endpoint-1")
c.Validate(t, response, err)
@ -539,7 +539,7 @@ func TestGetServerVersion(t *testing.T) {
func TestListMinions(t *testing.T) {
c := &testClient{
Request: testRequest{Method: "GET", Path: "/minions"},
Response: Response{StatusCode: 200, Body: &api.MinionList{JSONBase: api.JSONBase{ID: "minion-1"}}},
Response: Response{StatusCode: 200, Body: &api.MinionList{TypeMeta: api.TypeMeta{ID: "minion-1"}}},
}
response, err := c.Setup().ListMinions()
c.Validate(t, response, err)

View File

@ -72,7 +72,7 @@ func TestDoRequestNewWay(t *testing.T) {
}
func TestDoRequestNewWayReader(t *testing.T) {
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
reqObj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
reqBodyExpected, _ := v1beta1.Codec.Encode(reqObj)
expectedObj := &api.Service{Port: 12345}
expectedBody, _ := v1beta1.Codec.Encode(expectedObj)
@ -108,7 +108,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
}
func TestDoRequestNewWayObj(t *testing.T) {
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
reqObj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
reqBodyExpected, _ := v1beta2.Codec.Encode(reqObj)
expectedObj := &api.Service{Port: 12345}
expectedBody, _ := v1beta2.Codec.Encode(expectedObj)
@ -143,7 +143,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
}
func TestDoRequestNewWayFile(t *testing.T) {
reqObj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
reqObj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
reqBodyExpected, err := v1beta1.Codec.Encode(reqObj)
if err != nil {
t.Errorf("unexpected error: %v", err)
@ -380,9 +380,9 @@ func TestWatch(t *testing.T) {
t watch.EventType
obj runtime.Object
}{
{watch.Added, &api.Pod{JSONBase: api.JSONBase{ID: "first"}}},
{watch.Modified, &api.Pod{JSONBase: api.JSONBase{ID: "second"}}},
{watch.Deleted, &api.Pod{JSONBase: api.JSONBase{ID: "last"}}},
{watch.Added, &api.Pod{TypeMeta: api.TypeMeta{ID: "first"}}},
{watch.Modified, &api.Pod{TypeMeta: api.TypeMeta{ID: "second"}}},
{watch.Deleted, &api.Pod{TypeMeta: api.TypeMeta{ID: "last"}}},
}
auth := &Config{Username: "user", Password: "pass"}

View File

@ -89,7 +89,7 @@ func newPodList(count int) *api.PodList {
pods := []api.Pod{}
for i := 0; i < count; i++ {
pods = append(pods, api.Pod{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: fmt.Sprintf("pod%d", i),
},
})
@ -183,7 +183,7 @@ func TestCreateReplica(t *testing.T) {
}
controllerSpec := api.ReplicationController{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
Kind: "ReplicationController",
},
DesiredState: api.ReplicationControllerState{
@ -208,7 +208,7 @@ func TestCreateReplica(t *testing.T) {
podControl.createReplica(ctx, controllerSpec)
expectedPod := api.Pod{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
Kind: "Pod",
APIVersion: testapi.Version(),
},
@ -228,7 +228,7 @@ func TestCreateReplica(t *testing.T) {
func TestSynchonize(t *testing.T) {
controllerSpec1 := api.ReplicationController{
JSONBase: api.JSONBase{APIVersion: testapi.Version()},
TypeMeta: api.TypeMeta{APIVersion: testapi.Version()},
DesiredState: api.ReplicationControllerState{
Replicas: 4,
PodTemplate: api.PodTemplate{
@ -249,7 +249,7 @@ func TestSynchonize(t *testing.T) {
},
}
controllerSpec2 := api.ReplicationController{
JSONBase: api.JSONBase{APIVersion: testapi.Version()},
TypeMeta: api.TypeMeta{APIVersion: testapi.Version()},
DesiredState: api.ReplicationControllerState{
Replicas: 3,
PodTemplate: api.PodTemplate{

View File

@ -211,7 +211,7 @@ func RunController(ctx api.Context, image, name string, replicas int, client cli
return err
}
controller := &api.ReplicationController{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: name,
},
DesiredState: api.ReplicationControllerState{
@ -265,7 +265,7 @@ func RunController(ctx api.Context, image, name string, replicas int, client cli
func createService(ctx api.Context, name string, port int, client client.Interface) (*api.Service, error) {
svc := &api.Service{
JSONBase: api.JSONBase{ID: name},
TypeMeta: api.TypeMeta{ID: name},
Port: port,
Labels: map[string]string{
"simpleService": name,

View File

@ -38,8 +38,8 @@ func TestUpdateWithPods(t *testing.T) {
fakeClient := client.Fake{
Pods: api.PodList{
Items: []api.Pod{
{JSONBase: api.JSONBase{ID: "pod-1"}},
{JSONBase: api.JSONBase{ID: "pod-2"}},
{TypeMeta: api.TypeMeta{ID: "pod-1"}},
{TypeMeta: api.TypeMeta{ID: "pod-2"}},
},
},
}
@ -69,8 +69,8 @@ func TestUpdateWithNewImage(t *testing.T) {
fakeClient := client.Fake{
Pods: api.PodList{
Items: []api.Pod{
{JSONBase: api.JSONBase{ID: "pod-1"}},
{JSONBase: api.JSONBase{ID: "pod-2"}},
{TypeMeta: api.TypeMeta{ID: "pod-1"}},
{TypeMeta: api.TypeMeta{ID: "pod-2"}},
},
},
Ctrl: api.ReplicationController{

View File

@ -69,7 +69,7 @@ var testParser = NewParser(map[string]runtime.Object{
func TestParsePod(t *testing.T) {
DoParseTest(t, "pods", &api.Pod{
JSONBase: api.JSONBase{APIVersion: "v1beta1", ID: "test pod", Kind: "Pod"},
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", ID: "test pod", Kind: "Pod"},
DesiredState: api.PodState{
Manifest: api.ContainerManifest{
ID: "My manifest",
@ -86,7 +86,7 @@ func TestParsePod(t *testing.T) {
func TestParseService(t *testing.T) {
DoParseTest(t, "services", &api.Service{
JSONBase: api.JSONBase{APIVersion: "v1beta1", ID: "my service", Kind: "Service"},
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", ID: "my service", Kind: "Service"},
Port: 8080,
Labels: map[string]string{
"area": "staging",
@ -99,7 +99,7 @@ func TestParseService(t *testing.T) {
func TestParseController(t *testing.T) {
DoParseTest(t, "replicationControllers", &api.ReplicationController{
JSONBase: api.JSONBase{APIVersion: "v1beta1", ID: "my controller", Kind: "ReplicationController"},
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", ID: "my controller", Kind: "ReplicationController"},
DesiredState: api.ReplicationControllerState{
Replicas: 9001,
PodTemplate: api.PodTemplate{
@ -120,7 +120,7 @@ func TestParseController(t *testing.T) {
}
type TestParseType struct {
api.JSONBase `json:",inline" yaml:",inline"`
api.TypeMeta `json:",inline" yaml:",inline"`
Data string `json:"data" yaml:"data"`
}
@ -134,7 +134,7 @@ func TestParseCustomType(t *testing.T) {
"custom": &TestParseType{},
})
DoParseTest(t, "custom", &TestParseType{
JSONBase: api.JSONBase{APIVersion: "", ID: "my custom object", Kind: "TestParseType"},
TypeMeta: api.TypeMeta{APIVersion: "", ID: "my custom object", Kind: "TestParseType"},
Data: "test data",
}, v1beta1.Codec, parser)
}

View File

@ -68,7 +68,7 @@ func TestYAMLPrinterPrint(t *testing.T) {
}
obj := &api.Pod{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
}
buf.Reset()
printer.PrintObj(obj, buf)
@ -92,7 +92,7 @@ func TestIdentityPrinter(t *testing.T) {
}
obj := &api.Pod{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
}
buff.Reset()
printer.PrintObj(obj, buff)

View File

@ -92,7 +92,7 @@ func TestPodGetPodInfoGetter(t *testing.T) {
func TestPodUpdateAllContainers(t *testing.T) {
pod := api.Pod{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
CurrentState: api.PodState{
Host: "machine",
},

View File

@ -27,7 +27,7 @@ import (
)
func TestServices(t *testing.T) {
service := api.Service{JSONBase: api.JSONBase{ID: "bar", ResourceVersion: uint64(2)}}
service := api.Service{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: uint64(2)}}
fakeWatch := watch.NewFake()
fakeClient := &client.Fake{Watch: fakeWatch}
@ -72,13 +72,13 @@ func TestServices(t *testing.T) {
}
func TestServicesFromZero(t *testing.T) {
service := api.Service{JSONBase: api.JSONBase{ID: "bar", ResourceVersion: uint64(2)}}
service := api.Service{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: uint64(2)}}
fakeWatch := watch.NewFake()
fakeWatch.Stop()
fakeClient := &client.Fake{Watch: fakeWatch}
fakeClient.ServiceList = api.ServiceList{
JSONBase: api.JSONBase{ResourceVersion: 2},
TypeMeta: api.TypeMeta{ResourceVersion: 2},
Items: []api.Service{
service,
},
@ -152,7 +152,7 @@ func TestServicesFromZeroError(t *testing.T) {
}
func TestEndpoints(t *testing.T) {
endpoint := api.Endpoints{JSONBase: api.JSONBase{ID: "bar", ResourceVersion: uint64(2)}, Endpoints: []string{"127.0.0.1:9000"}}
endpoint := api.Endpoints{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: uint64(2)}, Endpoints: []string{"127.0.0.1:9000"}}
fakeWatch := watch.NewFake()
fakeClient := &client.Fake{Watch: fakeWatch}
@ -197,13 +197,13 @@ func TestEndpoints(t *testing.T) {
}
func TestEndpointsFromZero(t *testing.T) {
endpoint := api.Endpoints{JSONBase: api.JSONBase{ID: "bar", ResourceVersion: uint64(2)}, Endpoints: []string{"127.0.0.1:9000"}}
endpoint := api.Endpoints{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: uint64(2)}, Endpoints: []string{"127.0.0.1:9000"}}
fakeWatch := watch.NewFake()
fakeWatch.Stop()
fakeClient := &client.Fake{Watch: fakeWatch}
fakeClient.EndpointsList = api.EndpointsList{
JSONBase: api.JSONBase{ResourceVersion: 2},
TypeMeta: api.TypeMeta{ResourceVersion: 2},
Items: []api.Endpoints{
endpoint,
},

View File

@ -45,7 +45,7 @@ func (s sortedServices) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s sortedServices) Less(i, j int) bool {
return s[i].JSONBase.ID < s[j].JSONBase.ID
return s[i].TypeMeta.ID < s[j].TypeMeta.ID
}
type ServiceHandlerMock struct {
@ -136,7 +136,7 @@ func TestNewServiceAddedAndNotified(t *testing.T) {
handler := NewServiceHandlerMock()
handler.Wait(1)
config.RegisterHandler(handler)
serviceUpdate := CreateServiceUpdate(ADD, api.Service{JSONBase: api.JSONBase{ID: "foo"}, Port: 10})
serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "foo"}, Port: 10})
channel <- serviceUpdate
handler.ValidateServices(t, serviceUpdate.Services)
@ -147,24 +147,24 @@ func TestServiceAddedRemovedSetAndNotified(t *testing.T) {
channel := config.Channel("one")
handler := NewServiceHandlerMock()
config.RegisterHandler(handler)
serviceUpdate := CreateServiceUpdate(ADD, api.Service{JSONBase: api.JSONBase{ID: "foo"}, Port: 10})
serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "foo"}, Port: 10})
handler.Wait(1)
channel <- serviceUpdate
handler.ValidateServices(t, serviceUpdate.Services)
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{JSONBase: api.JSONBase{ID: "bar"}, Port: 20})
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "bar"}, Port: 20})
handler.Wait(1)
channel <- serviceUpdate2
services := []api.Service{serviceUpdate2.Services[0], serviceUpdate.Services[0]}
handler.ValidateServices(t, services)
serviceUpdate3 := CreateServiceUpdate(REMOVE, api.Service{JSONBase: api.JSONBase{ID: "foo"}})
serviceUpdate3 := CreateServiceUpdate(REMOVE, api.Service{TypeMeta: api.TypeMeta{ID: "foo"}})
handler.Wait(1)
channel <- serviceUpdate3
services = []api.Service{serviceUpdate2.Services[0]}
handler.ValidateServices(t, services)
serviceUpdate4 := CreateServiceUpdate(SET, api.Service{JSONBase: api.JSONBase{ID: "foobar"}, Port: 99})
serviceUpdate4 := CreateServiceUpdate(SET, api.Service{TypeMeta: api.TypeMeta{ID: "foobar"}, Port: 99})
handler.Wait(1)
channel <- serviceUpdate4
services = []api.Service{serviceUpdate4.Services[0]}
@ -180,8 +180,8 @@ func TestNewMultipleSourcesServicesAddedAndNotified(t *testing.T) {
}
handler := NewServiceHandlerMock()
config.RegisterHandler(handler)
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{JSONBase: api.JSONBase{ID: "foo"}, Port: 10})
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{JSONBase: api.JSONBase{ID: "bar"}, Port: 20})
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "foo"}, Port: 10})
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "bar"}, Port: 20})
handler.Wait(2)
channelOne <- serviceUpdate1
channelTwo <- serviceUpdate2
@ -197,8 +197,8 @@ func TestNewMultipleSourcesServicesMultipleHandlersAddedAndNotified(t *testing.T
handler2 := NewServiceHandlerMock()
config.RegisterHandler(handler)
config.RegisterHandler(handler2)
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{JSONBase: api.JSONBase{ID: "foo"}, Port: 10})
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{JSONBase: api.JSONBase{ID: "bar"}, Port: 20})
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "foo"}, Port: 10})
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{ID: "bar"}, Port: 20})
handler.Wait(2)
handler2.Wait(2)
channelOne <- serviceUpdate1
@ -217,11 +217,11 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddedAndNotified(t *testing.
config.RegisterHandler(handler)
config.RegisterHandler(handler2)
endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"endpoint1", "endpoint2"},
})
endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{
JSONBase: api.JSONBase{ID: "bar"},
TypeMeta: api.TypeMeta{ID: "bar"},
Endpoints: []string{"endpoint3", "endpoint4"},
})
handler.Wait(2)
@ -243,11 +243,11 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
config.RegisterHandler(handler)
config.RegisterHandler(handler2)
endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"endpoint1", "endpoint2"},
})
endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{
JSONBase: api.JSONBase{ID: "bar"},
TypeMeta: api.TypeMeta{ID: "bar"},
Endpoints: []string{"endpoint3", "endpoint4"},
})
handler.Wait(2)
@ -261,7 +261,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
// Add one more
endpointsUpdate3 := CreateEndpointsUpdate(ADD, api.Endpoints{
JSONBase: api.JSONBase{ID: "foobar"},
TypeMeta: api.TypeMeta{ID: "foobar"},
Endpoints: []string{"endpoint5", "endpoint6"},
})
handler.Wait(1)
@ -273,7 +273,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
// Update the "foo" service with new endpoints
endpointsUpdate1 = CreateEndpointsUpdate(ADD, api.Endpoints{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"endpoint77"},
})
handler.Wait(1)
@ -284,7 +284,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
handler2.ValidateEndpoints(t, endpoints)
// Remove "bar" service
endpointsUpdate2 = CreateEndpointsUpdate(REMOVE, api.Endpoints{JSONBase: api.JSONBase{ID: "bar"}})
endpointsUpdate2 = CreateEndpointsUpdate(REMOVE, api.Endpoints{TypeMeta: api.TypeMeta{ID: "bar"}})
handler.Wait(1)
handler2.Wait(1)
channelTwo <- endpointsUpdate2

View File

@ -221,7 +221,7 @@ func (s ConfigSourceEtcd) ProcessChange(response *etcd.Response) {
parts := strings.Split(response.Node.Key[1:], "/")
if len(parts) == 4 {
glog.V(4).Infof("Deleting service: %s", parts[3])
serviceUpdate := ServiceUpdate{Op: REMOVE, Services: []api.Service{{JSONBase: api.JSONBase{ID: parts[3]}}}}
serviceUpdate := ServiceUpdate{Op: REMOVE, Services: []api.Service{{TypeMeta: api.TypeMeta{ID: parts[3]}}}}
s.serviceChannel <- serviceUpdate
return
}

View File

@ -111,8 +111,8 @@ func (s ConfigSourceFile) Run() {
newServices := make([]api.Service, len(config.Services))
newEndpoints := make([]api.Endpoints, len(config.Services))
for i, service := range config.Services {
newServices[i] = api.Service{JSONBase: api.JSONBase{ID: service.Name}, Port: service.Port}
newEndpoints[i] = api.Endpoints{JSONBase: api.JSONBase{ID: service.Name}, Endpoints: service.Endpoints}
newServices[i] = api.Service{TypeMeta: api.TypeMeta{ID: service.Name}, Port: service.Port}
newEndpoints[i] = api.Endpoints{TypeMeta: api.TypeMeta{ID: service.Name}, Endpoints: service.Endpoints}
}
if !reflect.DeepEqual(lastServices, newServices) {
serviceUpdate := ServiceUpdate{Op: SET, Services: newServices}

View File

@ -139,7 +139,7 @@ func TestTCPProxy(t *testing.T) {
lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{
{
JSONBase: api.JSONBase{ID: "echo"},
TypeMeta: api.TypeMeta{ID: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
},
})
@ -157,7 +157,7 @@ func TestUDPProxy(t *testing.T) {
lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{
{
JSONBase: api.JSONBase{ID: "echo"},
TypeMeta: api.TypeMeta{ID: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
},
})
@ -184,7 +184,7 @@ func TestTCPProxyStop(t *testing.T) {
lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{
{
JSONBase: api.JSONBase{ID: "echo"},
TypeMeta: api.TypeMeta{ID: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
},
})
@ -212,7 +212,7 @@ func TestUDPProxyStop(t *testing.T) {
lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{
{
JSONBase: api.JSONBase{ID: "echo"},
TypeMeta: api.TypeMeta{ID: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
},
})
@ -240,7 +240,7 @@ func TestTCPProxyUpdateDelete(t *testing.T) {
lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{
{
JSONBase: api.JSONBase{ID: "echo"},
TypeMeta: api.TypeMeta{ID: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
},
})
@ -267,7 +267,7 @@ func TestUDPProxyUpdateDelete(t *testing.T) {
lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{
{
JSONBase: api.JSONBase{ID: "echo"},
TypeMeta: api.TypeMeta{ID: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
},
})
@ -294,7 +294,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{
{
JSONBase: api.JSONBase{ID: "echo"},
TypeMeta: api.TypeMeta{ID: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
},
})
@ -317,7 +317,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
}
proxyPortNum, _ := strconv.Atoi(proxyPort)
p.OnUpdate([]api.Service{
{JSONBase: api.JSONBase{ID: "echo"}, Port: proxyPortNum, Protocol: "TCP"},
{TypeMeta: api.TypeMeta{ID: "echo"}, Port: proxyPortNum, Protocol: "TCP"},
})
testEchoTCP(t, "127.0.0.1", proxyPort)
}
@ -326,7 +326,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{
{
JSONBase: api.JSONBase{ID: "echo"},
TypeMeta: api.TypeMeta{ID: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
},
})
@ -349,7 +349,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
}
proxyPortNum, _ := strconv.Atoi(proxyPort)
p.OnUpdate([]api.Service{
{JSONBase: api.JSONBase{ID: "echo"}, Port: proxyPortNum, Protocol: "UDP"},
{TypeMeta: api.TypeMeta{ID: "echo"}, Port: proxyPortNum, Protocol: "UDP"},
})
testEchoUDP(t, "127.0.0.1", proxyPort)
}
@ -358,7 +358,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{
{
JSONBase: api.JSONBase{ID: "echo"},
TypeMeta: api.TypeMeta{ID: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
},
})
@ -384,7 +384,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
t.Errorf("expected difference, got %s %s", newPort, proxyPort)
}
p.OnUpdate([]api.Service{
{JSONBase: api.JSONBase{ID: "echo"}, Port: newPortNum, Protocol: "TCP"},
{TypeMeta: api.TypeMeta{ID: "echo"}, Port: newPortNum, Protocol: "TCP"},
})
if err := waitForClosedPortTCP(p, proxyPort); err != nil {
t.Fatalf(err.Error())
@ -403,7 +403,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
lb := NewLoadBalancerRR()
lb.OnUpdate([]api.Endpoints{
{
JSONBase: api.JSONBase{ID: "echo"},
TypeMeta: api.TypeMeta{ID: "echo"},
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
},
})
@ -429,7 +429,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
t.Errorf("expected difference, got %s %s", newPort, proxyPort)
}
p.OnUpdate([]api.Service{
{JSONBase: api.JSONBase{ID: "echo"}, Port: newPortNum, Protocol: "UDP"},
{TypeMeta: api.TypeMeta{ID: "echo"}, Port: newPortNum, Protocol: "UDP"},
})
if err := waitForClosedPortUDP(p, proxyPort); err != nil {
t.Fatalf(err.Error())

View File

@ -86,7 +86,7 @@ func TestLoadBalanceWorksWithSingleEndpoint(t *testing.T) {
}
endpoints := make([]api.Endpoints, 1)
endpoints[0] = api.Endpoints{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"endpoint1:40"},
}
loadBalancer.OnUpdate(endpoints)
@ -104,7 +104,7 @@ func TestLoadBalanceWorksWithMultipleEndpoints(t *testing.T) {
}
endpoints := make([]api.Endpoints, 1)
endpoints[0] = api.Endpoints{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
}
loadBalancer.OnUpdate(endpoints)
@ -122,7 +122,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
}
endpoints := make([]api.Endpoints, 1)
endpoints[0] = api.Endpoints{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
}
loadBalancer.OnUpdate(endpoints)
@ -133,7 +133,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
expectEndpoint(t, loadBalancer, "foo", "endpoint:2")
// Then update the configuration with one fewer endpoints, make sure
// we start in the beginning again
endpoints[0] = api.Endpoints{JSONBase: api.JSONBase{ID: "foo"},
endpoints[0] = api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"endpoint:8", "endpoint:9"},
}
loadBalancer.OnUpdate(endpoints)
@ -142,7 +142,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
expectEndpoint(t, loadBalancer, "foo", "endpoint:8")
expectEndpoint(t, loadBalancer, "foo", "endpoint:9")
// Clear endpoints
endpoints[0] = api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}}
endpoints[0] = api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{}}
loadBalancer.OnUpdate(endpoints)
endpoint, err = loadBalancer.NextEndpoint("foo", nil)
@ -159,11 +159,11 @@ func TestLoadBalanceWorksWithServiceRemoval(t *testing.T) {
}
endpoints := make([]api.Endpoints, 2)
endpoints[0] = api.Endpoints{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
}
endpoints[1] = api.Endpoints{
JSONBase: api.JSONBase{ID: "bar"},
TypeMeta: api.TypeMeta{ID: "bar"},
Endpoints: []string{"endpoint:4", "endpoint:5"},
}
loadBalancer.OnUpdate(endpoints)

View File

@ -59,7 +59,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if !ok {
return nil, fmt.Errorf("not a replication controller: %#v", obj)
}
if !api.ValidNamespace(ctx, &controller.JSONBase) {
if !api.ValidNamespace(ctx, &controller.TypeMeta) {
return nil, errors.NewConflict("controller", controller.Namespace, fmt.Errorf("Controller.Namespace does not match the provided context"))
}
@ -132,7 +132,7 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if !ok {
return nil, fmt.Errorf("not a replication controller: %#v", obj)
}
if !api.ValidNamespace(ctx, &controller.JSONBase) {
if !api.ValidNamespace(ctx, &controller.TypeMeta) {
return nil, errors.NewConflict("controller", controller.Namespace, fmt.Errorf("Controller.Namespace does not match the provided context"))
}
if errs := validation.ValidateReplicationController(controller); len(errs) > 0 {

View File

@ -50,7 +50,7 @@ func TestListControllersError(t *testing.T) {
}
func TestListEmptyControllerList(t *testing.T) {
mockRegistry := registrytest.ControllerRegistry{nil, &api.ReplicationControllerList{JSONBase: api.JSONBase{ResourceVersion: 1}}}
mockRegistry := registrytest.ControllerRegistry{nil, &api.ReplicationControllerList{TypeMeta: api.TypeMeta{ResourceVersion: 1}}}
storage := REST{
registry: &mockRegistry,
}
@ -73,12 +73,12 @@ func TestListControllerList(t *testing.T) {
Controllers: &api.ReplicationControllerList{
Items: []api.ReplicationController{
{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
},
{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "bar",
},
},
@ -112,7 +112,7 @@ func TestControllerDecode(t *testing.T) {
registry: &mockRegistry,
}
controller := &api.ReplicationController{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
}
@ -133,7 +133,7 @@ func TestControllerDecode(t *testing.T) {
func TestControllerParsing(t *testing.T) {
expectedController := api.ReplicationController{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "nginxController",
},
DesiredState: api.ReplicationControllerState{
@ -224,7 +224,7 @@ func TestCreateController(t *testing.T) {
Pods: &api.PodList{
Items: []api.Pod{
{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Labels: map[string]string{"a": "b"},
},
},
@ -236,7 +236,7 @@ func TestCreateController(t *testing.T) {
pollPeriod: time.Millisecond * 1,
}
controller := &api.ReplicationController{
JSONBase: api.JSONBase{ID: "test"},
TypeMeta: api.TypeMeta{ID: "test"},
DesiredState: api.ReplicationControllerState{
Replicas: 2,
ReplicaSelector: map[string]string{"a": "b"},
@ -269,13 +269,13 @@ func TestControllerStorageValidatesCreate(t *testing.T) {
}
failureCases := map[string]api.ReplicationController{
"empty ID": {
JSONBase: api.JSONBase{ID: ""},
TypeMeta: api.TypeMeta{ID: ""},
DesiredState: api.ReplicationControllerState{
ReplicaSelector: map[string]string{"bar": "baz"},
},
},
"empty selector": {
JSONBase: api.JSONBase{ID: "abc"},
TypeMeta: api.TypeMeta{ID: "abc"},
DesiredState: api.ReplicationControllerState{},
},
}
@ -300,13 +300,13 @@ func TestControllerStorageValidatesUpdate(t *testing.T) {
}
failureCases := map[string]api.ReplicationController{
"empty ID": {
JSONBase: api.JSONBase{ID: ""},
TypeMeta: api.TypeMeta{ID: ""},
DesiredState: api.ReplicationControllerState{
ReplicaSelector: map[string]string{"bar": "baz"},
},
},
"empty selector": {
JSONBase: api.JSONBase{ID: "abc"},
TypeMeta: api.TypeMeta{ID: "abc"},
DesiredState: api.ReplicationControllerState{},
},
}
@ -337,8 +337,8 @@ func TestFillCurrentState(t *testing.T) {
fakeLister := fakePodLister{
l: api.PodList{
Items: []api.Pod{
{JSONBase: api.JSONBase{ID: "foo"}},
{JSONBase: api.JSONBase{ID: "bar"}},
{TypeMeta: api.TypeMeta{ID: "foo"}},
{TypeMeta: api.TypeMeta{ID: "bar"}},
},
},
}

View File

@ -29,7 +29,7 @@ import (
func TestGetEndpoints(t *testing.T) {
registry := &registrytest.ServiceRegistry{
Endpoints: api.Endpoints{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"127.0.0.1:9000"},
},
}
@ -59,7 +59,7 @@ func TestGetEndpointsMissingService(t *testing.T) {
// returns empty endpoints
registry.Err = nil
registry.Service = &api.Service{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
}
obj, err := storage.Get(ctx, "foo")
if err != nil {
@ -74,10 +74,10 @@ func TestEndpointsRegistryList(t *testing.T) {
registry := registrytest.NewServiceRegistry()
storage := NewREST(registry)
registry.EndpointsList = api.EndpointsList{
JSONBase: api.JSONBase{ResourceVersion: 1},
TypeMeta: api.TypeMeta{ResourceVersion: 1},
Items: []api.Endpoints{
{JSONBase: api.JSONBase{ID: "foo"}},
{JSONBase: api.JSONBase{ID: "bar"}},
{TypeMeta: api.TypeMeta{ID: "foo"}},
{TypeMeta: api.TypeMeta{ID: "bar"}},
},
}
ctx := api.NewContext()

View File

@ -43,7 +43,7 @@ func NewTestEtcdRegistry(client tools.EtcdClient) *Registry {
func TestEtcdGetPod(t *testing.T) {
ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.Set("/registry/pods/foo", runtime.EncodeOrDie(latest.Codec, &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0)
fakeClient.Set("/registry/pods/foo", runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient)
pod, err := registry.GetPod(ctx, "foo")
if err != nil {
@ -84,7 +84,7 @@ func TestEtcdCreatePod(t *testing.T) {
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(latest.Codec, &api.ContainerManifestList{}), 0)
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(ctx, &api.Pod{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
DesiredState: api.PodState{
@ -138,14 +138,14 @@ func TestEtcdCreatePodAlreadyExisting(t *testing.T) {
fakeClient.Data["/registry/pods/foo"] = tools.EtcdResponseWithError{
R: &etcd.Response{
Node: &etcd.Node{
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}),
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}),
},
},
E: nil,
}
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(ctx, &api.Pod{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
})
@ -172,7 +172,7 @@ func TestEtcdCreatePodWithContainersError(t *testing.T) {
}
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(ctx, &api.Pod{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
})
@ -213,7 +213,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
}
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(ctx, &api.Pod{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
DesiredState: api.PodState{
@ -279,7 +279,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
}), 0)
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(ctx, &api.Pod{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
DesiredState: api.PodState{
@ -335,7 +335,7 @@ func TestEtcdDeletePod(t *testing.T) {
key := "/registry/pods/foo"
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
DesiredState: api.PodState{Host: "machine"},
}), 0)
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(latest.Codec, &api.ContainerManifestList{
@ -372,7 +372,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
key := "/registry/pods/foo"
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
DesiredState: api.PodState{Host: "machine"},
}), 0)
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(latest.Codec, &api.ContainerManifestList{
@ -458,13 +458,13 @@ func TestEtcdListPods(t *testing.T) {
Nodes: []*etcd.Node{
{
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
DesiredState: api.PodState{Host: "machine"},
}),
},
{
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
JSONBase: api.JSONBase{ID: "bar"},
TypeMeta: api.TypeMeta{ID: "bar"},
DesiredState: api.PodState{Host: "machine"},
}),
},
@ -536,10 +536,10 @@ func TestEtcdListControllers(t *testing.T) {
Node: &etcd.Node{
Nodes: []*etcd.Node{
{
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}),
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "foo"}}),
},
{
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{JSONBase: api.JSONBase{ID: "bar"}}),
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "bar"}}),
},
},
},
@ -560,7 +560,7 @@ func TestEtcdListControllers(t *testing.T) {
func TestEtcdGetController(t *testing.T) {
ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.Set("/registry/controllers/foo", runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
fakeClient.Set("/registry/controllers/foo", runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient)
ctrl, err := registry.GetController(ctx, "foo")
if err != nil {
@ -614,7 +614,7 @@ func TestEtcdCreateController(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t)
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreateController(ctx, &api.ReplicationController{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
})
@ -640,11 +640,11 @@ func TestEtcdCreateController(t *testing.T) {
func TestEtcdCreateControllerAlreadyExisting(t *testing.T) {
ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.Set("/registry/controllers/foo", runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
fakeClient.Set("/registry/controllers/foo", runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreateController(ctx, &api.ReplicationController{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
})
@ -658,10 +658,10 @@ func TestEtcdUpdateController(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.TestIndex = true
resp, _ := fakeClient.Set("/registry/controllers/foo", runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
resp, _ := fakeClient.Set("/registry/controllers/foo", runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient)
err := registry.UpdateController(ctx, &api.ReplicationController{
JSONBase: api.JSONBase{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex},
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex},
DesiredState: api.ReplicationControllerState{
Replicas: 2,
},
@ -685,10 +685,10 @@ func TestEtcdListServices(t *testing.T) {
Node: &etcd.Node{
Nodes: []*etcd.Node{
{
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{JSONBase: api.JSONBase{ID: "foo"}}),
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{ID: "foo"}}),
},
{
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{JSONBase: api.JSONBase{ID: "bar"}}),
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{ID: "bar"}}),
},
},
},
@ -711,7 +711,7 @@ func TestEtcdCreateService(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t)
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreateService(ctx, &api.Service{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
})
if err != nil {
t.Errorf("unexpected error: %v", err)
@ -736,10 +736,10 @@ func TestEtcdCreateService(t *testing.T) {
func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.Set("/registry/services/specs/foo", runtime.EncodeOrDie(latest.Codec, &api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
fakeClient.Set("/registry/services/specs/foo", runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{ID: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreateService(ctx, &api.Service{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
})
if !errors.IsAlreadyExists(err) {
t.Errorf("expected already exists err, got %#v", err)
@ -749,7 +749,7 @@ func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
func TestEtcdGetService(t *testing.T) {
ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.Set("/registry/services/specs/foo", runtime.EncodeOrDie(latest.Codec, &api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
fakeClient.Set("/registry/services/specs/foo", runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{ID: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient)
service, err := registry.GetService(ctx, "foo")
if err != nil {
@ -804,10 +804,10 @@ func TestEtcdUpdateService(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.TestIndex = true
resp, _ := fakeClient.Set("/registry/services/specs/foo", runtime.EncodeOrDie(latest.Codec, &api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
resp, _ := fakeClient.Set("/registry/services/specs/foo", runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{ID: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient)
testService := api.Service{
JSONBase: api.JSONBase{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex},
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex},
Labels: map[string]string{
"baz": "bar",
},
@ -842,10 +842,10 @@ func TestEtcdListEndpoints(t *testing.T) {
Node: &etcd.Node{
Nodes: []*etcd.Node{
{
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}),
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}),
},
{
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{JSONBase: api.JSONBase{ID: "bar"}}),
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "bar"}}),
},
},
},
@ -868,7 +868,7 @@ func TestEtcdGetEndpoints(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t)
registry := NewTestEtcdRegistry(fakeClient)
endpoints := &api.Endpoints{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"127.0.0.1:34855"},
}
@ -890,7 +890,7 @@ func TestEtcdUpdateEndpoints(t *testing.T) {
fakeClient.TestIndex = true
registry := NewTestEtcdRegistry(fakeClient)
endpoints := api.Endpoints{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Endpoints: []string{"baz", "bar"},
}

View File

@ -78,7 +78,7 @@ func (m *minionList) List() (currentMinions *api.MinionList, err error) {
minions := []api.Minion{}
for minion := range m.minions {
minions = append(minions, api.Minion{
JSONBase: api.JSONBase{ID: minion},
TypeMeta: api.TypeMeta{ID: minion},
NodeResources: m.nodeResources,
})
}

View File

@ -99,5 +99,5 @@ func (rs *REST) Update(ctx api.Context, minion runtime.Object) (<-chan runtime.O
}
func (rs *REST) toApiMinion(name string) *api.Minion {
return &api.Minion{JSONBase: api.JSONBase{ID: name}}
return &api.Minion{TypeMeta: api.TypeMeta{ID: name}}
}

View File

@ -37,7 +37,7 @@ func TestMinionREST(t *testing.T) {
t.Errorf("has unexpected object")
}
c, err := ms.Create(ctx, &api.Minion{JSONBase: api.JSONBase{ID: "baz"}})
c, err := ms.Create(ctx, &api.Minion{TypeMeta: api.TypeMeta{ID: "baz"}})
if err != nil {
t.Errorf("insert failed")
}
@ -72,9 +72,9 @@ func TestMinionREST(t *testing.T) {
}
expect := []api.Minion{
{
JSONBase: api.JSONBase{ID: "baz"},
TypeMeta: api.TypeMeta{ID: "baz"},
}, {
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
},
}
nodeList := list.(*api.MinionList)

View File

@ -32,7 +32,7 @@ func TestMakeManifestNoServices(t *testing.T) {
}
manifest, err := factory.MakeManifest("machine", api.Pod{
JSONBase: api.JSONBase{ID: "foobar"},
TypeMeta: api.TypeMeta{ID: "foobar"},
DesiredState: api.PodState{
Manifest: api.ContainerManifest{
Containers: []api.Container{
@ -63,7 +63,7 @@ func TestMakeManifestServices(t *testing.T) {
List: api.ServiceList{
Items: []api.Service{
{
JSONBase: api.JSONBase{ID: "test"},
TypeMeta: api.TypeMeta{ID: "test"},
Port: 8080,
ContainerPort: util.IntOrString{
Kind: util.IntstrInt,
@ -143,7 +143,7 @@ func TestMakeManifestServicesExistingEnvVar(t *testing.T) {
List: api.ServiceList{
Items: []api.Service{
{
JSONBase: api.JSONBase{ID: "test"},
TypeMeta: api.TypeMeta{ID: "test"},
Port: 8080,
ContainerPort: util.IntOrString{
Kind: util.IntstrInt,

View File

@ -90,7 +90,7 @@ func NewREST(config *RESTConfig) *REST {
func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) {
pod := obj.(*api.Pod)
if !api.ValidNamespace(ctx, &pod.JSONBase) {
if !api.ValidNamespace(ctx, &pod.TypeMeta) {
return nil, errors.NewConflict("pod", pod.Namespace, fmt.Errorf("Pod.Namespace does not match the provided context"))
}
pod.DesiredState.Manifest.UUID = uuid.NewUUID().String()
@ -186,7 +186,7 @@ func (*REST) New() runtime.Object {
func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) {
pod := obj.(*api.Pod)
if !api.ValidNamespace(ctx, &pod.JSONBase) {
if !api.ValidNamespace(ctx, &pod.TypeMeta) {
return nil, errors.NewConflict("pod", pod.Namespace, fmt.Errorf("Pod.Namespace does not match the provided context"))
}
if errs := validation.ValidatePod(pod); len(errs) > 0 {

View File

@ -143,7 +143,7 @@ func TestListPodsError(t *testing.T) {
}
func TestListEmptyPodList(t *testing.T) {
podRegistry := registrytest.NewPodRegistry(&api.PodList{JSONBase: api.JSONBase{ResourceVersion: 1}})
podRegistry := registrytest.NewPodRegistry(&api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: 1}})
storage := REST{
registry: podRegistry,
}
@ -174,12 +174,12 @@ func TestListPodList(t *testing.T) {
podRegistry.Pods = &api.PodList{
Items: []api.Pod{
{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
},
{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "bar",
},
},
@ -213,18 +213,18 @@ func TestListPodListSelection(t *testing.T) {
podRegistry.Pods = &api.PodList{
Items: []api.Pod{
{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
}, {
JSONBase: api.JSONBase{ID: "bar"},
TypeMeta: api.TypeMeta{ID: "bar"},
DesiredState: api.PodState{Host: "barhost"},
}, {
JSONBase: api.JSONBase{ID: "baz"},
TypeMeta: api.TypeMeta{ID: "baz"},
DesiredState: api.PodState{Status: "bazstatus"},
}, {
JSONBase: api.JSONBase{ID: "qux"},
TypeMeta: api.TypeMeta{ID: "qux"},
Labels: map[string]string{"label": "qux"},
}, {
JSONBase: api.JSONBase{ID: "zot"},
TypeMeta: api.TypeMeta{ID: "zot"},
},
},
}
@ -297,7 +297,7 @@ func TestPodDecode(t *testing.T) {
registry: podRegistry,
}
expected := &api.Pod{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
},
}
@ -318,7 +318,7 @@ func TestPodDecode(t *testing.T) {
func TestGetPod(t *testing.T) {
podRegistry := registrytest.NewPodRegistry(nil)
podRegistry.Pod = &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
storage := REST{
registry: podRegistry,
ipCache: ipCache{},
@ -339,7 +339,7 @@ func TestGetPod(t *testing.T) {
func TestGetPodCloud(t *testing.T) {
fakeCloud := &fake_cloud.FakeCloud{}
podRegistry := registrytest.NewPodRegistry(nil)
podRegistry.Pod = &api.Pod{JSONBase: api.JSONBase{ID: "foo"}, CurrentState: api.PodState{Host: "machine"}}
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}, CurrentState: api.PodState{Host: "machine"}}
clock := &fakeClock{t: time.Now()}
@ -385,7 +385,7 @@ func TestMakePodStatus(t *testing.T) {
Minions: api.MinionList{
Items: []api.Minion{
{
JSONBase: api.JSONBase{ID: "machine"},
TypeMeta: api.TypeMeta{ID: "machine"},
},
},
},
@ -560,7 +560,7 @@ func TestPodStorageValidatesUpdate(t *testing.T) {
func TestCreatePod(t *testing.T) {
podRegistry := registrytest.NewPodRegistry(nil)
podRegistry.Pod = &api.Pod{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
CurrentState: api.PodState{
Host: "machine",
},
@ -575,7 +575,7 @@ func TestCreatePod(t *testing.T) {
},
}
pod := &api.Pod{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
DesiredState: desiredState,
}
ctx := api.NewDefaultContext()

View File

@ -55,7 +55,7 @@ func (r *MinionRegistry) Insert(minion string) error {
r.Lock()
defer r.Unlock()
r.Minion = minion
r.Minions.Items = append(r.Minions.Items, api.Minion{JSONBase: api.JSONBase{ID: minion}})
r.Minions.Items = append(r.Minions.Items, api.Minion{TypeMeta: api.TypeMeta{ID: minion}})
return r.Err
}
@ -76,7 +76,7 @@ func (r *MinionRegistry) Delete(minion string) error {
var newList []api.Minion
for _, node := range r.Minions.Items {
if node.ID != minion {
newList = append(newList, api.Minion{JSONBase: api.JSONBase{ID: node.ID}})
newList = append(newList, api.Minion{TypeMeta: api.TypeMeta{ID: node.ID}})
}
}
r.Minions.Items = newList

View File

@ -52,7 +52,7 @@ func NewREST(registry Registry, cloud cloudprovider.Interface, machines minion.R
func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) {
srv := obj.(*api.Service)
if !api.ValidNamespace(ctx, &srv.JSONBase) {
if !api.ValidNamespace(ctx, &srv.TypeMeta) {
return nil, errors.NewConflict("service", srv.Namespace, fmt.Errorf("Service.Namespace does not match the provided context"))
}
if errs := validation.ValidateService(srv); len(errs) > 0 {
@ -176,7 +176,7 @@ func GetServiceEnvironmentVariables(ctx api.Context, registry Registry, machine
func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) {
srv := obj.(*api.Service)
if !api.ValidNamespace(ctx, &srv.JSONBase) {
if !api.ValidNamespace(ctx, &srv.TypeMeta) {
return nil, errors.NewConflict("service", srv.Namespace, fmt.Errorf("Service.Namespace does not match the provided context"))
}
if errs := validation.ValidateService(srv); len(errs) > 0 {
@ -224,7 +224,7 @@ func (rs *REST) deleteExternalLoadBalancer(service *api.Service) error {
if err != nil {
return err
}
if err := balancer.DeleteTCPLoadBalancer(service.JSONBase.ID, zone.Region); err != nil {
if err := balancer.DeleteTCPLoadBalancer(service.TypeMeta.ID, zone.Region); err != nil {
return err
}
return nil

View File

@ -37,7 +37,7 @@ func TestServiceRegistryCreate(t *testing.T) {
storage := NewREST(registry, fakeCloud, minion.NewRegistry(machines, api.NodeResources{}))
svc := &api.Service{
Port: 6502,
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
}
ctx := api.NewDefaultContext()
@ -68,11 +68,11 @@ func TestServiceStorageValidatesCreate(t *testing.T) {
failureCases := map[string]api.Service{
"empty ID": {
Port: 6502,
JSONBase: api.JSONBase{ID: ""},
TypeMeta: api.TypeMeta{ID: ""},
Selector: map[string]string{"bar": "baz"},
},
"empty selector": {
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{},
},
}
@ -94,13 +94,13 @@ func TestServiceRegistryUpdate(t *testing.T) {
registry := registrytest.NewServiceRegistry()
registry.CreateService(ctx, &api.Service{
Port: 6502,
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz1"},
})
storage := NewREST(registry, nil, nil)
c, err := storage.Update(ctx, &api.Service{
Port: 6502,
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz2"},
})
if c == nil {
@ -124,19 +124,19 @@ func TestServiceStorageValidatesUpdate(t *testing.T) {
registry := registrytest.NewServiceRegistry()
registry.CreateService(ctx, &api.Service{
Port: 6502,
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
})
storage := NewREST(registry, nil, nil)
failureCases := map[string]api.Service{
"empty ID": {
Port: 6502,
JSONBase: api.JSONBase{ID: ""},
TypeMeta: api.TypeMeta{ID: ""},
Selector: map[string]string{"bar": "baz"},
},
"empty selector": {
Port: 6502,
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{},
},
}
@ -159,7 +159,7 @@ func TestServiceRegistryExternalService(t *testing.T) {
storage := NewREST(registry, fakeCloud, minion.NewRegistry(machines, api.NodeResources{}))
svc := &api.Service{
Port: 6502,
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
CreateExternalLoadBalancer: true,
}
@ -186,7 +186,7 @@ func TestServiceRegistryExternalServiceError(t *testing.T) {
storage := NewREST(registry, fakeCloud, minion.NewRegistry(machines, api.NodeResources{}))
svc := &api.Service{
Port: 6502,
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
CreateExternalLoadBalancer: true,
}
@ -208,7 +208,7 @@ func TestServiceRegistryDelete(t *testing.T) {
machines := []string{"foo", "bar", "baz"}
storage := NewREST(registry, fakeCloud, minion.NewRegistry(machines, api.NodeResources{}))
svc := &api.Service{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
}
registry.CreateService(ctx, svc)
@ -229,7 +229,7 @@ func TestServiceRegistryDeleteExternal(t *testing.T) {
machines := []string{"foo", "bar", "baz"}
storage := NewREST(registry, fakeCloud, minion.NewRegistry(machines, api.NodeResources{}))
svc := &api.Service{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
CreateExternalLoadBalancer: true,
}
@ -250,19 +250,19 @@ func TestServiceRegistryMakeLinkVariables(t *testing.T) {
registry.List = api.ServiceList{
Items: []api.Service{
{
JSONBase: api.JSONBase{ID: "foo-bar"},
TypeMeta: api.TypeMeta{ID: "foo-bar"},
Selector: map[string]string{"bar": "baz"},
Port: 8080,
Protocol: "TCP",
},
{
JSONBase: api.JSONBase{ID: "abc-123"},
TypeMeta: api.TypeMeta{ID: "abc-123"},
Selector: map[string]string{"bar": "baz"},
Port: 8081,
Protocol: "UDP",
},
{
JSONBase: api.JSONBase{ID: "q-u-u-x"},
TypeMeta: api.TypeMeta{ID: "q-u-u-x"},
Selector: map[string]string{"bar": "baz"},
Port: 8082,
Protocol: "",
@ -316,7 +316,7 @@ func TestServiceRegistryGet(t *testing.T) {
machines := []string{"foo", "bar", "baz"}
storage := NewREST(registry, fakeCloud, minion.NewRegistry(machines, api.NodeResources{}))
registry.CreateService(ctx, &api.Service{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
})
storage.Get(ctx, "foo")
@ -336,7 +336,7 @@ func TestServiceRegistryResourceLocation(t *testing.T) {
machines := []string{"foo", "bar", "baz"}
storage := NewREST(registry, fakeCloud, minion.NewRegistry(machines, api.NodeResources{}))
registry.CreateService(ctx, &api.Service{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
})
redirector := apiserver.Redirector(storage)
@ -365,11 +365,11 @@ func TestServiceRegistryList(t *testing.T) {
machines := []string{"foo", "bar", "baz"}
storage := NewREST(registry, fakeCloud, minion.NewRegistry(machines, api.NodeResources{}))
registry.CreateService(ctx, &api.Service{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
})
registry.CreateService(ctx, &api.Service{
JSONBase: api.JSONBase{ID: "foo2"},
TypeMeta: api.TypeMeta{ID: "foo2"},
Selector: map[string]string{"bar2": "baz2"},
})
registry.List.ResourceVersion = 1

View File

@ -17,7 +17,7 @@ limitations under the License.
// Package runtime includes helper functions for working with API objects
// that follow the kubernetes API object conventions, which are:
//
// 0. Your API objects have a common metadata struct member, JSONBase.
// 0. Your API objects have a common metadata struct member, TypeMeta.
// 1. Your code refers to an internal set of API objects.
// 2. In a separate package, you have an external set of API objects.
// 3. The external set is considered to be versioned, and no breaking

View File

@ -28,13 +28,13 @@ var scheme = runtime.NewScheme()
var Codec = runtime.CodecFor(scheme, "v1test")
type EmbeddedTest struct {
runtime.JSONBase `yaml:",inline" json:",inline"`
runtime.TypeMeta `yaml:",inline" json:",inline"`
Object runtime.EmbeddedObject `yaml:"object,omitempty" json:"object,omitempty"`
EmptyObject runtime.EmbeddedObject `yaml:"emptyObject,omitempty" json:"emptyObject,omitempty"`
}
type EmbeddedTestExternal struct {
runtime.JSONBase `yaml:",inline" json:",inline"`
runtime.TypeMeta `yaml:",inline" json:",inline"`
Object runtime.RawExtension `yaml:"object,omitempty" json:"object,omitempty"`
EmptyObject runtime.RawExtension `yaml:"emptyObject,omitempty" json:"emptyObject,omitempty"`
}
@ -48,10 +48,10 @@ func TestEmbeddedObject(t *testing.T) {
s.AddKnownTypeWithName("v1test", "EmbeddedTest", &EmbeddedTestExternal{})
outer := &EmbeddedTest{
JSONBase: runtime.JSONBase{ID: "outer"},
TypeMeta: runtime.TypeMeta{ID: "outer"},
Object: runtime.EmbeddedObject{
&EmbeddedTest{
JSONBase: runtime.JSONBase{ID: "inner"},
TypeMeta: runtime.TypeMeta{ID: "inner"},
},
},
}

View File

@ -29,9 +29,9 @@ import (
func TestExtractList(t *testing.T) {
pl := &api.PodList{
Items: []api.Pod{
{JSONBase: api.JSONBase{ID: "1"}},
{JSONBase: api.JSONBase{ID: "2"}},
{JSONBase: api.JSONBase{ID: "3"}},
{TypeMeta: api.TypeMeta{ID: "1"}},
{TypeMeta: api.TypeMeta{ID: "2"}},
{TypeMeta: api.TypeMeta{ID: "3"}},
},
}
list, err := runtime.ExtractList(pl)
@ -51,9 +51,9 @@ func TestExtractList(t *testing.T) {
func TestSetList(t *testing.T) {
pl := &api.PodList{}
list := []runtime.Object{
&api.Pod{JSONBase: api.JSONBase{ID: "1"}},
&api.Pod{JSONBase: api.JSONBase{ID: "2"}},
&api.Pod{JSONBase: api.JSONBase{ID: "3"}},
&api.Pod{TypeMeta: api.TypeMeta{ID: "1"}},
&api.Pod{TypeMeta: api.TypeMeta{ID: "2"}},
&api.Pod{TypeMeta: api.TypeMeta{ID: "3"}},
}
err := runtime.SetList(pl, list)
if err != nil {

View File

@ -21,9 +21,9 @@ import (
"reflect"
)
// NewJSONBaseResourceVersioner returns a ResourceVersioner that can set or
// retrieve ResourceVersion on objects derived from JSONBase.
func NewJSONBaseResourceVersioner() ResourceVersioner {
// NewTypeMetaResourceVersioner returns a ResourceVersioner that can set or
// retrieve ResourceVersion on objects derived from TypeMeta.
func NewTypeMetaResourceVersioner() ResourceVersioner {
return jsonBaseModifier{}
}
@ -31,7 +31,7 @@ func NewJSONBaseResourceVersioner() ResourceVersioner {
type jsonBaseModifier struct{}
func (v jsonBaseModifier) ResourceVersion(obj Object) (uint64, error) {
json, err := FindJSONBase(obj)
json, err := FindTypeMeta(obj)
if err != nil {
return 0, err
}
@ -39,7 +39,7 @@ func (v jsonBaseModifier) ResourceVersion(obj Object) (uint64, error) {
}
func (v jsonBaseModifier) SetResourceVersion(obj Object, version uint64) error {
json, err := FindJSONBase(obj)
json, err := FindTypeMeta(obj)
if err != nil {
return err
}
@ -48,7 +48,7 @@ func (v jsonBaseModifier) SetResourceVersion(obj Object, version uint64) error {
}
func (v jsonBaseModifier) ID(obj Object) (string, error) {
json, err := FindJSONBase(obj)
json, err := FindTypeMeta(obj)
if err != nil {
return "", err
}
@ -56,7 +56,7 @@ func (v jsonBaseModifier) ID(obj Object) (string, error) {
}
func (v jsonBaseModifier) SelfLink(obj Object) (string, error) {
json, err := FindJSONBase(obj)
json, err := FindTypeMeta(obj)
if err != nil {
return "", err
}
@ -64,7 +64,7 @@ func (v jsonBaseModifier) SelfLink(obj Object) (string, error) {
}
func (v jsonBaseModifier) SetSelfLink(obj Object, selfLink string) error {
json, err := FindJSONBase(obj)
json, err := FindTypeMeta(obj)
if err != nil {
return err
}
@ -72,14 +72,14 @@ func (v jsonBaseModifier) SetSelfLink(obj Object, selfLink string) error {
return nil
}
// NewJSONBaseSelfLinker returns a SelfLinker that works on all JSONBase SelfLink fields.
func NewJSONBaseSelfLinker() SelfLinker {
// NewTypeMetaSelfLinker returns a SelfLinker that works on all TypeMeta SelfLink fields.
func NewTypeMetaSelfLinker() SelfLinker {
return jsonBaseModifier{}
}
// JSONBaseInterface lets you work with a JSONBase from any of the versioned or
// TypeMetaInterface lets you work with a TypeMeta from any of the versioned or
// internal APIObjects.
type JSONBaseInterface interface {
type TypeMetaInterface interface {
ID() string
SetID(ID string)
APIVersion() string
@ -92,7 +92,7 @@ type JSONBaseInterface interface {
SetSelfLink(selfLink string)
}
type genericJSONBase struct {
type genericTypeMeta struct {
id *string
apiVersion *string
kind *string
@ -100,43 +100,43 @@ type genericJSONBase struct {
selfLink *string
}
func (g genericJSONBase) ID() string {
func (g genericTypeMeta) ID() string {
return *g.id
}
func (g genericJSONBase) SetID(id string) {
func (g genericTypeMeta) SetID(id string) {
*g.id = id
}
func (g genericJSONBase) APIVersion() string {
func (g genericTypeMeta) APIVersion() string {
return *g.apiVersion
}
func (g genericJSONBase) SetAPIVersion(version string) {
func (g genericTypeMeta) SetAPIVersion(version string) {
*g.apiVersion = version
}
func (g genericJSONBase) Kind() string {
func (g genericTypeMeta) Kind() string {
return *g.kind
}
func (g genericJSONBase) SetKind(kind string) {
func (g genericTypeMeta) SetKind(kind string) {
*g.kind = kind
}
func (g genericJSONBase) ResourceVersion() uint64 {
func (g genericTypeMeta) ResourceVersion() uint64 {
return *g.resourceVersion
}
func (g genericJSONBase) SetResourceVersion(version uint64) {
func (g genericTypeMeta) SetResourceVersion(version uint64) {
*g.resourceVersion = version
}
func (g genericJSONBase) SelfLink() string {
func (g genericTypeMeta) SelfLink() string {
return *g.selfLink
}
func (g genericJSONBase) SetSelfLink(selfLink string) {
func (g genericTypeMeta) SetSelfLink(selfLink string) {
*g.selfLink = selfLink
}
@ -165,11 +165,11 @@ func fieldPtr(v reflect.Value, fieldName string, dest interface{}) error {
return fmt.Errorf("Couldn't assign/convert %v to %v", field.Type(), v.Type())
}
// newGenericJSONBase creates a new generic JSONBase from v, which must be an
// addressable/setable reflect.Value having the same fields as api.JSONBase.
// newGenericTypeMeta creates a new generic TypeMeta from v, which must be an
// addressable/setable reflect.Value having the same fields as api.TypeMeta.
// Returns an error if this isn't the case.
func newGenericJSONBase(v reflect.Value) (genericJSONBase, error) {
g := genericJSONBase{}
func newGenericTypeMeta(v reflect.Value) (genericTypeMeta, error) {
g := genericTypeMeta{}
if err := fieldPtr(v, "ID", &g.id); err != nil {
return g, err
}

View File

@ -23,8 +23,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
func TestGenericJSONBase(t *testing.T) {
type JSONBase struct {
func TestGenericTypeMeta(t *testing.T) {
type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
@ -32,19 +32,19 @@ func TestGenericJSONBase(t *testing.T) {
ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
}
j := JSONBase{
j := TypeMeta{
ID: "foo",
APIVersion: "a",
Kind: "b",
ResourceVersion: 1,
SelfLink: "some/place/only/we/know",
}
g, err := newGenericJSONBase(reflect.ValueOf(&j).Elem())
g, err := newGenericTypeMeta(reflect.ValueOf(&j).Elem())
if err != nil {
t.Fatalf("new err: %v", err)
}
// Prove g supports JSONBaseInterface.
jbi := JSONBaseInterface(g)
// Prove g supports TypeMetaInterface.
jbi := TypeMetaInterface(g)
if e, a := "foo", jbi.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
@ -86,7 +86,7 @@ func TestGenericJSONBase(t *testing.T) {
}
type MyAPIObject struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
}
func (*MyAPIObject) IsAnAPIObject() {}
@ -103,10 +103,10 @@ func TestResourceVersionerOfAPI(t *testing.T) {
}
testCases := map[string]T{
"empty api object": {&MyAPIObject{}, 0},
"api object with version": {&MyAPIObject{JSONBase: JSONBase{ResourceVersion: 1}}, 1},
"pointer to api object with version": {&MyAPIObject{JSONBase: JSONBase{ResourceVersion: 1}}, 1},
"api object with version": {&MyAPIObject{TypeMeta: TypeMeta{ResourceVersion: 1}}, 1},
"pointer to api object with version": {&MyAPIObject{TypeMeta: TypeMeta{ResourceVersion: 1}}, 1},
}
versioning := NewJSONBaseResourceVersioner()
versioning := NewTypeMetaResourceVersioner()
for key, testCase := range testCases {
actual, err := versioning.ResourceVersion(testCase.Object)
if err != nil {
@ -134,7 +134,7 @@ func TestResourceVersionerOfAPI(t *testing.T) {
Object
Expected uint64
}{
"pointer to api object with version": {&MyAPIObject{JSONBase: JSONBase{ResourceVersion: 1}}, 1},
"pointer to api object with version": {&MyAPIObject{TypeMeta: TypeMeta{ResourceVersion: 1}}, 1},
}
for key, testCase := range setCases {
if err := versioning.SetResourceVersion(testCase.Object, 5); err != nil {
@ -150,7 +150,7 @@ func TestResourceVersionerOfAPI(t *testing.T) {
}
}
func TestJSONBaseSelfLinker(t *testing.T) {
func TestTypeMetaSelfLinker(t *testing.T) {
table := map[string]struct {
obj Object
expect string
@ -158,7 +158,7 @@ func TestJSONBaseSelfLinker(t *testing.T) {
succeed bool
}{
"normal": {
obj: &MyAPIObject{JSONBase: JSONBase{SelfLink: "foobar"}},
obj: &MyAPIObject{TypeMeta: TypeMeta{SelfLink: "foobar"}},
expect: "foobar",
try: "newbar",
succeed: true,
@ -169,7 +169,7 @@ func TestJSONBaseSelfLinker(t *testing.T) {
},
}
linker := NewJSONBaseSelfLinker()
linker := NewTypeMetaSelfLinker()
for name, item := range table {
got, err := linker.SelfLink(item.obj)
if e, a := item.succeed, err == nil; e != a {

View File

@ -247,9 +247,9 @@ func (s *Scheme) Convert(in, out interface{}) error {
return s.raw.Convert(in, out)
}
// FindJSONBase takes an arbitary api type, returns pointer to its JSONBase field.
// FindTypeMeta takes an arbitary api type, returns pointer to its TypeMeta field.
// obj must be a pointer to an api type.
func FindJSONBase(obj Object) (JSONBaseInterface, error) {
func FindTypeMeta(obj Object) (TypeMetaInterface, error) {
v, err := enforcePtr(obj)
if err != nil {
return nil, err
@ -259,11 +259,11 @@ func FindJSONBase(obj Object) (JSONBaseInterface, error) {
if v.Kind() != reflect.Struct {
return nil, fmt.Errorf("expected struct, but got %v: %v (%#v)", v.Kind(), name, v.Interface())
}
jsonBase := v.FieldByName("JSONBase")
jsonBase := v.FieldByName("TypeMeta")
if !jsonBase.IsValid() {
return nil, fmt.Errorf("struct %v lacks embedded JSON type", name)
}
g, err := newGenericJSONBase(jsonBase)
g, err := newGenericTypeMeta(jsonBase)
if err != nil {
return nil, err
}
@ -271,7 +271,7 @@ func FindJSONBase(obj Object) (JSONBaseInterface, error) {
}
// EncodeToVersion turns the given api object into an appropriate JSON string.
// Will return an error if the object doesn't have an embedded JSONBase.
// Will return an error if the object doesn't have an embedded TypeMeta.
// Obj may be a pointer to a struct, or a struct. If a struct, a copy
// must be made. If a pointer, the object may be modified before encoding,
// but will be put back into its original state before returning.
@ -390,9 +390,9 @@ func ObjectDiff(a, b Object) string {
// metaInsertion implements conversion.MetaInsertionFactory, which lets the conversion
// package figure out how to encode our object's types and versions. These fields are
// located in our JSONBase.
// located in our TypeMeta.
type metaInsertion struct {
JSONBase struct {
TypeMeta struct {
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
} `json:",inline" yaml:",inline"`
@ -401,8 +401,8 @@ type metaInsertion struct {
// Create returns a new metaInsertion with the version and kind fields set.
func (metaInsertion) Create(version, kind string) interface{} {
m := metaInsertion{}
m.JSONBase.APIVersion = version
m.JSONBase.Kind = kind
m.TypeMeta.APIVersion = version
m.TypeMeta.Kind = kind
return &m
}
@ -410,5 +410,5 @@ func (metaInsertion) Create(version, kind string) interface{} {
// a metaInsertion pointer object.
func (metaInsertion) Interpret(in interface{}) (version, kind string) {
m := in.(*metaInsertion)
return m.JSONBase.APIVersion, m.JSONBase.Kind
return m.TypeMeta.APIVersion, m.TypeMeta.Kind
}

View File

@ -24,18 +24,18 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
type JSONBase struct {
type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
}
type InternalSimple struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
TestString string `json:"testString" yaml:"testString"`
}
type ExternalSimple struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
TestString string `json:"testString" yaml:"testString"`
}
@ -59,7 +59,7 @@ func TestScheme(t *testing.T) {
if e, a := "externalVersion", scope.Meta().DestVersion; e != a {
t.Errorf("Expected '%v', got '%v'", e, a)
}
scope.Convert(&in.JSONBase, &out.JSONBase, 0)
scope.Convert(&in.TypeMeta, &out.TypeMeta, 0)
scope.Convert(&in.TestString, &out.TestString, 0)
internalToExternalCalls++
return nil
@ -71,7 +71,7 @@ func TestScheme(t *testing.T) {
if e, a := "", scope.Meta().DestVersion; e != a {
t.Errorf("Expected '%v', got '%v'", e, a)
}
scope.Convert(&in.JSONBase, &out.JSONBase, 0)
scope.Convert(&in.TypeMeta, &out.TypeMeta, 0)
scope.Convert(&in.TestString, &out.TestString, 0)
externalToInternalCalls++
return nil
@ -150,12 +150,12 @@ type ExtensionB struct {
}
type ExternalExtensionType struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Extension runtime.RawExtension `json:"extension" yaml:"extension"`
}
type InternalExtensionType struct {
JSONBase `json:",inline" yaml:",inline"`
TypeMeta `json:",inline" yaml:",inline"`
Extension runtime.EmbeddedObject `json:"extension" yaml:"extension"`
}

View File

@ -23,18 +23,18 @@ import (
// Note that the types provided in this file are not versioned and are intended to be
// safe to use from within all versions of every API object.
// JSONBase is shared by all top level objects. The proper way to use it is to inline it in your type,
// TypeMeta is shared by all top level objects. The proper way to use it is to inline it in your type,
// like this:
// type MyAwesomeAPIObject struct {
// runtime.JSONBase `yaml:",inline" json:",inline"`
// runtime.TypeMeta `yaml:",inline" json:",inline"`
// ... // other fields
// }
// func (*MyAwesomeAPIObject) IsAnAPIObject() {}
//
// JSONBase is provided here for convenience. You may use it directly from this package or define
// TypeMeta is provided here for convenience. You may use it directly from this package or define
// your own with the same fields.
//
type JSONBase struct {
type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
@ -43,7 +43,7 @@ type JSONBase struct {
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
}
// PluginBase is like JSONBase, but it's intended for plugin objects that won't ever be encoded
// PluginBase is like TypeMeta, but it's intended for plugin objects that won't ever be encoded
// except while embedded in other objects.
type PluginBase struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
@ -71,7 +71,7 @@ type EmbeddedObject struct {
//
// // Internal package:
// type MyAPIObject struct {
// runtime.JSONBase `yaml:",inline" json:",inline"`
// runtime.TypeMeta `yaml:",inline" json:",inline"`
// MyPlugin runtime.EmbeddedObject `json:"myPlugin" yaml:"myPlugin"`
// }
// type PluginA struct {
@ -81,7 +81,7 @@ type EmbeddedObject struct {
//
// // External package:
// type MyAPIObject struct {
// runtime.JSONBase `yaml:",inline" json:",inline"`
// runtime.TypeMeta `yaml:",inline" json:",inline"`
// MyPlugin runtime.RawExtension `json:"myPlugin" yaml:"myPlugin"`
// }
// type PluginA struct {
@ -112,10 +112,10 @@ type RawExtension struct {
// Unknown allows api objects with unknown types to be passed-through. This can be used
// to deal with the API objects from a plug-in. Unknown objects still have functioning
// JSONBase features-- kind, version, resourceVersion, etc.
// TypeMeta features-- kind, version, resourceVersion, etc.
// TODO: Not implemented yet!
type Unknown struct {
JSONBase `yaml:",inline" json:",inline"`
TypeMeta `yaml:",inline" json:",inline"`
// RawJSON will hold the complete JSON of the object which couldn't be matched
// with a registered type. Most likely, nothing should be done with this
// except for passing it through the system.

View File

@ -85,7 +85,7 @@ func TestGenericScheduler(t *testing.T) {
predicates: []FitPredicate{matchesPredicate},
prioritizer: EqualPriority,
nodes: []string{"machine1", "machine2"},
pod: api.Pod{JSONBase: api.JSONBase{ID: "machine2"}},
pod: api.Pod{TypeMeta: api.TypeMeta{ID: "machine2"}},
expectedHost: "machine2",
},
{
@ -98,7 +98,7 @@ func TestGenericScheduler(t *testing.T) {
predicates: []FitPredicate{matchesPredicate},
prioritizer: numericPriority,
nodes: []string{"3", "2", "1"},
pod: api.Pod{JSONBase: api.JSONBase{ID: "2"}},
pod: api.Pod{TypeMeta: api.TypeMeta{ID: "2"}},
expectedHost: "2",
},
{

View File

@ -77,7 +77,7 @@ func (e *EndpointController) SyncServiceEndpoints() error {
// TODO this is brittle as all get out, refactor the client libraries to return a structured error.
if errors.IsNotFound(err) {
currentEndpoints = &api.Endpoints{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: service.ID,
},
}

View File

@ -34,7 +34,7 @@ func newPodList(count int) api.PodList {
pods := []api.Pod{}
for i := 0; i < count; i++ {
pods = append(pods, api.Pod{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: fmt.Sprintf("pod%d", i),
APIVersion: testapi.Version(),
},
@ -57,7 +57,7 @@ func newPodList(count int) api.PodList {
})
}
return api.PodList{
JSONBase: api.JSONBase{APIVersion: testapi.Version(), Kind: "PodList"},
TypeMeta: api.TypeMeta{APIVersion: testapi.Version(), Kind: "PodList"},
Items: pods,
}
}
@ -181,7 +181,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
serviceList := api.ServiceList{
Items: []api.Service{
{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{
"foo": "bar",
},
@ -192,7 +192,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
serverResponse{http.StatusOK, newPodList(1)},
serverResponse{http.StatusOK, serviceList},
serverResponse{http.StatusOK, api.Endpoints{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
ResourceVersion: 1,
},
@ -204,7 +204,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
t.Errorf("unexpected error: %v", err)
}
data := runtime.EncodeOrDie(testapi.CodecForVersionOrDie(), &api.Endpoints{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ID: "foo",
ResourceVersion: 1,
},
@ -217,7 +217,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
serviceList := api.ServiceList{
Items: []api.Service{
{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{
"foo": "bar",
},
@ -228,7 +228,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
serverResponse{http.StatusOK, newPodList(1)},
serverResponse{http.StatusOK, serviceList},
serverResponse{http.StatusOK, api.Endpoints{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ResourceVersion: 1,
},
Endpoints: []string{"1.2.3.4:8080"},
@ -245,7 +245,7 @@ func TestSyncEndpointsItems(t *testing.T) {
serviceList := api.ServiceList{
Items: []api.Service{
{
JSONBase: api.JSONBase{ID: "foo"},
TypeMeta: api.TypeMeta{ID: "foo"},
Selector: map[string]string{
"foo": "bar",
},
@ -262,7 +262,7 @@ func TestSyncEndpointsItems(t *testing.T) {
t.Errorf("unexpected error: %v", err)
}
data := runtime.EncodeOrDie(testapi.CodecForVersionOrDie(), &api.Endpoints{
JSONBase: api.JSONBase{
TypeMeta: api.TypeMeta{
ResourceVersion: 0,
},
Endpoints: []string{"1.2.3.4:8080"},

View File

@ -36,7 +36,7 @@ type fakeClientGetSet struct {
}
type TestResource struct {
api.JSONBase `json:",inline" yaml:",inline"`
api.TypeMeta `json:",inline" yaml:",inline"`
Value int `json:"value" yaml:"value,omitempty"`
}
@ -44,7 +44,7 @@ func (*TestResource) IsAnAPIObject() {}
var scheme *runtime.Scheme
var codec runtime.Codec
var versioner = runtime.NewJSONBaseResourceVersioner()
var versioner = runtime.NewTypeMetaResourceVersioner()
func init() {
scheme = runtime.NewScheme()
@ -89,11 +89,11 @@ func TestExtractToList(t *testing.T) {
},
}
expect := api.PodList{
JSONBase: api.JSONBase{ResourceVersion: 10},
TypeMeta: api.TypeMeta{ResourceVersion: 10},
Items: []api.Pod{
{JSONBase: api.JSONBase{ID: "foo", ResourceVersion: 1}},
{JSONBase: api.JSONBase{ID: "bar", ResourceVersion: 2}},
{JSONBase: api.JSONBase{ID: "baz", ResourceVersion: 3}},
{TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: 1}},
{TypeMeta: api.TypeMeta{ID: "bar", ResourceVersion: 2}},
{TypeMeta: api.TypeMeta{ID: "baz", ResourceVersion: 3}},
},
}
@ -110,7 +110,7 @@ func TestExtractToList(t *testing.T) {
func TestExtractObj(t *testing.T) {
fakeClient := NewFakeEtcdClient(t)
expect := api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
expect := api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
fakeClient.Set("/some/key", util.EncodeJSON(expect), 0)
helper := EtcdHelper{fakeClient, latest.Codec, versioner}
var got api.Pod
@ -164,7 +164,7 @@ func TestExtractObjNotFoundErr(t *testing.T) {
}
func TestCreateObj(t *testing.T) {
obj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
obj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
fakeClient := NewFakeEtcdClient(t)
helper := EtcdHelper{fakeClient, latest.Codec, versioner}
err := helper.CreateObj("/some/key", obj, 5)
@ -185,7 +185,7 @@ func TestCreateObj(t *testing.T) {
}
func TestSetObj(t *testing.T) {
obj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
obj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
fakeClient := NewFakeEtcdClient(t)
helper := EtcdHelper{fakeClient, latest.Codec, versioner}
err := helper.SetObj("/some/key", obj)
@ -204,7 +204,7 @@ func TestSetObj(t *testing.T) {
}
func TestSetObjWithVersion(t *testing.T) {
obj := &api.Pod{JSONBase: api.JSONBase{ID: "foo", ResourceVersion: 1}}
obj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: 1}}
fakeClient := NewFakeEtcdClient(t)
fakeClient.TestIndex = true
fakeClient.Data["/some/key"] = EtcdResponseWithError{
@ -233,7 +233,7 @@ func TestSetObjWithVersion(t *testing.T) {
}
func TestSetObjWithoutResourceVersioner(t *testing.T) {
obj := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
obj := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
fakeClient := NewFakeEtcdClient(t)
helper := EtcdHelper{fakeClient, latest.Codec, nil}
err := helper.SetObj("/some/key", obj)
@ -254,11 +254,11 @@ func TestSetObjWithoutResourceVersioner(t *testing.T) {
func TestAtomicUpdate(t *testing.T) {
fakeClient := NewFakeEtcdClient(t)
fakeClient.TestIndex = true
helper := EtcdHelper{fakeClient, codec, runtime.NewJSONBaseResourceVersioner()}
helper := EtcdHelper{fakeClient, codec, runtime.NewTypeMetaResourceVersioner()}
// Create a new node.
fakeClient.ExpectNotFoundGet("/some/key")
obj := &TestResource{JSONBase: api.JSONBase{ID: "foo"}, Value: 1}
obj := &TestResource{TypeMeta: api.TypeMeta{ID: "foo"}, Value: 1}
err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
return obj, nil
})
@ -277,7 +277,7 @@ func TestAtomicUpdate(t *testing.T) {
// Update an existing node.
callbackCalled := false
objUpdate := &TestResource{JSONBase: api.JSONBase{ID: "foo"}, Value: 2}
objUpdate := &TestResource{TypeMeta: api.TypeMeta{ID: "foo"}, Value: 2}
err = helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
callbackCalled = true
@ -308,11 +308,11 @@ func TestAtomicUpdate(t *testing.T) {
func TestAtomicUpdateNoChange(t *testing.T) {
fakeClient := NewFakeEtcdClient(t)
fakeClient.TestIndex = true
helper := EtcdHelper{fakeClient, codec, runtime.NewJSONBaseResourceVersioner()}
helper := EtcdHelper{fakeClient, codec, runtime.NewTypeMetaResourceVersioner()}
// Create a new node.
fakeClient.ExpectNotFoundGet("/some/key")
obj := &TestResource{JSONBase: api.JSONBase{ID: "foo"}, Value: 1}
obj := &TestResource{TypeMeta: api.TypeMeta{ID: "foo"}, Value: 1}
err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
return obj, nil
})
@ -322,7 +322,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
// Update an existing node with the same data
callbackCalled := false
objUpdate := &TestResource{JSONBase: api.JSONBase{ID: "foo"}, Value: 1}
objUpdate := &TestResource{TypeMeta: api.TypeMeta{ID: "foo"}, Value: 1}
fakeClient.Err = errors.New("should not be called")
err = helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
callbackCalled = true
@ -339,7 +339,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
func TestAtomicUpdate_CreateCollision(t *testing.T) {
fakeClient := NewFakeEtcdClient(t)
fakeClient.TestIndex = true
helper := EtcdHelper{fakeClient, codec, runtime.NewJSONBaseResourceVersioner()}
helper := EtcdHelper{fakeClient, codec, runtime.NewTypeMetaResourceVersioner()}
fakeClient.ExpectNotFoundGet("/some/key")
@ -365,7 +365,7 @@ func TestAtomicUpdate_CreateCollision(t *testing.T) {
}
currValue := in.(*TestResource).Value
obj := &TestResource{JSONBase: api.JSONBase{ID: "foo"}, Value: currValue + 1}
obj := &TestResource{TypeMeta: api.TypeMeta{ID: "foo"}, Value: currValue + 1}
return obj, nil
})
if err != nil {

View File

@ -32,9 +32,9 @@ import (
func TestWatchInterpretations(t *testing.T) {
codec := latest.Codec
// Declare some pods to make the test cases compact.
podFoo := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
podBar := &api.Pod{JSONBase: api.JSONBase{ID: "bar"}}
podBaz := &api.Pod{JSONBase: api.JSONBase{ID: "baz"}}
podFoo := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
podBar := &api.Pod{TypeMeta: api.TypeMeta{ID: "bar"}}
podBaz := &api.Pod{TypeMeta: api.TypeMeta{ID: "baz"}}
firstLetterIsB := func(obj runtime.Object) bool {
return obj.(*api.Pod).ID[0] == 'b'
}
@ -236,7 +236,7 @@ func TestWatch(t *testing.T) {
}
// Test normal case
pod := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
pod := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
podBytes, _ := codec.Encode(pod)
fakeClient.WatchResponse <- &etcd.Response{
Action: "set",
@ -294,7 +294,7 @@ func TestWatchEtcdState(t *testing.T) {
{
Action: "create",
Node: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{}})),
},
},
},
@ -308,12 +308,12 @@ func TestWatchEtcdState(t *testing.T) {
{
Action: "compareAndSwap",
Node: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
CreatedIndex: 1,
ModifiedIndex: 2,
},
PrevNode: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{}})),
CreatedIndex: 1,
ModifiedIndex: 1,
},
@ -330,7 +330,7 @@ func TestWatchEtcdState(t *testing.T) {
R: &etcd.Response{
Action: "get",
Node: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{}})),
CreatedIndex: 1,
ModifiedIndex: 1,
},
@ -343,12 +343,12 @@ func TestWatchEtcdState(t *testing.T) {
{
Action: "compareAndSwap",
Node: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
CreatedIndex: 1,
ModifiedIndex: 2,
},
PrevNode: &etcd.Node{
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{JSONBase: api.JSONBase{ID: "foo"}, Endpoints: []string{}})),
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{}})),
CreatedIndex: 1,
ModifiedIndex: 1,
},
@ -391,7 +391,7 @@ func TestWatchEtcdState(t *testing.T) {
func TestWatchFromZeroIndex(t *testing.T) {
codec := latest.Codec
pod := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
pod := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
testCases := map[string]struct {
Response EtcdResponseWithError
@ -464,7 +464,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
func TestWatchListFromZeroIndex(t *testing.T) {
codec := latest.Codec
pod := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
pod := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
fakeClient := NewFakeEtcdClient(t)
fakeClient.Data["/some/key"] = EtcdResponseWithError{

View File

@ -24,11 +24,11 @@ import (
"gopkg.in/v1/yaml"
)
type FakeJSONBase struct {
type FakeTypeMeta struct {
ID string
}
type FakePod struct {
FakeJSONBase `json:",inline" yaml:",inline"`
FakeTypeMeta `json:",inline" yaml:",inline"`
Labels map[string]string
Int int
Str string
@ -36,7 +36,7 @@ type FakePod struct {
func TestEncodeJSON(t *testing.T) {
pod := FakePod{
FakeJSONBase: FakeJSONBase{ID: "foo"},
FakeTypeMeta: FakeTypeMeta{ID: "foo"},
Labels: map[string]string{
"foo": "bar",
"baz": "blah",

View File

@ -33,7 +33,7 @@ func TestDecoder(t *testing.T) {
out, in := io.Pipe()
decoder := NewDecoder(out, v1beta1.Codec)
expect := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
expect := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
encoder := json.NewEncoder(in)
go func() {
data, err := v1beta1.Codec.Encode(expect)

View File

@ -37,17 +37,17 @@ func TestEncodeDecodeRoundTrip(t *testing.T) {
}{
{
watch.Added,
&api.Pod{JSONBase: api.JSONBase{ID: "foo"}},
&api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}},
v1beta1.Codec,
},
{
watch.Modified,
&api.Pod{JSONBase: api.JSONBase{ID: "foo"}},
&api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}},
v1beta2.Codec,
},
{
watch.Deleted,
&api.Pod{JSONBase: api.JSONBase{ID: "foo"}},
&api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}},
api.Codec,
},
}

View File

@ -141,8 +141,8 @@ func TestPollMinions(t *testing.T) {
}{
{
minions: []api.Minion{
{JSONBase: api.JSONBase{ID: "foo"}},
{JSONBase: api.JSONBase{ID: "bar"}},
{TypeMeta: api.TypeMeta{ID: "foo"}},
{TypeMeta: api.TypeMeta{ID: "bar"}},
},
},
}
@ -175,7 +175,7 @@ func TestPollMinions(t *testing.T) {
}
func TestDefaultErrorFunc(t *testing.T) {
testPod := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
testPod := &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
handler := util.FakeHandler{
StatusCode: 200,
ResponseBody: runtime.EncodeOrDie(latest.Codec, testPod),
@ -215,7 +215,7 @@ func TestStoreToMinionLister(t *testing.T) {
store := cache.NewStore()
ids := util.NewStringSet("foo", "bar", "baz")
for id := range ids {
store.Add(id, &api.Minion{JSONBase: api.JSONBase{ID: id}})
store.Add(id, &api.Minion{TypeMeta: api.TypeMeta{ID: id}})
}
sml := storeToMinionLister{store}
@ -233,7 +233,7 @@ func TestStoreToPodLister(t *testing.T) {
ids := []string{"foo", "bar", "baz"}
for _, id := range ids {
store.Add(id, &api.Pod{
JSONBase: api.JSONBase{ID: id},
TypeMeta: api.TypeMeta{ID: id},
Labels: map[string]string{"name": id},
})
}
@ -259,9 +259,9 @@ func TestStoreToPodLister(t *testing.T) {
func TestMinionEnumerator(t *testing.T) {
testList := &api.MinionList{
Items: []api.Minion{
{JSONBase: api.JSONBase{ID: "foo"}},
{JSONBase: api.JSONBase{ID: "bar"}},
{JSONBase: api.JSONBase{ID: "baz"}},
{TypeMeta: api.TypeMeta{ID: "foo"}},
{TypeMeta: api.TypeMeta{ID: "bar"}},
{TypeMeta: api.TypeMeta{ID: "baz"}},
},
}
me := minionEnumerator{testList}

View File

@ -32,7 +32,7 @@ type fakeBinder struct {
func (fb fakeBinder) Bind(binding *api.Binding) error { return fb.b(binding) }
func podWithID(id string) *api.Pod {
return &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
return &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
}
type mockScheduler struct {

View File

@ -94,7 +94,7 @@ func TestWatch(t *testing.T) {
client := newEtcdClient()
helper := tools.EtcdHelper{Client: client, Codec: latest.Codec, ResourceVersioner: latest.ResourceVersioner}
withEtcdKey(func(key string) {
resp, err := client.Set(key, runtime.EncodeOrDie(v1beta1.Codec, &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0)
resp, err := client.Set(key, runtime.EncodeOrDie(v1beta1.Codec, &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}), 0)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}