Merge pull request #1975 from smarterclayton/split_type_meta
Split TypeMeta into ObjectMeta/ListMeta
This commit is contained in:
@@ -256,11 +256,16 @@ func runAtomicPutTest(c *client.Client) {
|
||||
var svc api.Service
|
||||
err := c.Post().Path("services").Body(
|
||||
&api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "atomicservice", APIVersion: latest.Version},
|
||||
Port: 12345,
|
||||
Labels: map[string]string{
|
||||
"name": "atomicService",
|
||||
TypeMeta: api.TypeMeta{
|
||||
APIVersion: latest.Version,
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "atomicservice",
|
||||
Labels: map[string]string{
|
||||
"name": "atomicService",
|
||||
},
|
||||
},
|
||||
Port: 12345,
|
||||
// This is here because validation requires it.
|
||||
Selector: map[string]string{
|
||||
"foo": "bar",
|
||||
@@ -330,7 +335,12 @@ func runAtomicPutTest(c *client.Client) {
|
||||
func runServiceTest(client *client.Client) {
|
||||
ctx := api.NewDefaultContext()
|
||||
pod := api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"name": "thisisalonglabel",
|
||||
},
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Version: "v1beta1",
|
||||
@@ -348,9 +358,6 @@ func runServiceTest(client *client.Client) {
|
||||
CurrentState: api.PodState{
|
||||
PodIP: "1.2.3.4",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"name": "thisisalonglabel",
|
||||
},
|
||||
}
|
||||
_, err := client.CreatePod(ctx, &pod)
|
||||
if err != nil {
|
||||
@@ -360,7 +367,7 @@ func runServiceTest(client *client.Client) {
|
||||
glog.Fatalf("FAILED: pod never started running %v", err)
|
||||
}
|
||||
svc1 := api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "service1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "service1"},
|
||||
Selector: map[string]string{
|
||||
"name": "thisisalonglabel",
|
||||
},
|
||||
@@ -375,7 +382,7 @@ func runServiceTest(client *client.Client) {
|
||||
}
|
||||
// A second service with the same port.
|
||||
svc2 := api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "service2"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "service2"},
|
||||
Selector: map[string]string{
|
||||
"name": "thisisalonglabel",
|
||||
},
|
||||
|
@@ -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.TypeMeta)
|
||||
api.ValidNamespace(ctx, &t.ObjectMeta)
|
||||
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.TypeMeta)
|
||||
api.ValidNamespace(ctx, &t.ObjectMeta)
|
||||
errors = validation.ValidateManifest(&t.DesiredState.Manifest)
|
||||
case *api.PodList:
|
||||
for i := range t.Items {
|
||||
|
@@ -70,7 +70,7 @@ func Namespace(ctx Context) string {
|
||||
}
|
||||
|
||||
// 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 *TypeMeta) bool {
|
||||
func ValidNamespace(ctx Context, resource *ObjectMeta) bool {
|
||||
ns, ok := NamespaceFrom(ctx)
|
||||
if len(resource.Namespace) == 0 {
|
||||
resource.Namespace = ns
|
||||
|
@@ -45,18 +45,18 @@ func TestValidNamespace(t *testing.T) {
|
||||
ctx := api.NewDefaultContext()
|
||||
namespace, _ := api.NamespaceFrom(ctx)
|
||||
resource := api.ReplicationController{}
|
||||
if !api.ValidNamespace(ctx, &resource.TypeMeta) {
|
||||
if !api.ValidNamespace(ctx, &resource.ObjectMeta) {
|
||||
t.Errorf("expected success")
|
||||
}
|
||||
if namespace != resource.Namespace {
|
||||
t.Errorf("expected resource to have the default namespace assigned during validation")
|
||||
}
|
||||
resource = api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "other"}}
|
||||
if api.ValidNamespace(ctx, &resource.TypeMeta) {
|
||||
resource = api.ReplicationController{ObjectMeta: api.ObjectMeta{Namespace: "other"}}
|
||||
if api.ValidNamespace(ctx, &resource.ObjectMeta) {
|
||||
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.TypeMeta) {
|
||||
if api.ValidNamespace(ctx, &resource.ObjectMeta) {
|
||||
t.Errorf("Expected error that resource and context errors do not match since context has no namespace")
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,8 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
// APIVersion and Kind must remain blank in memory.
|
||||
j.APIVersion = ""
|
||||
j.Kind = ""
|
||||
},
|
||||
func(j *internal.ObjectMeta, c fuzz.Continue) {
|
||||
j.Name = c.RandString()
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
@@ -49,6 +51,13 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
c.Fuzz(&nsec)
|
||||
j.CreationTimestamp = util.Unix(sec, nsec).Rfc3339Copy()
|
||||
},
|
||||
func(j *internal.ListMeta, c fuzz.Continue) {
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.SelfLink = c.RandString()
|
||||
},
|
||||
func(j *internal.ObjectReference, c fuzz.Continue) {
|
||||
// We have to customize the randomization of TypeMetas because their
|
||||
// APIVersion and Kind must remain blank in memory.
|
||||
@@ -133,7 +142,7 @@ func TestInternalRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResourceVersioner(t *testing.T) {
|
||||
pod := internal.Pod{TypeMeta: internal.TypeMeta{ResourceVersion: "10"}}
|
||||
pod := internal.Pod{ObjectMeta: internal.ObjectMeta{ResourceVersion: "10"}}
|
||||
version, err := ResourceVersioner.ResourceVersion(&pod)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
@@ -141,6 +150,15 @@ func TestResourceVersioner(t *testing.T) {
|
||||
if version != "10" {
|
||||
t.Errorf("unexpected version %v", version)
|
||||
}
|
||||
|
||||
podList := internal.PodList{ListMeta: internal.ListMeta{ResourceVersion: "10"}}
|
||||
version, err = ResourceVersioner.ResourceVersion(&podList)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if version != "10" {
|
||||
t.Errorf("unexpected version %v", version)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCodec(t *testing.T) {
|
||||
|
@@ -35,7 +35,7 @@ func TestGetReference(t *testing.T) {
|
||||
}{
|
||||
"pod": {
|
||||
obj: &Pod{
|
||||
TypeMeta: TypeMeta{
|
||||
ObjectMeta: ObjectMeta{
|
||||
Name: "foo",
|
||||
UID: "bar",
|
||||
ResourceVersion: "42",
|
||||
@@ -52,9 +52,7 @@ func TestGetReference(t *testing.T) {
|
||||
},
|
||||
"serviceList": {
|
||||
obj: &ServiceList{
|
||||
TypeMeta: TypeMeta{
|
||||
Name: "foo",
|
||||
UID: "bar",
|
||||
ListMeta: ListMeta{
|
||||
ResourceVersion: "42",
|
||||
SelfLink: "/api/v1beta2/services",
|
||||
},
|
||||
@@ -62,15 +60,12 @@ func TestGetReference(t *testing.T) {
|
||||
ref: &ObjectReference{
|
||||
Kind: "ServiceList",
|
||||
APIVersion: "v1beta2",
|
||||
Name: "foo",
|
||||
UID: "bar",
|
||||
ResourceVersion: "42",
|
||||
},
|
||||
},
|
||||
"badSelfLink": {
|
||||
obj: &ServiceList{
|
||||
TypeMeta: TypeMeta{
|
||||
Name: "foo",
|
||||
ListMeta: ListMeta{
|
||||
ResourceVersion: "42",
|
||||
SelfLink: "v1beta2/services",
|
||||
},
|
||||
|
@@ -47,12 +47,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
// APIVersion and Kind must remain blank in memory.
|
||||
j.APIVersion = ""
|
||||
j.Kind = ""
|
||||
},
|
||||
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 = ""
|
||||
|
||||
j.Name = c.RandString()
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
@@ -65,6 +60,32 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
|
||||
c.Fuzz(&nsec)
|
||||
j.CreationTimestamp = util.Unix(sec, nsec).Rfc3339Copy()
|
||||
},
|
||||
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 = ""
|
||||
},
|
||||
func(j *api.ObjectMeta, c fuzz.Continue) {
|
||||
j.Name = c.RandString()
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.SelfLink = c.RandString()
|
||||
|
||||
var sec, nsec int64
|
||||
c.Fuzz(&sec)
|
||||
c.Fuzz(&nsec)
|
||||
j.CreationTimestamp = util.Unix(sec, nsec).Rfc3339Copy()
|
||||
},
|
||||
func(j *api.ListMeta, c fuzz.Continue) {
|
||||
// TODO: Fix JSON/YAML packages and/or write custom encoding
|
||||
// for uint64's. Somehow the LS *byte* of this is lost, but
|
||||
// only when all 8 bytes are set.
|
||||
j.ResourceVersion = strconv.FormatUint(c.RandUint64()>>8, 10)
|
||||
j.SelfLink = c.RandString()
|
||||
},
|
||||
func(intstr *util.IntOrString, c fuzz.Continue) {
|
||||
// util.IntOrString will panic if its kind is set wrong.
|
||||
if c.RandBool() {
|
||||
@@ -173,7 +194,9 @@ func TestTypes(t *testing.T) {
|
||||
|
||||
func TestEncode_Ptr(t *testing.T) {
|
||||
pod := &api.Pod{
|
||||
Labels: map[string]string{"name": "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{"name": "foo"},
|
||||
},
|
||||
}
|
||||
obj := runtime.Object(pod)
|
||||
data, err := latest.Codec.Encode(obj)
|
||||
|
262
pkg/api/types.go
262
pkg/api/types.go
@@ -27,7 +27,7 @@ import (
|
||||
// Many fields in this API have formatting requirements. The commonly used
|
||||
// formats are defined here.
|
||||
//
|
||||
// C_IDENTIFIER: This is a string that conforms the definition of an "identifier"
|
||||
// C_IDENTIFIER: This is a string that conforms to the definition of an "identifier"
|
||||
// in the C language. This is captured by the following regex:
|
||||
// [A-Za-z_][A-Za-z0-9_]*
|
||||
// This defines the format, but not the length restriction, which should be
|
||||
@@ -45,15 +45,93 @@ import (
|
||||
// or more simply:
|
||||
// DNS_LABEL(\.DNS_LABEL)*
|
||||
|
||||
// TypeMeta describes an individual object in an API response or request
|
||||
// with strings representing the type of the object and its API schema version.
|
||||
// Structures that are versioned or persisted should inline TypeMeta.
|
||||
type TypeMeta struct {
|
||||
// Kind is a string value representing the REST resource this object represents.
|
||||
// Servers may infer this from the endpoint the client submits requests to.
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
// APIVersion defines the versioned schema of this representation of an object.
|
||||
// Servers should convert recognized schemas to the latest internal value, and
|
||||
// may reject unrecognized values.
|
||||
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
|
||||
}
|
||||
|
||||
// ListMeta describes metadata that synthetic resources must have, including lists and
|
||||
// various status objects. A resource may have only one of {ObjectMeta, ListMeta}.
|
||||
type ListMeta struct {
|
||||
// SelfLink is a URL representing this object.
|
||||
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
|
||||
|
||||
// An opaque value that represents the version of this response for use with optimistic
|
||||
// concurrency and change monitoring endpoints. Clients must treat these values as opaque
|
||||
// and values may only be valid for a particular resource or set of resources. Only servers
|
||||
// will generate resource versions.
|
||||
ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
|
||||
}
|
||||
|
||||
// ObjectMeta is metadata that all persisted resources must have, which includes all objects
|
||||
// users must create. A resource may have only one of {ObjectMeta, ListMeta}.
|
||||
type ObjectMeta struct {
|
||||
// Name is unique within a namespace. Name is required when creating resources, although
|
||||
// some resources may allow a client to request the generation of an appropriate name
|
||||
// automatically. Name is primarily intended for creation idempotence and configuration
|
||||
// definition.
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
// Namespace defines the space within which name must be unique. An empty namespace is
|
||||
// equivalent to the "default" namespace, but "default" is the canonical representation.
|
||||
// Not all objects are required to be scoped to a namespace - the value of this field for
|
||||
// those objects will be empty.
|
||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||
|
||||
// SelfLink is a URL representing this object.
|
||||
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
|
||||
|
||||
// UID is the unique in time and space value for this object. It is typically generated by
|
||||
// the server on successful creation of a resource and is not allowed to change on PUT
|
||||
// operations.
|
||||
UID string `json:"uid,omitempty" yaml:"uid,omitempty"`
|
||||
|
||||
// An opaque value that represents the version of this resource. May be used for optimistic
|
||||
// concurrency, change detection, and the watch operation on a resource or set of resources.
|
||||
// Clients must treat these values as opaque and values may only be valid for a particular
|
||||
// resource or set of resources. Only servers will generate resource versions.
|
||||
ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
|
||||
|
||||
// CreationTimestamp is a timestamp representing the server time when this object was
|
||||
// created. It is not guaranteed to be set in happens-before order across separate operations.
|
||||
// Clients may not set this value. It is represented in RFC3339 form and is in UTC.
|
||||
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
|
||||
|
||||
// Labels are key value pairs that may be used to scope and select individual resources.
|
||||
// TODO: replace map[string]string with labels.LabelSet type
|
||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||
|
||||
// Annotations are unstructured key value data stored with a resource that may be set by
|
||||
// external tooling. They are not queryable and should be preserved when modifying
|
||||
// objects.
|
||||
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
// NamespaceDefault means the object is in the default namespace which is applied when not specified by clients
|
||||
NamespaceDefault string = "default"
|
||||
// NamespaceAll is the default argument to specify on a context when you want to list or filter resources across all namespaces
|
||||
NamespaceAll string = ""
|
||||
)
|
||||
|
||||
// Volume represents a named volume in a pod that may be accessed by any containers in the pod.
|
||||
type Volume struct {
|
||||
// Required: This must be a DNS_LABEL. Each volume in a pod must have
|
||||
// a unique name.
|
||||
Name string `yaml:"name" json:"name"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
// Source represents the location and type of a volume to mount.
|
||||
// This is optional for now. If not specified, the Volume is implied to be an EmptyDir.
|
||||
// This implied behavior is deprecated and will be removed in a future version.
|
||||
Source *VolumeSource `yaml:"source" json:"source"`
|
||||
Source *VolumeSource `json:"source" yaml:"source"`
|
||||
}
|
||||
|
||||
type VolumeSource struct {
|
||||
@@ -61,19 +139,19 @@ type VolumeSource struct {
|
||||
// HostDir represents a pre-existing directory on the host machine that is directly
|
||||
// exposed to the container. This is generally used for system agents or other privileged
|
||||
// things that are allowed to see the host machine. Most containers will NOT need this.
|
||||
// TODO(jonesdl) We need to restrict who can use host directory mounts and
|
||||
// who can/can not mount host directories as read/write.
|
||||
HostDir *HostDir `yaml:"hostDir" json:"hostDir"`
|
||||
// TODO(jonesdl) We need to restrict who can use host directory mounts and who can/can not
|
||||
// mount host directories as read/write.
|
||||
HostDir *HostDir `json:"hostDir" yaml:"hostDir"`
|
||||
// EmptyDir represents a temporary directory that shares a pod's lifetime.
|
||||
EmptyDir *EmptyDir `yaml:"emptyDir" json:"emptyDir"`
|
||||
EmptyDir *EmptyDir `json:"emptyDir" yaml:"emptyDir"`
|
||||
// GCEPersistentDisk represents a GCE Disk resource that is attached to a
|
||||
// kubelet's host machine and then exposed to the pod.
|
||||
GCEPersistentDisk *GCEPersistentDisk `yaml:"persistentDisk" json:"persistentDisk"`
|
||||
GCEPersistentDisk *GCEPersistentDisk `json:"persistentDisk" yaml:"persistentDisk"`
|
||||
}
|
||||
|
||||
// HostDir represents bare host directory volume.
|
||||
type HostDir struct {
|
||||
Path string `yaml:"path" json:"path"`
|
||||
Path string `json:"path" yaml:"path"`
|
||||
}
|
||||
|
||||
type EmptyDir struct{}
|
||||
@@ -113,49 +191,49 @@ type GCEPersistentDisk struct {
|
||||
type Port struct {
|
||||
// Optional: If specified, this must be a DNS_LABEL. Each named port
|
||||
// in a pod must have a unique name.
|
||||
Name string `yaml:"name,omitempty" json:"name,omitempty"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
// Optional: If specified, this must be a valid port number, 0 < x < 65536.
|
||||
HostPort int `yaml:"hostPort,omitempty" json:"hostPort,omitempty"`
|
||||
HostPort int `json:"hostPort,omitempty" yaml:"hostPort,omitempty"`
|
||||
// Required: This must be a valid port number, 0 < x < 65536.
|
||||
ContainerPort int `yaml:"containerPort" json:"containerPort"`
|
||||
// Optional: Defaults to "TCP".
|
||||
Protocol Protocol `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||
ContainerPort int `json:"containerPort" yaml:"containerPort"`
|
||||
// Optional: Supports "TCP" and "UDP". Defaults to "TCP".
|
||||
Protocol Protocol `json:"protocol,omitempty" yaml:"protocol,omitempty"`
|
||||
// Optional: What host IP to bind the external port to.
|
||||
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
|
||||
HostIP string `json:"hostIP,omitempty" yaml:"hostIP,omitempty"`
|
||||
}
|
||||
|
||||
// VolumeMount describes a mounting of a Volume within a container.
|
||||
type VolumeMount struct {
|
||||
// Required: This must match the Name of a Volume [above].
|
||||
Name string `yaml:"name" json:"name"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
// Optional: Defaults to false (read-write).
|
||||
ReadOnly bool `yaml:"readOnly,omitempty" json:"readOnly,omitempty"`
|
||||
ReadOnly bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"`
|
||||
// Required.
|
||||
MountPath string `yaml:"mountPath,omitempty" json:"mountPath,omitempty"`
|
||||
MountPath string `json:"mountPath,omitempty" yaml:"mountPath,omitempty"`
|
||||
}
|
||||
|
||||
// EnvVar represents an environment variable present in a Container.
|
||||
type EnvVar struct {
|
||||
// Required: This must be a C_IDENTIFIER.
|
||||
Name string `yaml:"name" json:"name"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
// Optional: defaults to "".
|
||||
Value string `yaml:"value,omitempty" json:"value,omitempty"`
|
||||
Value string `json:"value,omitempty" yaml:"value,omitempty"`
|
||||
}
|
||||
|
||||
// HTTPGetAction describes an action based on HTTP Get requests.
|
||||
type HTTPGetAction struct {
|
||||
// Optional: Path to access on the HTTP server.
|
||||
Path string `yaml:"path,omitempty" json:"path,omitempty"`
|
||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||
// Required: Name or number of the port to access on the container.
|
||||
Port util.IntOrString `yaml:"port,omitempty" json:"port,omitempty"`
|
||||
Port util.IntOrString `json:"port,omitempty" yaml:"port,omitempty"`
|
||||
// Optional: Host name to connect to, defaults to the pod IP.
|
||||
Host string `yaml:"host,omitempty" json:"host,omitempty"`
|
||||
Host string `json:"host,omitempty" yaml:"host,omitempty"`
|
||||
}
|
||||
|
||||
// TCPSocketAction describes an action based on opening a socket
|
||||
type TCPSocketAction struct {
|
||||
// Required: Port to connect to.
|
||||
Port util.IntOrString `yaml:"port,omitempty" json:"port,omitempty"`
|
||||
Port util.IntOrString `json:"port,omitempty" yaml:"port,omitempty"`
|
||||
}
|
||||
|
||||
// ExecAction describes a "run in container" action.
|
||||
@@ -196,22 +274,22 @@ const (
|
||||
type Container struct {
|
||||
// Required: This must be a DNS_LABEL. Each container in a pod must
|
||||
// have a unique name.
|
||||
Name string `yaml:"name" json:"name"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
// Required.
|
||||
Image string `yaml:"image" json:"image"`
|
||||
Image string `json:"image" yaml:"image"`
|
||||
// Optional: Defaults to whatever is defined in the image.
|
||||
Command []string `yaml:"command,omitempty" json:"command,omitempty"`
|
||||
Command []string `json:"command,omitempty" yaml:"command,omitempty"`
|
||||
// Optional: Defaults to Docker's default.
|
||||
WorkingDir string `yaml:"workingDir,omitempty" json:"workingDir,omitempty"`
|
||||
Ports []Port `yaml:"ports,omitempty" json:"ports,omitempty"`
|
||||
Env []EnvVar `yaml:"env,omitempty" json:"env,omitempty"`
|
||||
WorkingDir string `json:"workingDir,omitempty" yaml:"workingDir,omitempty"`
|
||||
Ports []Port `json:"ports,omitempty" yaml:"ports,omitempty"`
|
||||
Env []EnvVar `json:"env,omitempty" yaml:"env,omitempty"`
|
||||
// Optional: Defaults to unlimited.
|
||||
Memory int `yaml:"memory,omitempty" json:"memory,omitempty"`
|
||||
Memory int `json:"memory,omitempty" yaml:"memory,omitempty"`
|
||||
// Optional: Defaults to unlimited.
|
||||
CPU int `yaml:"cpu,omitempty" json:"cpu,omitempty"`
|
||||
VolumeMounts []VolumeMount `yaml:"volumeMounts,omitempty" json:"volumeMounts,omitempty"`
|
||||
LivenessProbe *LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
|
||||
Lifecycle *Lifecycle `yaml:"lifecycle,omitempty" json:"lifecycle,omitempty"`
|
||||
CPU int `json:"cpu,omitempty" yaml:"cpu,omitempty"`
|
||||
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty" yaml:"volumeMounts,omitempty"`
|
||||
LivenessProbe *LivenessProbe `json:"livenessProbe,omitempty" yaml:"livenessProbe,omitempty"`
|
||||
Lifecycle *Lifecycle `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty"`
|
||||
// Optional: Default to false.
|
||||
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
||||
// Optional: Policy for pulling images for this container
|
||||
@@ -223,9 +301,9 @@ type Container struct {
|
||||
type Handler struct {
|
||||
// One and only one of the following should be specified.
|
||||
// Exec specifies the action to take.
|
||||
Exec *ExecAction `yaml:"exec,omitempty" json:"exec,omitempty"`
|
||||
Exec *ExecAction `json:"exec,omitempty" yaml:"exec,omitempty"`
|
||||
// HTTPGet specifies the http request to perform.
|
||||
HTTPGet *HTTPGetAction `yaml:"httpGet,omitempty" json:"httpGet,omitempty"`
|
||||
HTTPGet *HTTPGetAction `json:"httpGet,omitempty" yaml:"httpGet,omitempty"`
|
||||
}
|
||||
|
||||
// Lifecycle describes actions that the management system should take in response to container lifecycle
|
||||
@@ -234,7 +312,7 @@ type Handler struct {
|
||||
type Lifecycle struct {
|
||||
// PostStart is called immediately after a container is created. If the handler fails, the container
|
||||
// is terminated and restarted.
|
||||
PostStart *Handler `yaml:"postStart,omitempty" json:"postStart,omitempty"`
|
||||
PostStart *Handler `json:"postStart,omitempty" yaml:"postStart,omitempty"`
|
||||
// PreStop is called immediately before a container is terminated. The reason for termination is
|
||||
// passed to the handler. Regardless of the outcome of the handler, the container is eventually terminated.
|
||||
PreStop *Handler `yaml:"preStop,omitempty" json:"preStop,omitempty"`
|
||||
@@ -242,30 +320,6 @@ type Lifecycle struct {
|
||||
|
||||
// The below types are used by kube_client and api_server.
|
||||
|
||||
// TypeMeta is shared by all objects sent to, or returned from the client.
|
||||
type TypeMeta struct {
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"`
|
||||
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
|
||||
ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
|
||||
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||
UID string `json:"uid,omitempty" yaml:"uid,omitempty"`
|
||||
|
||||
// Annotations are unstructured key value data stored with a resource that may be set by
|
||||
// external tooling. They are not queryable and should be preserved when modifying
|
||||
// objects.
|
||||
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
// NamespaceDefault means the object is in the default namespace which is applied when not specified by clients
|
||||
NamespaceDefault string = "default"
|
||||
// NamespaceAll is the default argument to specify on a context when you want to list or filter resources across all namespaces
|
||||
NamespaceAll string = ""
|
||||
)
|
||||
|
||||
// PodStatus represents a status of a pod.
|
||||
type PodStatus string
|
||||
|
||||
@@ -358,15 +412,18 @@ type PodState struct {
|
||||
// PodList is a list of Pods.
|
||||
type PodList struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
Items []Pod `json:"items" yaml:"items,omitempty"`
|
||||
ListMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Items []Pod `json:"items" yaml:"items,omitempty"`
|
||||
}
|
||||
|
||||
// Pod is a collection of containers, used as either input (create, update) or as output (list, get).
|
||||
type Pod struct {
|
||||
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"`
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
|
||||
CurrentState PodState `json:"currentState,omitempty" yaml:"currentState,omitempty"`
|
||||
}
|
||||
|
||||
// ReplicationControllerState is the state of a replication controller, either input (create, update) or as output (list, get).
|
||||
@@ -379,15 +436,18 @@ type ReplicationControllerState struct {
|
||||
// ReplicationControllerList is a collection of replication controllers.
|
||||
type ReplicationControllerList struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
Items []ReplicationController `json:"items,omitempty" yaml:"items,omitempty"`
|
||||
ListMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Items []ReplicationController `json:"items,omitempty" yaml:"items,omitempty"`
|
||||
}
|
||||
|
||||
// ReplicationController represents the configuration of a replication controller.
|
||||
type ReplicationController struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
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"`
|
||||
}
|
||||
|
||||
// PodTemplate holds the information used for creating pods.
|
||||
@@ -399,23 +459,23 @@ type PodTemplate struct {
|
||||
// ServiceList holds a list of services.
|
||||
type ServiceList struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
Items []Service `json:"items" yaml:"items"`
|
||||
ListMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Items []Service `json:"items" yaml:"items"`
|
||||
}
|
||||
|
||||
// Service is a named abstraction of software service (for example, mysql) consisting of local port
|
||||
// (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 {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
// Required.
|
||||
Port int `json:"port" yaml:"port"`
|
||||
// Optional: Defaults to "TCP".
|
||||
Protocol Protocol `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||
|
||||
// This service's labels.
|
||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||
|
||||
// This service will route traffic to pods having labels matching this selector.
|
||||
Selector map[string]string `json:"selector,omitempty" yaml:"selector,omitempty"`
|
||||
CreateExternalLoadBalancer bool `json:"createExternalLoadBalancer,omitempty" yaml:"createExternalLoadBalancer,omitempty"`
|
||||
@@ -435,14 +495,18 @@ type Service struct {
|
||||
// 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 {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Endpoints []string `json:"endpoints,omitempty" yaml:"endpoints,omitempty"`
|
||||
}
|
||||
|
||||
// EndpointsList is a list of endpoints.
|
||||
type EndpointsList struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
Items []Endpoints `json:"items,omitempty" yaml:"items,omitempty"`
|
||||
ListMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Items []Endpoints `json:"items,omitempty" yaml:"items,omitempty"`
|
||||
}
|
||||
|
||||
// NodeResources represents resources on a Kubernetes system node
|
||||
@@ -460,7 +524,9 @@ type ResourceList map[ResourceName]util.IntOrString
|
||||
// Minion is a worker node in Kubernetenes.
|
||||
// The name of the minion according to etcd is in ID.
|
||||
type Minion struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
// Queried from cloud provider, if available.
|
||||
HostIP string `json:"hostIP,omitempty" yaml:"hostIP,omitempty"`
|
||||
// Resources available on the node
|
||||
@@ -470,21 +536,27 @@ type Minion struct {
|
||||
// MinionList is a list of minions.
|
||||
type MinionList struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
Items []Minion `json:"items,omitempty" yaml:"items,omitempty"`
|
||||
ListMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Items []Minion `json:"items,omitempty" yaml:"items,omitempty"`
|
||||
}
|
||||
|
||||
// Binding is written by a scheduler to cause a pod to be bound to a host.
|
||||
type Binding struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
PodID string `json:"podID" yaml:"podID"`
|
||||
Host string `json:"host" yaml:"host"`
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
PodID string `json:"podID" yaml:"podID"`
|
||||
Host string `json:"host" yaml:"host"`
|
||||
}
|
||||
|
||||
// Status is a return value for calls that don't return other objects.
|
||||
// TODO: this could go in apiserver, but I'm including it here so clients needn't
|
||||
// import both.
|
||||
type Status struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
// 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.
|
||||
@@ -636,13 +708,16 @@ const (
|
||||
|
||||
// ServerOp is an operation delivered to API clients.
|
||||
type ServerOp struct {
|
||||
TypeMeta `yaml:",inline" json:",inline"`
|
||||
TypeMeta `yaml:",inline" json:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
// ServerOpList is a list of operations, as delivered to API clients.
|
||||
type ServerOpList struct {
|
||||
TypeMeta `yaml:",inline" json:",inline"`
|
||||
Items []ServerOp `yaml:"items,omitempty" json:"items,omitempty"`
|
||||
ListMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Items []ServerOp `yaml:"items,omitempty" json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// ObjectReference contains enough information to let you inspect or modify the referred object.
|
||||
@@ -667,7 +742,8 @@ 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 {
|
||||
TypeMeta `yaml:",inline" json:",inline"`
|
||||
TypeMeta `yaml:",inline" json:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
// Required. The object that this event is about.
|
||||
InvolvedObject ObjectReference `json:"involvedObject,omitempty" yaml:"involvedObject,omitempty"`
|
||||
@@ -702,7 +778,9 @@ type Event struct {
|
||||
// EventList is a list of events.
|
||||
type EventList struct {
|
||||
TypeMeta `yaml:",inline" json:",inline"`
|
||||
Items []Event `yaml:"items,omitempty" json:"items,omitempty"`
|
||||
ListMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Items []Event `yaml:"items,omitempty" json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// ContainerManifest corresponds to the Container Manifest format, documented at:
|
||||
@@ -728,7 +806,9 @@ type ContainerManifest struct {
|
||||
// DEPRECATED: Replaced with BoundPods
|
||||
type ContainerManifestList struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"`
|
||||
ListMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"`
|
||||
}
|
||||
|
||||
// Included in partial form from v1beta3 to replace ContainerManifest
|
||||
@@ -744,7 +824,8 @@ type PodSpec struct {
|
||||
// defines how a Pod may change after a Binding is created. A Pod is a request to
|
||||
// execute a pod, whereas a BoundPod is the specification that would be run on a server.
|
||||
type BoundPod struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
// Spec defines the behavior of a pod.
|
||||
Spec PodSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
|
||||
@@ -753,7 +834,8 @@ type BoundPod struct {
|
||||
// BoundPods is a list of Pods bound to a common server. The resource version of
|
||||
// the pod list is guaranteed to only change when the list of bound pods changes.
|
||||
type BoundPods struct {
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
TypeMeta `json:",inline" yaml:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
// Host is the name of a node that these pods were bound to.
|
||||
Host string `json:"host" yaml:"host"`
|
||||
|
@@ -25,16 +25,21 @@ import (
|
||||
|
||||
func init() {
|
||||
newer.Scheme.AddConversionFuncs(
|
||||
// TypeMeta has changed type of ResourceVersion internally
|
||||
// TypeMeta must be split into two objects
|
||||
func(in *newer.TypeMeta, out *TypeMeta, s conversion.Scope) error {
|
||||
out.APIVersion = in.APIVersion
|
||||
out.Kind = in.Kind
|
||||
out.Namespace = in.Namespace
|
||||
out.ID = in.Name
|
||||
out.CreationTimestamp = in.CreationTimestamp
|
||||
out.SelfLink = in.SelfLink
|
||||
out.Annotations = in.Annotations
|
||||
out.APIVersion = in.APIVersion
|
||||
return nil
|
||||
},
|
||||
func(in *TypeMeta, out *newer.TypeMeta, s conversion.Scope) error {
|
||||
out.Kind = in.Kind
|
||||
out.APIVersion = in.APIVersion
|
||||
return nil
|
||||
},
|
||||
|
||||
// ListMeta must be converted to TypeMeta
|
||||
func(in *newer.ListMeta, out *TypeMeta, s conversion.Scope) error {
|
||||
out.SelfLink = in.SelfLink
|
||||
if len(in.ResourceVersion) > 0 {
|
||||
v, err := strconv.ParseUint(in.ResourceVersion, 10, 64)
|
||||
if err != nil {
|
||||
@@ -44,21 +49,46 @@ func init() {
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *TypeMeta, out *newer.TypeMeta, s conversion.Scope) error {
|
||||
out.APIVersion = in.APIVersion
|
||||
out.Kind = in.Kind
|
||||
out.Namespace = in.Namespace
|
||||
out.Name = in.ID
|
||||
out.CreationTimestamp = in.CreationTimestamp
|
||||
func(in *TypeMeta, out *newer.ListMeta, s conversion.Scope) error {
|
||||
out.SelfLink = in.SelfLink
|
||||
out.Annotations = in.Annotations
|
||||
|
||||
if in.ResourceVersion != 0 {
|
||||
out.ResourceVersion = strconv.FormatUint(in.ResourceVersion, 10)
|
||||
} else {
|
||||
out.ResourceVersion = ""
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
// ObjectMeta must be converted to TypeMeta
|
||||
func(in *newer.ObjectMeta, out *TypeMeta, s conversion.Scope) error {
|
||||
out.Namespace = in.Namespace
|
||||
out.ID = in.Name
|
||||
out.UID = in.UID
|
||||
out.CreationTimestamp = in.CreationTimestamp
|
||||
out.SelfLink = in.SelfLink
|
||||
if len(in.ResourceVersion) > 0 {
|
||||
v, err := strconv.ParseUint(in.ResourceVersion, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.ResourceVersion = v
|
||||
}
|
||||
return s.Convert(&in.Annotations, &out.Annotations, 0)
|
||||
},
|
||||
func(in *TypeMeta, out *newer.ObjectMeta, s conversion.Scope) error {
|
||||
out.Namespace = in.Namespace
|
||||
out.Name = in.ID
|
||||
out.UID = in.UID
|
||||
out.CreationTimestamp = in.CreationTimestamp
|
||||
out.SelfLink = in.SelfLink
|
||||
if in.ResourceVersion != 0 {
|
||||
out.ResourceVersion = strconv.FormatUint(in.ResourceVersion, 10)
|
||||
} else {
|
||||
out.ResourceVersion = ""
|
||||
}
|
||||
return s.Convert(&in.Annotations, &out.Annotations, 0)
|
||||
},
|
||||
|
||||
// EnvVar's Key is deprecated in favor of Name.
|
||||
func(in *newer.EnvVar, out *EnvVar, s conversion.Scope) error {
|
||||
out.Value = in.Value
|
||||
@@ -98,20 +128,487 @@ func init() {
|
||||
|
||||
// MinionList.Items had a wrong name in v1beta1
|
||||
func(in *newer.MinionList, out *MinionList, s conversion.Scope) error {
|
||||
s.Convert(&in.TypeMeta, &out.TypeMeta, 0)
|
||||
s.Convert(&in.Items, &out.Items, 0)
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Items, &out.Items, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Minions = out.Items
|
||||
return nil
|
||||
},
|
||||
func(in *MinionList, out *newer.MinionList, s conversion.Scope) error {
|
||||
s.Convert(&in.TypeMeta, &out.TypeMeta, 0)
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(in.Items) == 0 {
|
||||
s.Convert(&in.Minions, &out.Items, 0)
|
||||
if err := s.Convert(&in.Minions, &out.Items, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
s.Convert(&in.Items, &out.Items, 0)
|
||||
if err := s.Convert(&in.Items, &out.Items, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
// Convert all the standard objects
|
||||
func(in *newer.Pod, out *Pod, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.Convert(&in.DesiredState, &out.DesiredState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.CurrentState, &out.CurrentState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *Pod, out *newer.Pod, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.Convert(&in.DesiredState, &out.DesiredState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.CurrentState, &out.CurrentState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.ReplicationController, out *ReplicationController, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.Convert(&in.DesiredState, &out.DesiredState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.CurrentState, &out.CurrentState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *ReplicationController, out *newer.ReplicationController, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.Convert(&in.DesiredState, &out.DesiredState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.CurrentState, &out.CurrentState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.Service, out *Service, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Port = in.Port
|
||||
out.Protocol = Protocol(in.Protocol)
|
||||
if err := s.Convert(&in.Selector, &out.Selector, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
out.CreateExternalLoadBalancer = in.CreateExternalLoadBalancer
|
||||
out.ContainerPort = in.ContainerPort
|
||||
out.PortalIP = in.PortalIP
|
||||
out.ProxyPort = in.ProxyPort
|
||||
|
||||
return nil
|
||||
},
|
||||
func(in *Service, out *newer.Service, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Port = in.Port
|
||||
out.Protocol = newer.Protocol(in.Protocol)
|
||||
if err := s.Convert(&in.Selector, &out.Selector, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
out.CreateExternalLoadBalancer = in.CreateExternalLoadBalancer
|
||||
out.ContainerPort = in.ContainerPort
|
||||
out.PortalIP = in.PortalIP
|
||||
out.ProxyPort = in.ProxyPort
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.Binding, out *Binding, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.PodID = in.PodID
|
||||
out.Host = in.Host
|
||||
|
||||
return nil
|
||||
},
|
||||
func(in *Binding, out *newer.Binding, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.PodID = in.PodID
|
||||
out.Host = in.Host
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.Status, out *Status, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Code = in.Code
|
||||
out.Message = in.Message
|
||||
out.Reason = StatusReason(in.Reason)
|
||||
out.Status = in.Status
|
||||
return s.Convert(&in.Details, &out.Details, 0)
|
||||
},
|
||||
func(in *Status, out *newer.Status, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Code = in.Code
|
||||
out.Message = in.Message
|
||||
out.Reason = newer.StatusReason(in.Reason)
|
||||
out.Status = in.Status
|
||||
return s.Convert(&in.Details, &out.Details, 0)
|
||||
},
|
||||
|
||||
func(in *newer.Minion, out *Minion, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.HostIP = in.HostIP
|
||||
return s.Convert(&in.NodeResources, &out.NodeResources, 0)
|
||||
},
|
||||
func(in *Minion, out *newer.Minion, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.HostIP = in.HostIP
|
||||
return s.Convert(&in.NodeResources, &out.NodeResources, 0)
|
||||
},
|
||||
|
||||
func(in *newer.BoundPod, out *BoundPod, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Convert(&in.Spec, &out.Spec, 0)
|
||||
},
|
||||
func(in *BoundPod, out *newer.BoundPod, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Convert(&in.Spec, &out.Spec, 0)
|
||||
},
|
||||
|
||||
func(in *newer.BoundPods, out *BoundPods, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Host = in.Host
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *BoundPods, out *newer.BoundPods, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Host = in.Host
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.Endpoints, out *Endpoints, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Convert(&in.Endpoints, &out.Endpoints, 0)
|
||||
},
|
||||
func(in *Endpoints, out *newer.Endpoints, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Convert(&in.Endpoints, &out.Endpoints, 0)
|
||||
},
|
||||
|
||||
func(in *newer.ServerOp, out *ServerOp, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *ServerOp, out *newer.ServerOp, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.Event, out *Event, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
out.Source = in.Source
|
||||
out.Status = in.Status
|
||||
out.Timestamp = in.Timestamp
|
||||
return s.Convert(&in.InvolvedObject, &out.InvolvedObject, 0)
|
||||
},
|
||||
func(in *Event, out *newer.Event, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
out.Source = in.Source
|
||||
out.Status = in.Status
|
||||
out.Timestamp = in.Timestamp
|
||||
return s.Convert(&in.InvolvedObject, &out.InvolvedObject, 0)
|
||||
},
|
||||
|
||||
// Convert all the standard lists
|
||||
func(in *newer.PodList, out *PodList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *PodList, out *newer.PodList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.ReplicationControllerList, out *ReplicationControllerList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *ReplicationControllerList, out *newer.ReplicationControllerList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.ServiceList, out *ServiceList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *ServiceList, out *newer.ServiceList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.EndpointsList, out *EndpointsList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *EndpointsList, out *newer.EndpointsList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.EventList, out *EventList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *EventList, out *newer.EventList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.ServerOpList, out *ServerOpList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *ServerOpList, out *newer.ServerOpList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.ContainerManifestList, out *ContainerManifestList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *ContainerManifestList, out *newer.ContainerManifestList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@@ -119,7 +119,7 @@ func TestMinionListConversionToNew(t *testing.T) {
|
||||
return v1beta1.Minion{TypeMeta: v1beta1.TypeMeta{ID: id}}
|
||||
}
|
||||
newMinion := func(id string) newer.Minion {
|
||||
return newer.Minion{TypeMeta: newer.TypeMeta{Name: id}}
|
||||
return newer.Minion{ObjectMeta: newer.ObjectMeta{Name: id}}
|
||||
}
|
||||
oldMinions := []v1beta1.Minion{
|
||||
oldMinion("foo"),
|
||||
@@ -166,7 +166,7 @@ func TestMinionListConversionToOld(t *testing.T) {
|
||||
return v1beta1.Minion{TypeMeta: v1beta1.TypeMeta{ID: id}}
|
||||
}
|
||||
newMinion := func(id string) newer.Minion {
|
||||
return newer.Minion{TypeMeta: newer.TypeMeta{Name: id}}
|
||||
return newer.Minion{ObjectMeta: newer.ObjectMeta{Name: id}}
|
||||
}
|
||||
oldMinions := []v1beta1.Minion{
|
||||
oldMinion("foo"),
|
||||
|
@@ -25,16 +25,21 @@ import (
|
||||
|
||||
func init() {
|
||||
newer.Scheme.AddConversionFuncs(
|
||||
// TypeMeta has changed type of ResourceVersion internally
|
||||
// TypeMeta must be split into two objects
|
||||
func(in *newer.TypeMeta, out *TypeMeta, s conversion.Scope) error {
|
||||
out.APIVersion = in.APIVersion
|
||||
out.Kind = in.Kind
|
||||
out.Namespace = in.Namespace
|
||||
out.ID = in.Name
|
||||
out.CreationTimestamp = in.CreationTimestamp
|
||||
out.SelfLink = in.SelfLink
|
||||
out.Annotations = in.Annotations
|
||||
out.APIVersion = in.APIVersion
|
||||
return nil
|
||||
},
|
||||
func(in *TypeMeta, out *newer.TypeMeta, s conversion.Scope) error {
|
||||
out.Kind = in.Kind
|
||||
out.APIVersion = in.APIVersion
|
||||
return nil
|
||||
},
|
||||
|
||||
// ListMeta must be converted to TypeMeta
|
||||
func(in *newer.ListMeta, out *TypeMeta, s conversion.Scope) error {
|
||||
out.SelfLink = in.SelfLink
|
||||
if len(in.ResourceVersion) > 0 {
|
||||
v, err := strconv.ParseUint(in.ResourceVersion, 10, 64)
|
||||
if err != nil {
|
||||
@@ -44,19 +49,516 @@ func init() {
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *TypeMeta, out *newer.TypeMeta, s conversion.Scope) error {
|
||||
out.APIVersion = in.APIVersion
|
||||
out.Kind = in.Kind
|
||||
out.Namespace = in.Namespace
|
||||
out.Name = in.ID
|
||||
out.CreationTimestamp = in.CreationTimestamp
|
||||
func(in *TypeMeta, out *newer.ListMeta, s conversion.Scope) error {
|
||||
out.SelfLink = in.SelfLink
|
||||
out.Annotations = in.Annotations
|
||||
|
||||
if in.ResourceVersion != 0 {
|
||||
out.ResourceVersion = strconv.FormatUint(in.ResourceVersion, 10)
|
||||
} else {
|
||||
out.ResourceVersion = ""
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
// ObjectMeta must be converted to TypeMeta
|
||||
func(in *newer.ObjectMeta, out *TypeMeta, s conversion.Scope) error {
|
||||
out.Namespace = in.Namespace
|
||||
out.ID = in.Name
|
||||
out.UID = in.UID
|
||||
out.CreationTimestamp = in.CreationTimestamp
|
||||
out.SelfLink = in.SelfLink
|
||||
if len(in.ResourceVersion) > 0 {
|
||||
v, err := strconv.ParseUint(in.ResourceVersion, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.ResourceVersion = v
|
||||
}
|
||||
return s.Convert(&in.Annotations, &out.Annotations, 0)
|
||||
},
|
||||
func(in *TypeMeta, out *newer.ObjectMeta, s conversion.Scope) error {
|
||||
out.Namespace = in.Namespace
|
||||
out.Name = in.ID
|
||||
out.UID = in.UID
|
||||
out.CreationTimestamp = in.CreationTimestamp
|
||||
out.SelfLink = in.SelfLink
|
||||
if in.ResourceVersion != 0 {
|
||||
out.ResourceVersion = strconv.FormatUint(in.ResourceVersion, 10)
|
||||
} else {
|
||||
out.ResourceVersion = ""
|
||||
}
|
||||
return s.Convert(&in.Annotations, &out.Annotations, 0)
|
||||
},
|
||||
|
||||
// Convert all the standard objects
|
||||
// Convert all the standard objects
|
||||
func(in *newer.Pod, out *Pod, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.Convert(&in.DesiredState, &out.DesiredState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.CurrentState, &out.CurrentState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *Pod, out *newer.Pod, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.Convert(&in.DesiredState, &out.DesiredState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.CurrentState, &out.CurrentState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.ReplicationController, out *ReplicationController, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.Convert(&in.DesiredState, &out.DesiredState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.CurrentState, &out.CurrentState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *ReplicationController, out *newer.ReplicationController, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.Convert(&in.DesiredState, &out.DesiredState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.CurrentState, &out.CurrentState, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.Service, out *Service, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Port = in.Port
|
||||
out.Protocol = Protocol(in.Protocol)
|
||||
if err := s.Convert(&in.Selector, &out.Selector, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
out.CreateExternalLoadBalancer = in.CreateExternalLoadBalancer
|
||||
out.ContainerPort = in.ContainerPort
|
||||
out.PortalIP = in.PortalIP
|
||||
out.ProxyPort = in.ProxyPort
|
||||
|
||||
return nil
|
||||
},
|
||||
func(in *Service, out *newer.Service, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Port = in.Port
|
||||
out.Protocol = newer.Protocol(in.Protocol)
|
||||
if err := s.Convert(&in.Selector, &out.Selector, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
out.CreateExternalLoadBalancer = in.CreateExternalLoadBalancer
|
||||
out.ContainerPort = in.ContainerPort
|
||||
out.PortalIP = in.PortalIP
|
||||
out.ProxyPort = in.ProxyPort
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.Binding, out *Binding, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.PodID = in.PodID
|
||||
out.Host = in.Host
|
||||
|
||||
return nil
|
||||
},
|
||||
func(in *Binding, out *newer.Binding, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.PodID = in.PodID
|
||||
out.Host = in.Host
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.Status, out *Status, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Code = in.Code
|
||||
out.Message = in.Message
|
||||
out.Reason = StatusReason(in.Reason)
|
||||
out.Status = in.Status
|
||||
return s.Convert(&in.Details, &out.Details, 0)
|
||||
},
|
||||
func(in *Status, out *newer.Status, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Code = in.Code
|
||||
out.Message = in.Message
|
||||
out.Reason = newer.StatusReason(in.Reason)
|
||||
out.Status = in.Status
|
||||
return s.Convert(&in.Details, &out.Details, 0)
|
||||
},
|
||||
|
||||
func(in *newer.Minion, out *Minion, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.HostIP = in.HostIP
|
||||
return s.Convert(&in.NodeResources, &out.NodeResources, 0)
|
||||
},
|
||||
func(in *Minion, out *newer.Minion, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.HostIP = in.HostIP
|
||||
return s.Convert(&in.NodeResources, &out.NodeResources, 0)
|
||||
},
|
||||
|
||||
func(in *newer.BoundPod, out *BoundPod, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Convert(&in.Spec, &out.Spec, 0)
|
||||
},
|
||||
func(in *BoundPod, out *newer.BoundPod, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Convert(&in.Spec, &out.Spec, 0)
|
||||
},
|
||||
|
||||
func(in *newer.BoundPods, out *BoundPods, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Host = in.Host
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *BoundPods, out *newer.BoundPods, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Host = in.Host
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.Endpoints, out *Endpoints, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Convert(&in.Endpoints, &out.Endpoints, 0)
|
||||
},
|
||||
func(in *Endpoints, out *newer.Endpoints, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Convert(&in.Endpoints, &out.Endpoints, 0)
|
||||
},
|
||||
|
||||
func(in *newer.ServerOp, out *ServerOp, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *ServerOp, out *newer.ServerOp, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
func(in *newer.Event, out *Event, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ObjectMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
out.Source = in.Source
|
||||
out.Status = in.Status
|
||||
out.Timestamp = in.Timestamp
|
||||
return s.Convert(&in.InvolvedObject, &out.InvolvedObject, 0)
|
||||
},
|
||||
func(in *Event, out *newer.Event, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ObjectMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Message = in.Message
|
||||
out.Reason = in.Reason
|
||||
out.Source = in.Source
|
||||
out.Status = in.Status
|
||||
out.Timestamp = in.Timestamp
|
||||
return s.Convert(&in.InvolvedObject, &out.InvolvedObject, 0)
|
||||
},
|
||||
|
||||
// Convert all the standard lists
|
||||
func(in *newer.PodList, out *PodList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *PodList, out *newer.PodList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.ReplicationControllerList, out *ReplicationControllerList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *ReplicationControllerList, out *newer.ReplicationControllerList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.ServiceList, out *ServiceList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *ServiceList, out *newer.ServiceList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.EndpointsList, out *EndpointsList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *EndpointsList, out *newer.EndpointsList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.EventList, out *EventList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *EventList, out *newer.EventList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.MinionList, out *MinionList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *MinionList, out *newer.MinionList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.ServerOpList, out *ServerOpList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *ServerOpList, out *newer.ServerOpList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
|
||||
func(in *newer.ContainerManifestList, out *ContainerManifestList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.ListMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
func(in *ContainerManifestList, out *newer.ContainerManifestList, s conversion.Scope) error {
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.ListMeta, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Convert(&in.Items, &out.Items, 0)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@@ -356,7 +356,7 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ErrorList {
|
||||
}
|
||||
pod := *newPod
|
||||
pod.Labels = oldPod.Labels
|
||||
pod.TypeMeta.ResourceVersion = oldPod.TypeMeta.ResourceVersion
|
||||
pod.ResourceVersion = oldPod.ResourceVersion
|
||||
// Tricky, we need to copy the container list so that we don't overwrite the update
|
||||
var newContainers []api.Container
|
||||
for ix, container := range pod.DesiredState.Manifest.Containers {
|
||||
|
@@ -367,9 +367,11 @@ func TestValidateManifest(t *testing.T) {
|
||||
|
||||
func TestValidatePod(t *testing.T) {
|
||||
errs := ValidatePod(&api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo", Namespace: api.NamespaceDefault,
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
@@ -385,9 +387,12 @@ func TestValidatePod(t *testing.T) {
|
||||
t.Errorf("Unexpected non-zero error list: %#v", errs)
|
||||
}
|
||||
errs = ValidatePod(&api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: api.NamespaceDefault,
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{Version: "v1beta1", ID: "abc"},
|
||||
@@ -398,9 +403,11 @@ func TestValidatePod(t *testing.T) {
|
||||
}
|
||||
|
||||
errs = ValidatePod(&api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo", Namespace: api.NamespaceDefault,
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
@@ -426,25 +433,29 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
{api.Pod{}, api.Pod{}, true, "nothing"},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
},
|
||||
false,
|
||||
"ids",
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
true,
|
||||
@@ -452,7 +463,9 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -464,7 +477,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -483,7 +496,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -495,7 +508,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -511,7 +524,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -524,7 +537,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -541,7 +554,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -556,7 +569,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -598,9 +611,9 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing id",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the ID is missing.
|
||||
numErrs: 1,
|
||||
@@ -608,9 +621,9 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing namespace",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the Namespace is missing.
|
||||
numErrs: 1,
|
||||
@@ -618,9 +631,9 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "invalid id",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "123abc", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "123abc", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the ID is invalid.
|
||||
numErrs: 1,
|
||||
@@ -628,8 +641,8 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing port",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the port number is missing/invalid.
|
||||
numErrs: 1,
|
||||
@@ -637,9 +650,9 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "invalid port",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65536,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65536,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the port number is invalid.
|
||||
numErrs: 1,
|
||||
@@ -647,10 +660,10 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "invalid protocol",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Protocol: "INVALID",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Protocol: "INVALID",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the protocol is invalid.
|
||||
numErrs: 1,
|
||||
@@ -658,8 +671,8 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing selector",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
},
|
||||
// Should fail because the selector is missing.
|
||||
numErrs: 1,
|
||||
@@ -667,29 +680,29 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "valid 1",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 1,
|
||||
Protocol: "TCP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 1,
|
||||
Protocol: "TCP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "valid 2",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65535,
|
||||
Protocol: "UDP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65535,
|
||||
Protocol: "UDP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "valid 3",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 80,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 80,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
@@ -703,9 +716,9 @@ func TestValidateService(t *testing.T) {
|
||||
}
|
||||
|
||||
svc := api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
}
|
||||
errs := ValidateService(&svc)
|
||||
if len(errs) != 0 {
|
||||
@@ -736,14 +749,14 @@ func TestValidateReplicationController(t *testing.T) {
|
||||
}
|
||||
successCases := []api.ReplicationController{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
@@ -758,47 +771,47 @@ func TestValidateReplicationController(t *testing.T) {
|
||||
|
||||
errorCases := map[string]api.ReplicationController{
|
||||
"zero-length ID": {
|
||||
TypeMeta: api.TypeMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"missing-namespace": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc-123"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc-123"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"empty selector": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"selector_doesnt_match": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: map[string]string{"foo": "bar"},
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"invalid manifest": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
},
|
||||
},
|
||||
"read-write presistent disk": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: invalidVolumePodTemplate,
|
||||
},
|
||||
},
|
||||
"negative_replicas": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: -1,
|
||||
ReplicaSelector: validSelector,
|
||||
@@ -827,13 +840,13 @@ func TestValidateReplicationController(t *testing.T) {
|
||||
func TestValidateBoundPodNoName(t *testing.T) {
|
||||
errorCases := map[string]api.BoundPod{
|
||||
// manifest is tested in api/validation_test.go, ensure it is invoked
|
||||
"empty version": {TypeMeta: api.TypeMeta{Name: "test"}, Spec: api.PodSpec{Containers: []api.Container{{Name: ""}}}},
|
||||
"empty version": {ObjectMeta: api.ObjectMeta{Name: "test"}, Spec: api.PodSpec{Containers: []api.Container{{Name: ""}}}},
|
||||
|
||||
// Name
|
||||
"zero-length name": {TypeMeta: api.TypeMeta{Name: ""}},
|
||||
"name > 255 characters": {TypeMeta: api.TypeMeta{Name: strings.Repeat("a", 256)}},
|
||||
"name not a DNS subdomain": {TypeMeta: api.TypeMeta{Name: "a.b.c."}},
|
||||
"name with underscore": {TypeMeta: api.TypeMeta{Name: "a_b_c"}},
|
||||
"zero-length name": {ObjectMeta: api.ObjectMeta{Name: ""}},
|
||||
"name > 255 characters": {ObjectMeta: api.ObjectMeta{Name: strings.Repeat("a", 256)}},
|
||||
"name not a DNS subdomain": {ObjectMeta: api.ObjectMeta{Name: "a.b.c."}},
|
||||
"name with underscore": {ObjectMeta: api.ObjectMeta{Name: "a_b_c"}},
|
||||
}
|
||||
for k, v := range errorCases {
|
||||
if errs := ValidateBoundPod(&v); len(errs) == 0 {
|
||||
|
@@ -53,14 +53,16 @@ func init() {
|
||||
}
|
||||
|
||||
type Simple struct {
|
||||
api.TypeMeta `yaml:",inline" json:",inline"`
|
||||
Other string `yaml:"other,omitempty" json:"other,omitempty"`
|
||||
api.TypeMeta `yaml:",inline" json:",inline"`
|
||||
api.ObjectMeta `yaml:"metadata,inline" json:"metadata,inline"`
|
||||
Other string `yaml:"other,omitempty" json:"other,omitempty"`
|
||||
}
|
||||
|
||||
func (*Simple) IsAnAPIObject() {}
|
||||
|
||||
type SimpleList struct {
|
||||
api.TypeMeta `yaml:",inline" json:",inline"`
|
||||
api.ListMeta `yaml:"metadata,inline" json:"metadata,inline"`
|
||||
Items []Simple `yaml:"items,omitempty" json:"items,omitempty"`
|
||||
}
|
||||
|
||||
@@ -108,7 +110,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{TypeMeta: api.TypeMeta{Name: id}})
|
||||
return storage.injectedFunction(&Simple{ObjectMeta: api.ObjectMeta{Name: id}})
|
||||
}
|
||||
return &api.Status{Status: api.StatusSuccess}, nil
|
||||
}), nil
|
||||
@@ -310,6 +312,8 @@ func TestNonEmptyList(t *testing.T) {
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Errorf("Unexpected status: %d, Expected: %d, %#v", resp.StatusCode, http.StatusOK, resp)
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
t.Logf("Data: %s", string(body))
|
||||
}
|
||||
|
||||
var listOut SimpleList
|
||||
|
@@ -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{TypeMeta: api.TypeMeta{Name: id}})
|
||||
ol.Items = append(ol.Items, api.ServerOp{ObjectMeta: api.ObjectMeta{Name: id}})
|
||||
}
|
||||
return ol
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ func TestOperation(t *testing.T) {
|
||||
time.Sleep(time.Millisecond)
|
||||
go func() {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
c <- &Simple{TypeMeta: api.TypeMeta{Name: "All done"}}
|
||||
c <- &Simple{ObjectMeta: api.ObjectMeta{Name: "All done"}}
|
||||
}()
|
||||
|
||||
if op.expired(time.Now().Add(-time.Minute)) {
|
||||
@@ -119,7 +119,7 @@ func TestOperationsList(t *testing.T) {
|
||||
client := http.Client{}
|
||||
|
||||
simple := &Simple{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
data, err := codec.Encode(simple)
|
||||
if err != nil {
|
||||
@@ -175,7 +175,7 @@ func TestOpGet(t *testing.T) {
|
||||
client := http.Client{}
|
||||
|
||||
simple := &Simple{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
data, err := codec.Encode(simple)
|
||||
t.Log(string(data))
|
||||
|
20
pkg/client/cache/reflector_test.go
vendored
20
pkg/client/cache/reflector_test.go
vendored
@@ -54,13 +54,13 @@ func TestReflector_watchHandler(t *testing.T) {
|
||||
s := NewStore()
|
||||
g := NewReflector(&testLW{}, &api.Pod{}, s)
|
||||
fw := watch.NewFake()
|
||||
s.Add("foo", &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}})
|
||||
s.Add("bar", &api.Pod{TypeMeta: api.TypeMeta{Name: "bar"}})
|
||||
s.Add("foo", &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
s.Add("bar", &api.Pod{ObjectMeta: api.ObjectMeta{Name: "bar"}})
|
||||
go func() {
|
||||
fw.Add(&api.Service{TypeMeta: api.TypeMeta{Name: "rejected"}})
|
||||
fw.Delete(&api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}})
|
||||
fw.Modify(&api.Pod{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "55"}})
|
||||
fw.Add(&api.Pod{TypeMeta: api.TypeMeta{Name: "baz", ResourceVersion: "32"}})
|
||||
fw.Add(&api.Service{ObjectMeta: api.ObjectMeta{Name: "rejected"}})
|
||||
fw.Delete(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
fw.Modify(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "55"}})
|
||||
fw.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "baz", ResourceVersion: "32"}})
|
||||
fw.Stop()
|
||||
}()
|
||||
var resumeRV string
|
||||
@@ -118,7 +118,7 @@ func TestReflector_listAndWatch(t *testing.T) {
|
||||
return fw, nil
|
||||
},
|
||||
ListFunc: func() (runtime.Object, error) {
|
||||
return &api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: "1"}}, nil
|
||||
return &api.PodList{ListMeta: api.ListMeta{ResourceVersion: "1"}}, nil
|
||||
},
|
||||
}
|
||||
s := NewFIFO()
|
||||
@@ -132,7 +132,7 @@ func TestReflector_listAndWatch(t *testing.T) {
|
||||
fw = <-createdFakes
|
||||
}
|
||||
sendingRV := strconv.FormatUint(uint64(i+2), 10)
|
||||
fw.Add(&api.Pod{TypeMeta: api.TypeMeta{Name: id, ResourceVersion: sendingRV}})
|
||||
fw.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: id, ResourceVersion: sendingRV}})
|
||||
if sendingRV == "3" {
|
||||
// Inject a failure.
|
||||
fw.Stop()
|
||||
@@ -158,10 +158,10 @@ func TestReflector_listAndWatch(t *testing.T) {
|
||||
|
||||
func TestReflector_listAndWatchWithErrors(t *testing.T) {
|
||||
mkPod := func(id string, rv string) *api.Pod {
|
||||
return &api.Pod{TypeMeta: api.TypeMeta{Name: id, ResourceVersion: rv}}
|
||||
return &api.Pod{ObjectMeta: api.ObjectMeta{Name: id, ResourceVersion: rv}}
|
||||
}
|
||||
mkList := func(rv string, pods ...*api.Pod) *api.PodList {
|
||||
list := &api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: rv}}
|
||||
list := &api.PodList{ListMeta: api.ListMeta{ResourceVersion: rv}}
|
||||
for _, pod := range pods {
|
||||
list.Items = append(list.Items, *pod)
|
||||
}
|
||||
|
@@ -166,9 +166,11 @@ func TestListPods(t *testing.T) {
|
||||
CurrentState: api.PodState{
|
||||
Status: "Foobar",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -197,9 +199,11 @@ func TestListPodsLabels(t *testing.T) {
|
||||
CurrentState: api.PodState{
|
||||
Status: "Foobar",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -223,9 +227,11 @@ func TestGetPod(t *testing.T) {
|
||||
CurrentState: api.PodState{
|
||||
Status: "Foobar",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -248,9 +254,11 @@ func TestCreatePod(t *testing.T) {
|
||||
CurrentState: api.PodState{
|
||||
Status: "Foobar",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
}
|
||||
c := &testClient{
|
||||
@@ -266,14 +274,17 @@ func TestCreatePod(t *testing.T) {
|
||||
|
||||
func TestUpdatePod(t *testing.T) {
|
||||
requestPod := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
CurrentState: api.PodState{
|
||||
Status: "Foobar",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "PUT", Path: "/pods/foo"},
|
||||
@@ -290,14 +301,16 @@ func TestListControllers(t *testing.T) {
|
||||
Body: &api.ReplicationControllerList{
|
||||
Items: []api.ReplicationController{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -314,14 +327,16 @@ func TestGetController(t *testing.T) {
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -331,21 +346,23 @@ func TestGetController(t *testing.T) {
|
||||
|
||||
func TestUpdateController(t *testing.T) {
|
||||
requestController := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "PUT", Path: "/replicationControllers/foo"},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -364,21 +381,23 @@ func TestDeleteController(t *testing.T) {
|
||||
|
||||
func TestCreateController(t *testing.T) {
|
||||
requestController := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "POST", Path: "/replicationControllers", Body: requestController},
|
||||
Response: Response{
|
||||
StatusCode: 200,
|
||||
Body: &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -402,10 +421,12 @@ func TestListServices(t *testing.T) {
|
||||
Body: &api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "name"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "name",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
Selector: map[string]string{
|
||||
"one": "two",
|
||||
@@ -416,6 +437,7 @@ func TestListServices(t *testing.T) {
|
||||
},
|
||||
}
|
||||
receivedServiceList, err := c.Setup().ListServices(api.NewDefaultContext(), labels.Everything())
|
||||
t.Logf("received services: %v %#v", err, receivedServiceList)
|
||||
c.Validate(t, receivedServiceList, err)
|
||||
}
|
||||
|
||||
@@ -426,10 +448,12 @@ func TestListServicesLabels(t *testing.T) {
|
||||
Body: &api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "name"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "name",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
"name": "baz",
|
||||
},
|
||||
},
|
||||
Selector: map[string]string{
|
||||
"one": "two",
|
||||
@@ -449,7 +473,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{TypeMeta: api.TypeMeta{Name: "service-1"}}},
|
||||
Response: Response{StatusCode: 200, Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}},
|
||||
}
|
||||
response, err := c.Setup().GetService(api.NewDefaultContext(), "1")
|
||||
c.Validate(t, response, err)
|
||||
@@ -457,15 +481,15 @@ func TestGetService(t *testing.T) {
|
||||
|
||||
func TestCreateService(t *testing.T) {
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "POST", Path: "/services", Body: &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}}},
|
||||
Response: Response{StatusCode: 200, Body: &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}}},
|
||||
Request: testRequest{Method: "POST", Path: "/services", Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}},
|
||||
Response: Response{StatusCode: 200, Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}},
|
||||
}
|
||||
response, err := c.Setup().CreateService(api.NewDefaultContext(), &api.Service{TypeMeta: api.TypeMeta{Name: "service-1"}})
|
||||
response, err := c.Setup().CreateService(api.NewDefaultContext(), &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}})
|
||||
c.Validate(t, response, err)
|
||||
}
|
||||
|
||||
func TestUpdateService(t *testing.T) {
|
||||
svc := &api.Service{TypeMeta: api.TypeMeta{Name: "service-1", ResourceVersion: "1"}}
|
||||
svc := &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1", ResourceVersion: "1"}}
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "PUT", Path: "/services/service-1", Body: svc},
|
||||
Response: Response{StatusCode: 200, Body: svc},
|
||||
@@ -490,8 +514,8 @@ func TestListEndpooints(t *testing.T) {
|
||||
Body: &api.EndpointsList{
|
||||
Items: []api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "endpoint-1"},
|
||||
Endpoints: []string{"10.245.1.2:8080", "10.245.1.3:8080"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "endpoint-1"},
|
||||
Endpoints: []string{"10.245.1.2:8080", "10.245.1.3:8080"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -504,7 +528,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{TypeMeta: api.TypeMeta{Name: "endpoint-1"}}},
|
||||
Response: Response{StatusCode: 200, Body: &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "endpoint-1"}}},
|
||||
}
|
||||
response, err := c.Setup().GetEndpoints(api.NewDefaultContext(), "endpoint-1")
|
||||
c.Validate(t, response, err)
|
||||
@@ -540,7 +564,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{TypeMeta: api.TypeMeta{Name: "minion-1"}}},
|
||||
Response: Response{StatusCode: 200, Body: &api.MinionList{ListMeta: api.ListMeta{ResourceVersion: "1"}}},
|
||||
}
|
||||
response, err := c.Setup().ListMinions()
|
||||
c.Validate(t, response, err)
|
||||
@@ -548,7 +572,7 @@ func TestListMinions(t *testing.T) {
|
||||
|
||||
func TestCreateMinion(t *testing.T) {
|
||||
requestMinion := &api.Minion{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "minion-1",
|
||||
},
|
||||
HostIP: "123.321.456.654",
|
||||
|
@@ -54,7 +54,7 @@ func TestEventf(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
obj: &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
SelfLink: "/api/v1beta1/pods/foo",
|
||||
Name: "foo",
|
||||
UID: "bar",
|
||||
|
@@ -72,7 +72,7 @@ func TestDoRequestNewWay(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDoRequestNewWayReader(t *testing.T) {
|
||||
reqObj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
reqObj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
reqObj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
reqObj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
reqBodyExpected, err := v1beta1.Codec.Encode(reqObj)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@@ -412,9 +412,9 @@ func TestWatch(t *testing.T) {
|
||||
t watch.EventType
|
||||
obj runtime.Object
|
||||
}{
|
||||
{watch.Added, &api.Pod{TypeMeta: api.TypeMeta{Name: "first"}}},
|
||||
{watch.Modified, &api.Pod{TypeMeta: api.TypeMeta{Name: "second"}}},
|
||||
{watch.Deleted, &api.Pod{TypeMeta: api.TypeMeta{Name: "last"}}},
|
||||
{watch.Added, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "first"}}},
|
||||
{watch.Modified, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "second"}}},
|
||||
{watch.Deleted, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "last"}}},
|
||||
}
|
||||
|
||||
auth := &Config{Username: "user", Password: "pass"}
|
||||
|
@@ -45,8 +45,8 @@ func NewTestEtcdRegistry(client tools.EtcdClient) *etcdregistry.Registry {
|
||||
func TestSyncCreateMinion(t *testing.T) {
|
||||
ctx := api.NewContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m1"}})
|
||||
m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m2"}})
|
||||
m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m1"}})
|
||||
m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m2"}})
|
||||
fakeClient.Set("/registry/minions/m1", m1, 0)
|
||||
fakeClient.Set("/registry/minions/m2", m2, 0)
|
||||
fakeClient.ExpectNotFoundGet("/registry/minions/m3")
|
||||
@@ -88,9 +88,9 @@ func TestSyncCreateMinion(t *testing.T) {
|
||||
func TestSyncDeleteMinion(t *testing.T) {
|
||||
ctx := api.NewContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m1"}})
|
||||
m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m2"}})
|
||||
m3 := runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "m3"}})
|
||||
m1 := runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m1"}})
|
||||
m2 := runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m2"}})
|
||||
m3 := runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m3"}})
|
||||
fakeClient.Set("/registry/minions/m1", m1, 0)
|
||||
fakeClient.Set("/registry/minions/m2", m2, 0)
|
||||
fakeClient.Set("/registry/minions/m3", m3, 0)
|
||||
|
@@ -53,18 +53,20 @@ type RealPodControl struct {
|
||||
}
|
||||
|
||||
func (r RealPodControl) createReplica(ctx api.Context, controllerSpec api.ReplicationController) {
|
||||
labels := controllerSpec.DesiredState.PodTemplate.Labels
|
||||
// TODO: don't fail to set this label just because the map isn't created.
|
||||
if labels != nil {
|
||||
labels["replicationController"] = controllerSpec.Name
|
||||
desiredLabels := make(labels.Set)
|
||||
for k, v := range controllerSpec.DesiredState.PodTemplate.Labels {
|
||||
desiredLabels[k] = v
|
||||
}
|
||||
desiredLabels["replicationController"] = controllerSpec.Name
|
||||
|
||||
pod := &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: desiredLabels,
|
||||
},
|
||||
DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState,
|
||||
Labels: controllerSpec.DesiredState.PodTemplate.Labels,
|
||||
}
|
||||
_, err := r.kubeClient.CreatePod(ctx, pod)
|
||||
if err != nil {
|
||||
glog.Errorf("%#v\n", err)
|
||||
if _, err := r.kubeClient.CreatePod(ctx, pod); err != nil {
|
||||
glog.Errorf("Unable to create pod replica: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,6 @@ limitations under the License.
|
||||
package controller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -89,7 +88,7 @@ func newPodList(count int) *api.PodList {
|
||||
pods := []api.Pod{}
|
||||
for i := 0; i < count; i++ {
|
||||
pods = append(pods, api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: fmt.Sprintf("pod%d", i),
|
||||
},
|
||||
})
|
||||
@@ -183,8 +182,8 @@ func TestCreateReplica(t *testing.T) {
|
||||
}
|
||||
|
||||
controllerSpec := api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
Kind: "ReplicationController",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "test",
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
PodTemplate: api.PodTemplate{
|
||||
@@ -198,8 +197,9 @@ func TestCreateReplica(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"name": "foo",
|
||||
"type": "production",
|
||||
"name": "foo",
|
||||
"type": "production",
|
||||
"replicationController": "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -208,21 +208,19 @@ func TestCreateReplica(t *testing.T) {
|
||||
podControl.createReplica(ctx, controllerSpec)
|
||||
|
||||
expectedPod := api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: testapi.Version(),
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: controllerSpec.DesiredState.PodTemplate.Labels,
|
||||
},
|
||||
Labels: controllerSpec.DesiredState.PodTemplate.Labels,
|
||||
DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState,
|
||||
}
|
||||
fakeHandler.ValidateRequest(t, makeURL("/pods?namespace=default"), "POST", nil)
|
||||
actualPod := api.Pod{}
|
||||
if err := json.Unmarshal([]byte(fakeHandler.RequestBody), &actualPod); err != nil {
|
||||
actualPod, err := client.Codec.Decode([]byte(fakeHandler.RequestBody))
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %#v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(expectedPod, actualPod) {
|
||||
if !reflect.DeepEqual(&expectedPod, actualPod) {
|
||||
t.Logf("Body: %s", fakeHandler.RequestBody)
|
||||
t.Errorf("Unexpected mismatch. Expected\n %#v,\n Got:\n %#v", expectedPod, actualPod)
|
||||
t.Errorf("Unexpected mismatch. Expected\n %#v,\n Got:\n %#v", &expectedPod, actualPod)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,7 @@ func (s *Scheme) Decode(data []byte) (interface{}, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// yaml is a superset of json, so we use it to decode here. That way,
|
||||
// we understand both.
|
||||
err = yaml.Unmarshal(data, obj)
|
||||
|
@@ -245,7 +245,7 @@ func RunController(ctx api.Context, image, name string, replicas int, client cli
|
||||
return err
|
||||
}
|
||||
controller := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
@@ -299,11 +299,13 @@ 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{
|
||||
TypeMeta: api.TypeMeta{Name: name},
|
||||
Port: port,
|
||||
Labels: map[string]string{
|
||||
"simpleService": name,
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Labels: map[string]string{
|
||||
"simpleService": name,
|
||||
},
|
||||
},
|
||||
Port: port,
|
||||
Selector: map[string]string{
|
||||
"simpleService": name,
|
||||
},
|
||||
|
@@ -38,8 +38,8 @@ func TestUpdateWithPods(t *testing.T) {
|
||||
fakeClient := client.Fake{
|
||||
Pods: api.PodList{
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "pod-1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "pod-2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "pod-1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "pod-2"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -69,8 +69,8 @@ func TestUpdateWithNewImage(t *testing.T) {
|
||||
fakeClient := client.Fake{
|
||||
Pods: api.PodList{
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "pod-1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "pod-2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "pod-1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "pod-2"}},
|
||||
},
|
||||
},
|
||||
Ctrl: api.ReplicationController{
|
||||
|
@@ -69,7 +69,8 @@ var testParser = NewParser(map[string]runtime.Object{
|
||||
|
||||
func TestParsePod(t *testing.T) {
|
||||
DoParseTest(t, "pods", &api.Pod{
|
||||
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Name: "test pod", Kind: "Pod"},
|
||||
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Kind: "Pod"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test pod"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
ID: "My manifest",
|
||||
@@ -86,11 +87,14 @@ func TestParsePod(t *testing.T) {
|
||||
|
||||
func TestParseService(t *testing.T) {
|
||||
DoParseTest(t, "services", &api.Service{
|
||||
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Name: "my service", Kind: "Service"},
|
||||
Port: 8080,
|
||||
Labels: map[string]string{
|
||||
"area": "staging",
|
||||
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Kind: "Service"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "my service",
|
||||
Labels: map[string]string{
|
||||
"area": "staging",
|
||||
},
|
||||
},
|
||||
Port: 8080,
|
||||
Selector: map[string]string{
|
||||
"area": "staging",
|
||||
},
|
||||
@@ -99,7 +103,8 @@ func TestParseService(t *testing.T) {
|
||||
|
||||
func TestParseController(t *testing.T) {
|
||||
DoParseTest(t, "replicationControllers", &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Name: "my controller", Kind: "ReplicationController"},
|
||||
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Kind: "ReplicationController"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "my controller"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 9001,
|
||||
PodTemplate: api.PodTemplate{
|
||||
@@ -120,8 +125,9 @@ func TestParseController(t *testing.T) {
|
||||
}
|
||||
|
||||
type TestParseType struct {
|
||||
api.TypeMeta `json:",inline" yaml:",inline"`
|
||||
Data string `json:"data" yaml:"data"`
|
||||
api.TypeMeta `json:",inline" yaml:",inline"`
|
||||
api.ObjectMeta `json:"metadata" yaml:"metadata"`
|
||||
Data string `json:"data" yaml:"data"`
|
||||
}
|
||||
|
||||
func (*TestParseType) IsAnAPIObject() {}
|
||||
@@ -134,7 +140,8 @@ func TestParseCustomType(t *testing.T) {
|
||||
"custom": &TestParseType{},
|
||||
})
|
||||
DoParseTest(t, "custom", &TestParseType{
|
||||
TypeMeta: api.TypeMeta{APIVersion: "", Name: "my custom object", Kind: "TestParseType"},
|
||||
Data: "test data",
|
||||
TypeMeta: api.TypeMeta{APIVersion: "", Kind: "TestParseType"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "my custom object"},
|
||||
Data: "test data",
|
||||
}, v1beta1.Codec, parser)
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ func TestYAMLPrinterPrint(t *testing.T) {
|
||||
}
|
||||
|
||||
obj := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
buf.Reset()
|
||||
printer.PrintObj(obj, buf)
|
||||
@@ -92,7 +92,7 @@ func TestIdentityPrinter(t *testing.T) {
|
||||
}
|
||||
|
||||
obj := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
buff.Reset()
|
||||
printer.PrintObj(obj, buff)
|
||||
|
@@ -69,7 +69,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
|
||||
}
|
||||
|
||||
obj := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}
|
||||
buf.Reset()
|
||||
printer.PrintObj(obj, buf)
|
||||
|
@@ -50,7 +50,7 @@ func (s sortedPods) Less(i, j int) bool {
|
||||
|
||||
func CreateValidPod(name, namespace, source string) api.BoundPod {
|
||||
return api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
Annotations: map[string]string{kubelet.ConfigSourceAnnotationKey: source},
|
||||
@@ -158,7 +158,7 @@ func TestInvalidPodFiltered(t *testing.T) {
|
||||
expectPodUpdate(t, ch, CreatePodUpdate(kubelet.ADD, CreateValidPod("foo", "new", "test")))
|
||||
|
||||
// add an invalid update
|
||||
podUpdate = CreatePodUpdate(kubelet.UPDATE, api.BoundPod{TypeMeta: api.TypeMeta{Name: "foo"}})
|
||||
podUpdate = CreatePodUpdate(kubelet.UPDATE, api.BoundPod{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
channel <- podUpdate
|
||||
expectNoPodUpdate(t, ch)
|
||||
}
|
||||
@@ -217,7 +217,7 @@ func TestNewPodAddedUpdatedRemoved(t *testing.T) {
|
||||
channel <- podUpdate
|
||||
expectPodUpdate(t, ch, CreatePodUpdate(kubelet.UPDATE, pod))
|
||||
|
||||
podUpdate = CreatePodUpdate(kubelet.REMOVE, api.BoundPod{TypeMeta: api.TypeMeta{Name: "foo", Namespace: "new"}})
|
||||
podUpdate = CreatePodUpdate(kubelet.REMOVE, api.BoundPod{ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "new"}})
|
||||
channel <- podUpdate
|
||||
expectPodUpdate(t, ch, CreatePodUpdate(kubelet.REMOVE, pod))
|
||||
}
|
||||
|
@@ -44,14 +44,14 @@ func TestEventToPods(t *testing.T) {
|
||||
input: watch.Event{
|
||||
Object: &api.BoundPods{
|
||||
Items: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
pods: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
},
|
||||
fail: false,
|
||||
},
|
||||
@@ -59,14 +59,14 @@ func TestEventToPods(t *testing.T) {
|
||||
input: watch.Event{
|
||||
Object: &api.BoundPods{
|
||||
Items: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "2", Namespace: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "2", Namespace: "foo"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
pods: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "1", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
{TypeMeta: api.TypeMeta{Name: "2", Namespace: "foo"}, Spec: api.PodSpec{}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "1", Namespace: "default"}, Spec: api.PodSpec{}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "2", Namespace: "foo"}, Spec: api.PodSpec{}},
|
||||
},
|
||||
fail: false,
|
||||
},
|
||||
|
@@ -52,7 +52,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
|
||||
},
|
||||
}
|
||||
expectedPod := api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: id,
|
||||
UID: "uid",
|
||||
Namespace: "default",
|
||||
@@ -118,7 +118,7 @@ func TestReadFromFile(t *testing.T) {
|
||||
case got := <-ch:
|
||||
update := got.(kubelet.PodUpdate)
|
||||
expected := CreatePodUpdate(kubelet.SET, api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: simpleSubdomainSafeHash(file.Name()),
|
||||
UID: simpleSubdomainSafeHash(file.Name()),
|
||||
Namespace: "default",
|
||||
|
@@ -124,7 +124,7 @@ func TestExtractFromHTTP(t *testing.T) {
|
||||
manifests: api.ContainerManifest{Version: "v1beta1", ID: "foo"},
|
||||
expected: CreatePodUpdate(kubelet.SET,
|
||||
api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "default",
|
||||
},
|
||||
@@ -141,14 +141,14 @@ func TestExtractFromHTTP(t *testing.T) {
|
||||
},
|
||||
expected: CreatePodUpdate(kubelet.SET,
|
||||
api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "1",
|
||||
Namespace: "default",
|
||||
},
|
||||
Spec: api.PodSpec{Containers: []api.Container{{Name: "1", Image: "foo"}}},
|
||||
},
|
||||
api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "bar",
|
||||
Namespace: "default",
|
||||
},
|
||||
|
@@ -167,7 +167,7 @@ func TestSyncPodsDoesNothing(t *testing.T) {
|
||||
}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
@@ -213,7 +213,7 @@ func TestSyncPodsCreatesNetAndContainer(t *testing.T) {
|
||||
fakeDocker.ContainerList = []docker.APIContainers{}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
@@ -261,7 +261,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
|
||||
fakeDocker.ContainerList = []docker.APIContainers{}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
@@ -306,7 +306,7 @@ func TestSyncPodsWithNetCreatesContainer(t *testing.T) {
|
||||
}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
@@ -347,7 +347,7 @@ func TestSyncPodsWithNetCreatesContainerCallsHandler(t *testing.T) {
|
||||
}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
@@ -400,7 +400,7 @@ func TestSyncPodsDeletesWithNoNetContainer(t *testing.T) {
|
||||
}
|
||||
err := kubelet.SyncPods([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
@@ -495,7 +495,7 @@ func TestSyncPodDeletesDuplicate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := kubelet.syncPod(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "bar",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
@@ -544,7 +544,7 @@ func TestSyncPodBadHash(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := kubelet.syncPod(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
@@ -588,7 +588,7 @@ func TestSyncPodUnhealthy(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := kubelet.syncPod(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
@@ -648,7 +648,7 @@ func TestMakeEnvVariables(t *testing.T) {
|
||||
func TestMountExternalVolumes(t *testing.T) {
|
||||
kubelet, _, _ := newTestKubelet(t)
|
||||
pod := api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "test",
|
||||
},
|
||||
@@ -703,7 +703,7 @@ func TestMakeVolumesAndBinds(t *testing.T) {
|
||||
}
|
||||
|
||||
pod := api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "pod",
|
||||
Namespace: "test",
|
||||
},
|
||||
@@ -988,7 +988,7 @@ func TestRunInContainerNoSuchPod(t *testing.T) {
|
||||
podNamespace := "etcd"
|
||||
containerName := "containerFoo"
|
||||
output, err := kubelet.RunInContainer(
|
||||
GetPodFullName(&api.BoundPod{TypeMeta: api.TypeMeta{Name: podName, Namespace: podNamespace}}),
|
||||
GetPodFullName(&api.BoundPod{ObjectMeta: api.ObjectMeta{Name: podName, Namespace: podNamespace}}),
|
||||
"",
|
||||
containerName,
|
||||
[]string{"ls"})
|
||||
@@ -1020,7 +1020,7 @@ func TestRunInContainer(t *testing.T) {
|
||||
cmd := []string{"ls"}
|
||||
_, err := kubelet.RunInContainer(
|
||||
GetPodFullName(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podName,
|
||||
Namespace: podNamespace,
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
@@ -1162,7 +1162,7 @@ func TestSyncPodEventHandlerFails(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := kubelet.syncPod(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@@ -108,7 +108,7 @@ func TestRunOnce(t *testing.T) {
|
||||
kb.dockerPuller = &dockertools.FakeDockerPuller{}
|
||||
results, err := kb.runOnce([]api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "new",
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "test"},
|
||||
|
@@ -204,7 +204,7 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
|
||||
tail := uriValues.Get("tail")
|
||||
|
||||
podFullName := GetPodFullName(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podID,
|
||||
Namespace: podNamespace,
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"},
|
||||
@@ -248,7 +248,7 @@ func (s *Server) handlePodInfo(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
// TODO: backwards compatibility with existing API, needs API change
|
||||
podFullName := GetPodFullName(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podID,
|
||||
Namespace: podNamespace,
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"},
|
||||
@@ -323,7 +323,7 @@ func (s *Server) handleRun(w http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
podFullName := GetPodFullName(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podID,
|
||||
Namespace: podNamespace,
|
||||
Annotations: map[string]string{ConfigSourceAnnotationKey: "etcd"},
|
||||
@@ -373,7 +373,7 @@ func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
|
||||
case 3:
|
||||
// Backward compatibility without uuid information
|
||||
podFullName := GetPodFullName(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: components[1],
|
||||
// TODO: I am broken
|
||||
Namespace: api.NamespaceDefault,
|
||||
@@ -383,7 +383,7 @@ func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
|
||||
stats, err = s.host.GetContainerInfo(podFullName, "", components[2], &query)
|
||||
case 4:
|
||||
podFullName := GetPodFullName(&api.BoundPod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: components[1],
|
||||
// TODO: I am broken
|
||||
Namespace: "",
|
||||
|
@@ -132,7 +132,7 @@ func TestContainer(t *testing.T) {
|
||||
}
|
||||
expectedPods := []api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "test_manifest",
|
||||
UID: "value",
|
||||
},
|
||||
@@ -207,7 +207,7 @@ func TestContainers(t *testing.T) {
|
||||
}
|
||||
expectedPods := []api.BoundPod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "1",
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
@@ -227,7 +227,7 @@ func TestContainers(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "2",
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
|
@@ -125,7 +125,7 @@ func (m *Master) init(c *Config) {
|
||||
} else {
|
||||
for _, minionID := range c.Minions {
|
||||
m.minionRegistry.CreateMinion(nil, &api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: minionID},
|
||||
ObjectMeta: api.ObjectMeta{Name: minionID},
|
||||
NodeResources: c.NodeResources,
|
||||
})
|
||||
}
|
||||
|
@@ -124,7 +124,7 @@ func TestPodGetPodInfoGetter(t *testing.T) {
|
||||
|
||||
func TestPodUpdateAllContainers(t *testing.T) {
|
||||
pod := api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
CurrentState: api.PodState{
|
||||
Host: "machine",
|
||||
},
|
||||
|
@@ -27,7 +27,7 @@ import (
|
||||
)
|
||||
|
||||
func TestServices(t *testing.T) {
|
||||
service := api.Service{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
service := api.Service{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "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{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
service := api.Service{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
|
||||
fakeWatch := watch.NewFake()
|
||||
fakeWatch.Stop()
|
||||
fakeClient := &client.Fake{Watch: fakeWatch}
|
||||
fakeClient.ServiceList = api.ServiceList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "2"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "2"},
|
||||
Items: []api.Service{
|
||||
service,
|
||||
},
|
||||
@@ -152,7 +152,7 @@ func TestServicesFromZeroError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEndpoints(t *testing.T) {
|
||||
endpoint := api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
endpoint := api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "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{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
endpoint := api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
|
||||
fakeWatch := watch.NewFake()
|
||||
fakeWatch.Stop()
|
||||
fakeClient := &client.Fake{Watch: fakeWatch}
|
||||
fakeClient.EndpointsList = api.EndpointsList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "2"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "2"},
|
||||
Items: []api.Endpoints{
|
||||
endpoint,
|
||||
},
|
||||
|
@@ -136,7 +136,7 @@ func TestNewServiceAddedAndNotified(t *testing.T) {
|
||||
handler := NewServiceHandlerMock()
|
||||
handler.Wait(1)
|
||||
config.RegisterHandler(handler)
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
handler.Wait(1)
|
||||
channel <- serviceUpdate
|
||||
handler.ValidateServices(t, serviceUpdate.Services)
|
||||
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}})
|
||||
serviceUpdate3 := CreateServiceUpdate(REMOVE, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
handler.Wait(1)
|
||||
channel <- serviceUpdate3
|
||||
services = []api.Service{serviceUpdate2.Services[0]}
|
||||
handler.ValidateServices(t, services)
|
||||
|
||||
serviceUpdate4 := CreateServiceUpdate(SET, api.Service{TypeMeta: api.TypeMeta{Name: "foobar"}, Port: 99})
|
||||
serviceUpdate4 := CreateServiceUpdate(SET, api.Service{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
|
||||
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
|
||||
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}, Port: 20})
|
||||
handler.Wait(2)
|
||||
handler2.Wait(2)
|
||||
channelOne <- serviceUpdate1
|
||||
@@ -217,12 +217,12 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddedAndNotified(t *testing.
|
||||
config.RegisterHandler(handler)
|
||||
config.RegisterHandler(handler2)
|
||||
endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
})
|
||||
endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
})
|
||||
handler.Wait(2)
|
||||
handler2.Wait(2)
|
||||
@@ -243,12 +243,12 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
||||
config.RegisterHandler(handler)
|
||||
config.RegisterHandler(handler2)
|
||||
endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
})
|
||||
endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
})
|
||||
handler.Wait(2)
|
||||
handler2.Wait(2)
|
||||
@@ -261,8 +261,8 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
||||
|
||||
// Add one more
|
||||
endpointsUpdate3 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foobar"},
|
||||
Endpoints: []string{"endpoint5", "endpoint6"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foobar"},
|
||||
Endpoints: []string{"endpoint5", "endpoint6"},
|
||||
})
|
||||
handler.Wait(1)
|
||||
handler2.Wait(1)
|
||||
@@ -273,8 +273,8 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
||||
|
||||
// Update the "foo" service with new endpoints
|
||||
endpointsUpdate1 = CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint77"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint77"},
|
||||
})
|
||||
handler.Wait(1)
|
||||
handler2.Wait(1)
|
||||
@@ -284,7 +284,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
||||
handler2.ValidateEndpoints(t, endpoints)
|
||||
|
||||
// Remove "bar" service
|
||||
endpointsUpdate2 = CreateEndpointsUpdate(REMOVE, api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar"}})
|
||||
endpointsUpdate2 = CreateEndpointsUpdate(REMOVE, api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar"}})
|
||||
handler.Wait(1)
|
||||
handler2.Wait(1)
|
||||
channelTwo <- endpointsUpdate2
|
||||
|
@@ -243,7 +243,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{{TypeMeta: api.TypeMeta{Name: parts[3]}}}}
|
||||
serviceUpdate := ServiceUpdate{Op: REMOVE, Services: []api.Service{{ObjectMeta: api.ObjectMeta{Name: parts[3]}}}}
|
||||
s.serviceChannel <- serviceUpdate
|
||||
return
|
||||
}
|
||||
|
@@ -163,8 +163,8 @@ func TestTCPProxy(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -181,8 +181,8 @@ func TestUDPProxy(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -208,8 +208,8 @@ func TestTCPProxyStop(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -236,8 +236,8 @@ func TestUDPProxyStop(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -264,8 +264,8 @@ func TestTCPProxyUpdateDelete(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -291,8 +291,8 @@ func TestUDPProxyUpdateDelete(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -318,8 +318,8 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -340,7 +340,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
|
||||
t.Fatalf(err.Error())
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "TCP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "TCP"},
|
||||
})
|
||||
testEchoTCP(t, "127.0.0.1", svcInfo.proxyPort)
|
||||
}
|
||||
@@ -349,8 +349,8 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -371,7 +371,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
|
||||
t.Fatalf(err.Error())
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "UDP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "UDP"},
|
||||
})
|
||||
testEchoUDP(t, "127.0.0.1", svcInfo.proxyPort)
|
||||
}
|
||||
@@ -380,8 +380,8 @@ func TestTCPProxyUpdatePort(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -406,7 +406,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
|
||||
t.Errorf("expected difference, got %d %d", newPort, svcInfo.proxyPort)
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "TCP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "TCP"},
|
||||
})
|
||||
if err := waitForClosedPortTCP(p, svcInfo.proxyPort); err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
@@ -425,8 +425,8 @@ func TestUDPProxyUpdatePort(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -451,7 +451,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
|
||||
t.Errorf("expected difference, got %d %d", newPort, svcInfo.proxyPort)
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "UDP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "UDP"},
|
||||
})
|
||||
if err := waitForClosedPortUDP(p, svcInfo.proxyPort); err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
|
@@ -86,8 +86,8 @@ func TestLoadBalanceWorksWithSingleEndpoint(t *testing.T) {
|
||||
}
|
||||
endpoints := make([]api.Endpoints, 1)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1:40"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1:40"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint1:40")
|
||||
@@ -104,8 +104,8 @@ func TestLoadBalanceWorksWithMultipleEndpoints(t *testing.T) {
|
||||
}
|
||||
endpoints := make([]api.Endpoints, 1)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:1")
|
||||
@@ -122,8 +122,8 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
|
||||
}
|
||||
endpoints := make([]api.Endpoints, 1)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:1")
|
||||
@@ -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{TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
endpoints[0] = api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}}
|
||||
endpoints[0] = api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{}}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
|
||||
endpoint, err = loadBalancer.NextEndpoint("foo", nil)
|
||||
@@ -159,12 +159,12 @@ func TestLoadBalanceWorksWithServiceRemoval(t *testing.T) {
|
||||
}
|
||||
endpoints := make([]api.Endpoints, 2)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
}
|
||||
endpoints[1] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint:4", "endpoint:5"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint:4", "endpoint:5"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:1")
|
||||
|
@@ -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.TypeMeta) {
|
||||
if !api.ValidNamespace(ctx, &controller.ObjectMeta) {
|
||||
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.TypeMeta) {
|
||||
if !api.ValidNamespace(ctx, &controller.ObjectMeta) {
|
||||
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 {
|
||||
|
@@ -51,7 +51,7 @@ func TestListControllersError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListEmptyControllerList(t *testing.T) {
|
||||
mockRegistry := registrytest.ControllerRegistry{nil, &api.ReplicationControllerList{TypeMeta: api.TypeMeta{ResourceVersion: "1"}}}
|
||||
mockRegistry := registrytest.ControllerRegistry{nil, &api.ReplicationControllerList{ListMeta: api.ListMeta{ResourceVersion: "1"}}}
|
||||
storage := REST{
|
||||
registry: &mockRegistry,
|
||||
}
|
||||
@@ -74,12 +74,12 @@ func TestListControllerList(t *testing.T) {
|
||||
Controllers: &api.ReplicationControllerList{
|
||||
Items: []api.ReplicationController{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "bar",
|
||||
},
|
||||
},
|
||||
@@ -113,7 +113,7 @@ func TestControllerDecode(t *testing.T) {
|
||||
registry: &mockRegistry,
|
||||
}
|
||||
controller := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
}
|
||||
@@ -134,8 +134,11 @@ func TestControllerDecode(t *testing.T) {
|
||||
|
||||
func TestControllerParsing(t *testing.T) {
|
||||
expectedController := api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "nginxController",
|
||||
Labels: map[string]string{
|
||||
"name": "nginx",
|
||||
},
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
@@ -163,9 +166,6 @@ func TestControllerParsing(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"name": "nginx",
|
||||
},
|
||||
}
|
||||
file, err := ioutil.TempFile("", "controller")
|
||||
fileName := file.Name()
|
||||
@@ -225,8 +225,10 @@ func TestCreateController(t *testing.T) {
|
||||
Pods: &api.PodList{
|
||||
Items: []api.Pod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Labels: map[string]string{"a": "b"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{"a": "b"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -237,7 +239,7 @@ func TestCreateController(t *testing.T) {
|
||||
pollPeriod: time.Millisecond * 1,
|
||||
}
|
||||
controller := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "test"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
ReplicaSelector: map[string]string{"a": "b"},
|
||||
@@ -270,13 +272,13 @@ func TestControllerStorageValidatesCreate(t *testing.T) {
|
||||
}
|
||||
failureCases := map[string]api.ReplicationController{
|
||||
"empty ID": {
|
||||
TypeMeta: api.TypeMeta{Name: ""},
|
||||
ObjectMeta: api.ObjectMeta{Name: ""},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: map[string]string{"bar": "baz"},
|
||||
},
|
||||
},
|
||||
"empty selector": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc"},
|
||||
DesiredState: api.ReplicationControllerState{},
|
||||
},
|
||||
}
|
||||
@@ -301,13 +303,13 @@ func TestControllerStorageValidatesUpdate(t *testing.T) {
|
||||
}
|
||||
failureCases := map[string]api.ReplicationController{
|
||||
"empty ID": {
|
||||
TypeMeta: api.TypeMeta{Name: ""},
|
||||
ObjectMeta: api.ObjectMeta{Name: ""},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: map[string]string{"bar": "baz"},
|
||||
},
|
||||
},
|
||||
"empty selector": {
|
||||
TypeMeta: api.TypeMeta{Name: "abc"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc"},
|
||||
DesiredState: api.ReplicationControllerState{},
|
||||
},
|
||||
}
|
||||
@@ -338,8 +340,8 @@ func TestFillCurrentState(t *testing.T) {
|
||||
fakeLister := fakePodLister{
|
||||
l: api.PodList{
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -368,7 +370,7 @@ func TestFillCurrentState(t *testing.T) {
|
||||
func TestCreateControllerWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
controller := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
@@ -386,7 +388,7 @@ func TestCreateControllerWithConflictingNamespace(t *testing.T) {
|
||||
func TestUpdateControllerWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
controller := &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
|
@@ -29,8 +29,8 @@ import (
|
||||
func TestGetEndpoints(t *testing.T) {
|
||||
registry := ®istrytest.ServiceRegistry{
|
||||
Endpoints: api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"127.0.0.1:9000"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"127.0.0.1:9000"},
|
||||
},
|
||||
}
|
||||
storage := NewREST(registry)
|
||||
@@ -59,7 +59,7 @@ func TestGetEndpointsMissingService(t *testing.T) {
|
||||
// returns empty endpoints
|
||||
registry.Err = nil
|
||||
registry.Service = &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "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{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "1"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "1"},
|
||||
Items: []api.Endpoints{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
}
|
||||
ctx := api.NewContext()
|
||||
|
@@ -87,8 +87,8 @@ func TestEtcdGetPodDifferentNamespace(t *testing.T) {
|
||||
key1, _ := makePodKey(ctx1, "foo")
|
||||
key2, _ := makePodKey(ctx2, "foo")
|
||||
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Pod{ObjectMeta: api.ObjectMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Pod{ObjectMeta: api.ObjectMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
|
||||
@@ -120,7 +120,7 @@ func TestEtcdGetPod(t *testing.T) {
|
||||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
key, _ := makePodKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
pod, err := registry.GetPod(ctx, "foo")
|
||||
if err != nil {
|
||||
@@ -163,7 +163,7 @@ func TestEtcdCreatePod(t *testing.T) {
|
||||
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(ctx, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
@@ -181,7 +181,7 @@ func TestEtcdCreatePod(t *testing.T) {
|
||||
}
|
||||
|
||||
// Suddenly, a wild scheduler appears:
|
||||
err = registry.ApplyBinding(ctx, &api.Binding{PodID: "foo", Host: "machine", TypeMeta: api.TypeMeta{Namespace: api.NamespaceDefault}})
|
||||
err = registry.ApplyBinding(ctx, &api.Binding{PodID: "foo", Host: "machine", ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault}})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -216,7 +216,7 @@ func TestEtcdCreatePodFailsWithoutNamespace(t *testing.T) {
|
||||
fakeClient.TestIndex = true
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(api.NewContext(), &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
@@ -242,14 +242,14 @@ func TestEtcdCreatePodAlreadyExisting(t *testing.T) {
|
||||
fakeClient.Data[key] = tools.EtcdResponseWithError{
|
||||
R: &etcd.Response{
|
||||
Node: &etcd.Node{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}),
|
||||
},
|
||||
},
|
||||
E: nil,
|
||||
}
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(ctx, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
})
|
||||
@@ -277,7 +277,7 @@ func TestEtcdCreatePodWithContainersError(t *testing.T) {
|
||||
}
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(ctx, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
})
|
||||
@@ -319,7 +319,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
|
||||
}
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(ctx, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
@@ -381,12 +381,12 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
|
||||
}
|
||||
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{
|
||||
Items: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreatePod(ctx, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
@@ -448,9 +448,12 @@ func TestEtcdUpdatePodNotFound(t *testing.T) {
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
podIn := api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
}
|
||||
err := registry.UpdatePod(ctx, &podIn)
|
||||
@@ -466,14 +469,17 @@ func TestEtcdUpdatePodNotScheduled(t *testing.T) {
|
||||
|
||||
key, _ := makePodKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}), 1)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
podIn := api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
}
|
||||
err := registry.UpdatePod(ctx, &podIn)
|
||||
@@ -498,7 +504,7 @@ func TestEtcdUpdatePodScheduled(t *testing.T) {
|
||||
|
||||
key, _ := makePodKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Host: "machine",
|
||||
Manifest: api.ContainerManifest{
|
||||
@@ -536,7 +542,13 @@ func TestEtcdUpdatePodScheduled(t *testing.T) {
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
podIn := api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
ID: "foo",
|
||||
@@ -547,9 +559,6 @@ func TestEtcdUpdatePodScheduled(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
}
|
||||
err := registry.UpdatePod(ctx, &podIn)
|
||||
if err != nil {
|
||||
@@ -584,12 +593,12 @@ func TestEtcdDeletePod(t *testing.T) {
|
||||
|
||||
key, _ := makePodKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}), 0)
|
||||
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{
|
||||
Items: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
},
|
||||
}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
@@ -620,13 +629,13 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
|
||||
fakeClient.TestIndex = true
|
||||
key, _ := makePodKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}), 0)
|
||||
fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{
|
||||
Items: []api.BoundPod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
@@ -706,13 +715,13 @@ func TestEtcdListPods(t *testing.T) {
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}),
|
||||
},
|
||||
@@ -783,10 +792,10 @@ func TestEtcdListControllers(t *testing.T) {
|
||||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "bar"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "bar"}}),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -814,8 +823,8 @@ func TestEtcdGetControllerDifferentNamespace(t *testing.T) {
|
||||
key1, _ := makeControllerKey(ctx1, "foo")
|
||||
key2, _ := makeControllerKey(ctx2, "foo")
|
||||
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
|
||||
@@ -847,7 +856,7 @@ func TestEtcdGetController(t *testing.T) {
|
||||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
key, _ := makeControllerKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
ctrl, err := registry.GetController(ctx, "foo")
|
||||
if err != nil {
|
||||
@@ -903,7 +912,7 @@ func TestEtcdCreateController(t *testing.T) {
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
key, _ := makeControllerKey(ctx, "foo")
|
||||
err := registry.CreateController(ctx, &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
})
|
||||
@@ -929,11 +938,11 @@ func TestEtcdCreateControllerAlreadyExisting(t *testing.T) {
|
||||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
key, _ := makeControllerKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateController(ctx, &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
})
|
||||
@@ -947,10 +956,10 @@ func TestEtcdUpdateController(t *testing.T) {
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
fakeClient.TestIndex = true
|
||||
key, _ := makeControllerKey(ctx, "foo")
|
||||
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.UpdateController(ctx, &api.ReplicationController{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
@@ -974,10 +983,10 @@ func TestEtcdListServices(t *testing.T) {
|
||||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "bar"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}}),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1000,7 +1009,7 @@ func TestEtcdCreateService(t *testing.T) {
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@@ -1027,10 +1036,10 @@ func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
|
||||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
key, _ := makeServiceKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if !errors.IsAlreadyExists(err) {
|
||||
t.Errorf("expected already exists err, got %#v", err)
|
||||
@@ -1047,8 +1056,8 @@ func TestEtcdGetServiceDifferentNamespace(t *testing.T) {
|
||||
key1, _ := makeServiceKey(ctx1, "foo")
|
||||
key2, _ := makeServiceKey(ctx2, "foo")
|
||||
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key1, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Namespace: "default", Name: "foo"}}), 0)
|
||||
fakeClient.Set(key2, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Namespace: "other", Name: "foo"}}), 0)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
|
||||
@@ -1080,7 +1089,7 @@ func TestEtcdGetService(t *testing.T) {
|
||||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
key, _ := makeServiceKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
service, err := registry.GetService(ctx, "foo")
|
||||
if err != nil {
|
||||
@@ -1136,12 +1145,15 @@ func TestEtcdUpdateService(t *testing.T) {
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
fakeClient.TestIndex = true
|
||||
key, _ := makeServiceKey(ctx, "foo")
|
||||
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
testService := api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)},
|
||||
Labels: map[string]string{
|
||||
"baz": "bar",
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10),
|
||||
Labels: map[string]string{
|
||||
"baz": "bar",
|
||||
},
|
||||
},
|
||||
Selector: map[string]string{
|
||||
"baz": "bar",
|
||||
@@ -1174,10 +1186,10 @@ func TestEtcdListEndpoints(t *testing.T) {
|
||||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar"}}),
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar"}}),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1200,8 +1212,8 @@ func TestEtcdGetEndpoints(t *testing.T) {
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
endpoints := &api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"127.0.0.1:34855"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"127.0.0.1:34855"},
|
||||
}
|
||||
|
||||
key, _ := makeServiceEndpointsKey(ctx, "foo")
|
||||
@@ -1223,8 +1235,8 @@ func TestEtcdUpdateEndpoints(t *testing.T) {
|
||||
fakeClient.TestIndex = true
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
endpoints := api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"baz", "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"baz", "bar"},
|
||||
}
|
||||
|
||||
key, _ := makeServiceEndpointsKey(ctx, "foo")
|
||||
@@ -1392,12 +1404,12 @@ func TestEtcdListMinions(t *testing.T) {
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
}),
|
||||
},
|
||||
},
|
||||
@@ -1421,7 +1433,7 @@ func TestEtcdCreateMinion(t *testing.T) {
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateMinion(ctx, &api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@@ -1446,7 +1458,7 @@ func TestEtcdCreateMinion(t *testing.T) {
|
||||
func TestEtcdGetMinion(t *testing.T) {
|
||||
ctx := api.NewContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
fakeClient.Set("/registry/minions/foo", runtime.EncodeOrDie(latest.Codec, &api.Minion{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
fakeClient.Set("/registry/minions/foo", runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
minion, err := registry.GetMinion(ctx, "foo")
|
||||
if err != nil {
|
||||
|
@@ -42,12 +42,12 @@ func NewTestEventEtcdRegistry(t *testing.T) (*tools.FakeEtcdClient, generic.Regi
|
||||
|
||||
func TestEventCreate(t *testing.T) {
|
||||
eventA := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
eventB := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
|
||||
nodeWithEventA := tools.EtcdResponseWithError{
|
||||
|
@@ -40,8 +40,8 @@ func NewTestREST() (testRegistry, *REST) {
|
||||
func TestRESTCreate(t *testing.T) {
|
||||
_, rest := NewTestREST()
|
||||
eventA := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
c, err := rest.Create(api.NewContext(), eventA)
|
||||
if err != nil {
|
||||
@@ -55,8 +55,8 @@ func TestRESTCreate(t *testing.T) {
|
||||
func TestRESTDelete(t *testing.T) {
|
||||
_, rest := NewTestREST()
|
||||
eventA := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
c, err := rest.Create(api.NewContext(), eventA)
|
||||
if err != nil {
|
||||
@@ -75,8 +75,8 @@ func TestRESTDelete(t *testing.T) {
|
||||
func TestRESTGet(t *testing.T) {
|
||||
_, rest := NewTestREST()
|
||||
eventA := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
c, err := rest.Create(api.NewContext(), eventA)
|
||||
if err != nil {
|
||||
@@ -131,8 +131,8 @@ func TestRESTgetAttrs(t *testing.T) {
|
||||
func TestRESTUpdate(t *testing.T) {
|
||||
_, rest := NewTestREST()
|
||||
eventA := &api.Event{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Reason: "forTesting",
|
||||
}
|
||||
c, err := rest.Create(api.NewContext(), eventA)
|
||||
if err != nil {
|
||||
|
@@ -72,11 +72,11 @@ func (EverythingMatcher) Matches(obj runtime.Object) (bool, error) {
|
||||
|
||||
func TestEtcdList(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
podB := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
|
||||
@@ -154,11 +154,11 @@ func TestEtcdList(t *testing.T) {
|
||||
|
||||
func TestEtcdCreate(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
podB := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine2"},
|
||||
}
|
||||
|
||||
@@ -217,11 +217,11 @@ func TestEtcdCreate(t *testing.T) {
|
||||
|
||||
func TestEtcdUpdate(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
podB := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
DesiredState: api.PodState{Host: "machine2"},
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ func TestEtcdUpdate(t *testing.T) {
|
||||
|
||||
func TestEtcdGet(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ func TestEtcdGet(t *testing.T) {
|
||||
|
||||
func TestEtcdDelete(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ func TestEtcdDelete(t *testing.T) {
|
||||
|
||||
func TestEtcdWatch(t *testing.T) {
|
||||
podA := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||
DesiredState: api.PodState{Host: "machine"},
|
||||
}
|
||||
respWithPodA := &etcd.Response{
|
||||
|
@@ -46,7 +46,7 @@ func TestBasicDelegation(t *testing.T) {
|
||||
t.Errorf("Expected %v, Got %v", mockMinionRegistry.Minions, list)
|
||||
}
|
||||
err = healthy.CreateMinion(ctx, &api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
@@ -106,7 +106,7 @@ func (rs *REST) Update(ctx api.Context, minion runtime.Object) (<-chan runtime.O
|
||||
}
|
||||
|
||||
func (rs *REST) toApiMinion(name string) *api.Minion {
|
||||
return &api.Minion{TypeMeta: api.TypeMeta{Name: name}}
|
||||
return &api.Minion{ObjectMeta: api.ObjectMeta{Name: name}}
|
||||
}
|
||||
|
||||
// ResourceLocation returns a URL to which one can send traffic for the specified minion.
|
||||
|
@@ -37,7 +37,7 @@ func TestMinionREST(t *testing.T) {
|
||||
t.Errorf("has unexpected object")
|
||||
}
|
||||
|
||||
c, err := ms.Create(ctx, &api.Minion{TypeMeta: api.TypeMeta{Name: "baz"}})
|
||||
c, err := ms.Create(ctx, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "baz"}})
|
||||
if err != nil {
|
||||
t.Errorf("insert failed")
|
||||
}
|
||||
@@ -72,9 +72,9 @@ func TestMinionREST(t *testing.T) {
|
||||
}
|
||||
expect := []api.Minion{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{Name: "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
||||
},
|
||||
}
|
||||
nodeList := list.(*api.MinionList)
|
||||
|
@@ -32,7 +32,7 @@ func TestMakeBoundPodNoServices(t *testing.T) {
|
||||
}
|
||||
|
||||
pod, err := factory.MakeBoundPod("machine", &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foobar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foobar"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -61,8 +61,8 @@ func TestMakeBoundPodServices(t *testing.T) {
|
||||
List: api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "test"},
|
||||
Port: 8080,
|
||||
ObjectMeta: api.ObjectMeta{Name: "test"},
|
||||
Port: 8080,
|
||||
ContainerPort: util.IntOrString{
|
||||
Kind: util.IntstrInt,
|
||||
IntVal: 900,
|
||||
@@ -137,8 +137,8 @@ func TestMakeBoundPodServicesExistingEnvVar(t *testing.T) {
|
||||
List: api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "test"},
|
||||
Port: 8080,
|
||||
ObjectMeta: api.ObjectMeta{Name: "test"},
|
||||
Port: 8080,
|
||||
ContainerPort: util.IntOrString{
|
||||
Kind: util.IntstrInt,
|
||||
IntVal: 900,
|
||||
|
@@ -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.TypeMeta) {
|
||||
if !api.ValidNamespace(ctx, &pod.ObjectMeta) {
|
||||
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.TypeMeta) {
|
||||
if !api.ValidNamespace(ctx, &pod.ObjectMeta) {
|
||||
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 {
|
||||
|
@@ -144,7 +144,7 @@ func TestListPodsError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListEmptyPodList(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(&api.PodList{TypeMeta: api.TypeMeta{ResourceVersion: "1"}})
|
||||
podRegistry := registrytest.NewPodRegistry(&api.PodList{ListMeta: api.ListMeta{ResourceVersion: "1"}})
|
||||
storage := REST{
|
||||
registry: podRegistry,
|
||||
}
|
||||
@@ -175,12 +175,12 @@ func TestListPodList(t *testing.T) {
|
||||
podRegistry.Pods = &api.PodList{
|
||||
Items: []api.Pod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "bar",
|
||||
},
|
||||
},
|
||||
@@ -214,18 +214,20 @@ func TestListPodListSelection(t *testing.T) {
|
||||
podRegistry.Pods = &api.PodList{
|
||||
Items: []api.Pod{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
DesiredState: api.PodState{Host: "barhost"},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{Name: "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
||||
DesiredState: api.PodState{Status: "bazstatus"},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{Name: "qux"},
|
||||
Labels: map[string]string{"label": "qux"},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "qux",
|
||||
Labels: map[string]string{"label": "qux"},
|
||||
},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{Name: "zot"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "zot"},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -298,7 +300,7 @@ func TestPodDecode(t *testing.T) {
|
||||
registry: podRegistry,
|
||||
}
|
||||
expected := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
}
|
||||
@@ -319,7 +321,7 @@ func TestPodDecode(t *testing.T) {
|
||||
|
||||
func TestGetPod(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
podRegistry.Pod = &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
storage := REST{
|
||||
registry: podRegistry,
|
||||
ipCache: ipCache{},
|
||||
@@ -340,7 +342,7 @@ func TestGetPod(t *testing.T) {
|
||||
func TestGetPodCloud(t *testing.T) {
|
||||
fakeCloud := &fake_cloud.FakeCloud{}
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}, CurrentState: api.PodState{Host: "machine"}}
|
||||
podRegistry.Pod = &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}, CurrentState: api.PodState{Host: "machine"}}
|
||||
|
||||
clock := &fakeClock{t: time.Now()}
|
||||
|
||||
@@ -386,7 +388,7 @@ func TestMakePodStatus(t *testing.T) {
|
||||
Minions: api.MinionList{
|
||||
Items: []api.Minion{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "machine"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "machine"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -561,7 +563,7 @@ func TestPodStorageValidatesUpdate(t *testing.T) {
|
||||
func TestCreatePod(t *testing.T) {
|
||||
podRegistry := registrytest.NewPodRegistry(nil)
|
||||
podRegistry.Pod = &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
CurrentState: api.PodState{
|
||||
Host: "machine",
|
||||
},
|
||||
@@ -576,7 +578,7 @@ func TestCreatePod(t *testing.T) {
|
||||
},
|
||||
}
|
||||
pod := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
DesiredState: desiredState,
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
@@ -656,7 +658,7 @@ func TestFillPodInfoNoData(t *testing.T) {
|
||||
func TestCreatePodWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
pod := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
@@ -674,7 +676,7 @@ func TestCreatePodWithConflictingNamespace(t *testing.T) {
|
||||
func TestUpdatePodWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
pod := &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
|
@@ -77,7 +77,7 @@ func (r *MinionRegistry) DeleteMinion(ctx api.Context, minionID string) error {
|
||||
var newList []api.Minion
|
||||
for _, node := range r.Minions.Items {
|
||||
if node.Name != minionID {
|
||||
newList = append(newList, api.Minion{TypeMeta: api.TypeMeta{Name: node.Name}})
|
||||
newList = append(newList, api.Minion{ObjectMeta: api.ObjectMeta{Name: node.Name}})
|
||||
}
|
||||
}
|
||||
r.Minions.Items = newList
|
||||
|
@@ -81,7 +81,7 @@ func reloadIPsFromStorage(ipa *ipAllocator, registry Registry) {
|
||||
|
||||
func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) {
|
||||
service := obj.(*api.Service)
|
||||
if !api.ValidNamespace(ctx, &service.TypeMeta) {
|
||||
if !api.ValidNamespace(ctx, &service.ObjectMeta) {
|
||||
return nil, errors.NewConflict("service", service.Namespace, fmt.Errorf("Service.Namespace does not match the provided context"))
|
||||
}
|
||||
if errs := validation.ValidateService(service); len(errs) > 0 {
|
||||
@@ -213,7 +213,7 @@ func GetServiceEnvironmentVariables(ctx api.Context, registry Registry, machine
|
||||
|
||||
func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Object, error) {
|
||||
service := obj.(*api.Service)
|
||||
if !api.ValidNamespace(ctx, &service.TypeMeta) {
|
||||
if !api.ValidNamespace(ctx, &service.ObjectMeta) {
|
||||
return nil, errors.NewConflict("service", service.Namespace, fmt.Errorf("Service.Namespace does not match the provided context"))
|
||||
}
|
||||
if errs := validation.ValidateService(service); len(errs) > 0 {
|
||||
|
@@ -45,9 +45,9 @@ func TestServiceRegistryCreate(t *testing.T) {
|
||||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
c, _ := storage.Create(ctx, svc)
|
||||
@@ -82,13 +82,13 @@ func TestServiceStorageValidatesCreate(t *testing.T) {
|
||||
storage := NewREST(registry, nil, nil, makeIPNet(t))
|
||||
failureCases := map[string]api.Service{
|
||||
"empty ID": {
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: ""},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: ""},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
},
|
||||
"empty selector": {
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{},
|
||||
},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
@@ -108,15 +108,15 @@ func TestServiceRegistryUpdate(t *testing.T) {
|
||||
ctx := api.NewDefaultContext()
|
||||
registry := registrytest.NewServiceRegistry()
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz1"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz1"},
|
||||
})
|
||||
storage := NewREST(registry, nil, nil, makeIPNet(t))
|
||||
c, err := storage.Update(ctx, &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz2"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz2"},
|
||||
})
|
||||
if c == nil {
|
||||
t.Errorf("Expected non-nil channel")
|
||||
@@ -138,21 +138,21 @@ func TestServiceStorageValidatesUpdate(t *testing.T) {
|
||||
ctx := api.NewDefaultContext()
|
||||
registry := registrytest.NewServiceRegistry()
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
})
|
||||
storage := NewREST(registry, nil, nil, makeIPNet(t))
|
||||
failureCases := map[string]api.Service{
|
||||
"empty ID": {
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: ""},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: ""},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
},
|
||||
"empty selector": {
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{},
|
||||
},
|
||||
}
|
||||
for _, failureCase := range failureCases {
|
||||
@@ -174,7 +174,7 @@ func TestServiceRegistryExternalService(t *testing.T) {
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
CreateExternalLoadBalancer: true,
|
||||
}
|
||||
@@ -201,7 +201,7 @@ func TestServiceRegistryExternalServiceError(t *testing.T) {
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
CreateExternalLoadBalancer: true,
|
||||
}
|
||||
@@ -223,8 +223,8 @@ func TestServiceRegistryDelete(t *testing.T) {
|
||||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
svc := &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
registry.CreateService(ctx, svc)
|
||||
c, _ := storage.Delete(ctx, svc.Name)
|
||||
@@ -244,7 +244,7 @@ func TestServiceRegistryDeleteExternal(t *testing.T) {
|
||||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
svc := &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
CreateExternalLoadBalancer: true,
|
||||
}
|
||||
@@ -265,25 +265,25 @@ func TestServiceRegistryMakeLinkVariables(t *testing.T) {
|
||||
registry.List = api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo-bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8080,
|
||||
Protocol: "TCP",
|
||||
PortalIP: "1.2.3.4",
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo-bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8080,
|
||||
Protocol: "TCP",
|
||||
PortalIP: "1.2.3.4",
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "abc-123"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8081,
|
||||
Protocol: "UDP",
|
||||
PortalIP: "5.6.7.8",
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc-123"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8081,
|
||||
Protocol: "UDP",
|
||||
PortalIP: "5.6.7.8",
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "q-u-u-x"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8082,
|
||||
Protocol: "",
|
||||
PortalIP: "9.8.7.6",
|
||||
ObjectMeta: api.ObjectMeta{Name: "q-u-u-x"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 8082,
|
||||
Protocol: "",
|
||||
PortalIP: "9.8.7.6",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -333,8 +333,8 @@ func TestServiceRegistryGet(t *testing.T) {
|
||||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
})
|
||||
storage.Get(ctx, "foo")
|
||||
if len(fakeCloud.Calls) != 0 {
|
||||
@@ -353,8 +353,8 @@ func TestServiceRegistryResourceLocation(t *testing.T) {
|
||||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
})
|
||||
redirector := apiserver.Redirector(storage)
|
||||
location, err := redirector.ResourceLocation(ctx, "foo")
|
||||
@@ -382,12 +382,12 @@ func TestServiceRegistryList(t *testing.T) {
|
||||
machines := []string{"foo", "bar", "baz"}
|
||||
storage := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
})
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "foo2"},
|
||||
Selector: map[string]string{"bar2": "baz2"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo2"},
|
||||
Selector: map[string]string{"bar2": "baz2"},
|
||||
})
|
||||
registry.List.ResourceVersion = "1"
|
||||
s, _ := storage.List(ctx, labels.Everything(), labels.Everything())
|
||||
@@ -416,9 +416,9 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
|
||||
rest := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
|
||||
svc1 := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
c1, _ := rest.Create(ctx, svc1)
|
||||
@@ -432,9 +432,9 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
|
||||
}
|
||||
|
||||
svc2 := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx = api.NewDefaultContext()
|
||||
c2, _ := rest.Create(ctx, svc2)
|
||||
@@ -455,9 +455,9 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
|
||||
rest := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
|
||||
svc1 := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
c1, _ := rest.Create(ctx, svc1)
|
||||
@@ -474,9 +474,9 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
|
||||
<-c
|
||||
|
||||
svc2 := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx = api.NewDefaultContext()
|
||||
c2, _ := rest.Create(ctx, svc2)
|
||||
@@ -497,9 +497,9 @@ func TestServiceRegistryIPUpdate(t *testing.T) {
|
||||
rest := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
c, _ := rest.Create(ctx, svc)
|
||||
@@ -543,7 +543,7 @@ func TestServiceRegistryIPExternalLoadBalancer(t *testing.T) {
|
||||
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
CreateExternalLoadBalancer: true,
|
||||
}
|
||||
@@ -569,17 +569,17 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
|
||||
rest1 := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
|
||||
svc := &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
ctx := api.NewDefaultContext()
|
||||
c, _ := rest1.Create(ctx, svc)
|
||||
<-c
|
||||
svc = &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
c, _ = rest1.Create(ctx, svc)
|
||||
<-c
|
||||
@@ -588,9 +588,9 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
|
||||
rest2 := NewREST(registry, fakeCloud, registrytest.NewMinionRegistry(machines, api.NodeResources{}), makeIPNet(t))
|
||||
|
||||
svc = &api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
Port: 6502,
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
}
|
||||
c, _ = rest2.Create(ctx, svc)
|
||||
created_svc := <-c
|
||||
@@ -603,7 +603,7 @@ func TestServiceRegistryIPReloadFromStorage(t *testing.T) {
|
||||
func TestCreateServiceWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
service := &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
@@ -621,7 +621,7 @@ func TestCreateServiceWithConflictingNamespace(t *testing.T) {
|
||||
func TestUpdateServiceWithConflictingNamespace(t *testing.T) {
|
||||
storage := REST{}
|
||||
service := &api.Service{
|
||||
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "test", Namespace: "not-default"},
|
||||
}
|
||||
|
||||
ctx := api.NewDefaultContext()
|
||||
|
@@ -29,9 +29,9 @@ import (
|
||||
func TestExtractList(t *testing.T) {
|
||||
pl := &api.PodList{
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "2"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "3"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "1"}},
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "2"}},
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "3"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "1"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "2"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "3"}},
|
||||
}
|
||||
err := runtime.SetList(pl, list)
|
||||
if err != nil {
|
||||
|
@@ -95,7 +95,7 @@ func TestGenericScheduler(t *testing.T) {
|
||||
predicates: []FitPredicate{matchesPredicate},
|
||||
prioritizer: EqualPriority,
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
pod: api.Pod{TypeMeta: api.TypeMeta{Name: "machine2"}},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Name: "machine2"}},
|
||||
expectedHost: "machine2",
|
||||
},
|
||||
{
|
||||
@@ -108,7 +108,7 @@ func TestGenericScheduler(t *testing.T) {
|
||||
predicates: []FitPredicate{matchesPredicate},
|
||||
prioritizer: numericPriority,
|
||||
nodes: []string{"3", "2", "1"},
|
||||
pod: api.Pod{TypeMeta: api.TypeMeta{Name: "2"}},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Name: "2"}},
|
||||
expectedHost: "2",
|
||||
},
|
||||
{
|
||||
|
@@ -27,7 +27,7 @@ import (
|
||||
|
||||
func makeMinion(node string, cpu, memory int) api.Minion {
|
||||
return api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: node},
|
||||
ObjectMeta: api.ObjectMeta{Name: node},
|
||||
NodeResources: api.NodeResources{
|
||||
Capacity: api.ResourceList{
|
||||
resources.CPU: util.NewIntOrStringFromInt(cpu),
|
||||
@@ -87,10 +87,10 @@ func TestLeastRequested(t *testing.T) {
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "no resources requested",
|
||||
pods: []api.Pod{
|
||||
{DesiredState: machine1State, Labels: labels2},
|
||||
{DesiredState: machine1State, Labels: labels1},
|
||||
{DesiredState: machine2State, Labels: labels1},
|
||||
{DesiredState: machine2State, Labels: labels1},
|
||||
{DesiredState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{DesiredState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{DesiredState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{DesiredState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@@ -51,47 +51,47 @@ func TestSpreadPriority(t *testing.T) {
|
||||
test: "nothing scheduled",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{{CurrentState: machine1State}},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "no labels",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pods: []api.Pod{{CurrentState: machine1State, Labels: labels2}},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}}},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "different labels",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{
|
||||
{CurrentState: machine1State, Labels: labels2},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 1}},
|
||||
test: "one label match",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{
|
||||
{CurrentState: machine1State, Labels: labels2},
|
||||
{CurrentState: machine1State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 1}, {"machine2", 1}},
|
||||
test: "two label matches on different machines",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{
|
||||
{CurrentState: machine1State, Labels: labels2},
|
||||
{CurrentState: machine1State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 1}, {"machine2", 2}},
|
||||
|
@@ -74,10 +74,9 @@ func (e *EndpointController) SyncServiceEndpoints() error {
|
||||
}
|
||||
currentEndpoints, err := e.client.GetEndpoints(nsCtx, service.Name)
|
||||
if err != nil {
|
||||
// TODO this is brittle as all get out, refactor the client libraries to return a structured error.
|
||||
if errors.IsNotFound(err) {
|
||||
currentEndpoints = &api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: service.Name,
|
||||
},
|
||||
}
|
||||
|
@@ -34,10 +34,8 @@ func newPodList(count int) api.PodList {
|
||||
pods := []api.Pod{}
|
||||
for i := 0; i < count; i++ {
|
||||
pods = append(pods, api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
Name: fmt.Sprintf("pod%d", i),
|
||||
APIVersion: testapi.Version(),
|
||||
},
|
||||
TypeMeta: api.TypeMeta{APIVersion: testapi.Version()},
|
||||
ObjectMeta: api.ObjectMeta{Name: fmt.Sprintf("pod%d", i)},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -181,7 +179,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
|
||||
serviceList := api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -192,7 +190,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
|
||||
serverResponse{http.StatusOK, newPodList(1)},
|
||||
serverResponse{http.StatusOK, serviceList},
|
||||
serverResponse{http.StatusOK, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
@@ -204,7 +202,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
data := runtime.EncodeOrDie(testapi.Codec(), &api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
@@ -217,7 +215,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
|
||||
serviceList := api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -228,7 +226,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
|
||||
serverResponse{http.StatusOK, newPodList(1)},
|
||||
serverResponse{http.StatusOK, serviceList},
|
||||
serverResponse{http.StatusOK, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
Endpoints: []string{"1.2.3.4:8080"},
|
||||
@@ -245,7 +243,7 @@ func TestSyncEndpointsItems(t *testing.T) {
|
||||
serviceList := api.ServiceList{
|
||||
Items: []api.Service{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Selector: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -262,7 +260,7 @@ func TestSyncEndpointsItems(t *testing.T) {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
data := runtime.EncodeOrDie(testapi.Codec(), &api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ResourceVersion: "",
|
||||
},
|
||||
Endpoints: []string{"1.2.3.4:8080"},
|
||||
|
@@ -37,8 +37,9 @@ type fakeClientGetSet struct {
|
||||
}
|
||||
|
||||
type TestResource struct {
|
||||
api.TypeMeta `json:",inline" yaml:",inline"`
|
||||
Value int `json:"value" yaml:"value,omitempty"`
|
||||
api.TypeMeta `json:",inline" yaml:",inline"`
|
||||
api.ObjectMeta `json:"metadata" yaml:"metadata"`
|
||||
Value int `json:"value" yaml:"value,omitempty"`
|
||||
}
|
||||
|
||||
func (*TestResource) IsAnAPIObject() {}
|
||||
@@ -74,15 +75,15 @@ func TestExtractToList(t *testing.T) {
|
||||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: `{"name":"foo"}`,
|
||||
Value: `{"id":"foo","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 1,
|
||||
},
|
||||
{
|
||||
Value: `{"name":"bar"}`,
|
||||
Value: `{"id":"bar","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 2,
|
||||
},
|
||||
{
|
||||
Value: `{"name":"baz"}`,
|
||||
Value: `{"id":"baz","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 3,
|
||||
},
|
||||
},
|
||||
@@ -90,11 +91,11 @@ func TestExtractToList(t *testing.T) {
|
||||
},
|
||||
}
|
||||
expect := api.PodList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "10"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "10"},
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "baz", ResourceVersion: "3"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "baz", ResourceVersion: "3"}},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -122,7 +123,7 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
|
||||
Dir: true,
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: `{"name":"foo"}`,
|
||||
Value: `{"id":"foo","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 1,
|
||||
},
|
||||
},
|
||||
@@ -132,7 +133,7 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
|
||||
Dir: true,
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: `{"name":"bar"}`,
|
||||
Value: `{"id":"bar","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 2,
|
||||
},
|
||||
},
|
||||
@@ -142,10 +143,10 @@ func TestExtractToListAcrossDirectories(t *testing.T) {
|
||||
},
|
||||
}
|
||||
expect := api.PodList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "10"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "10"},
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -168,15 +169,15 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
|
||||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: `{"name":"foo"}`,
|
||||
Value: `{"id":"foo","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 1,
|
||||
},
|
||||
{
|
||||
Value: `{"name":"bar"}`,
|
||||
Value: `{"id":"bar","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 2,
|
||||
},
|
||||
{
|
||||
Value: `{"name":"baz"}`,
|
||||
Value: `{"id":"baz","kind":"Pod","apiVersion":"v1beta1"}`,
|
||||
ModifiedIndex: 3,
|
||||
},
|
||||
{
|
||||
@@ -188,11 +189,11 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
|
||||
},
|
||||
}
|
||||
expect := api.PodList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "10"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "10"},
|
||||
Items: []api.Pod{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "baz", ResourceVersion: "3"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "baz", ResourceVersion: "3"}},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -209,7 +210,7 @@ func TestExtractToListExcludesDirectories(t *testing.T) {
|
||||
|
||||
func TestExtractObj(t *testing.T) {
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
expect := api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
expect := api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
fakeClient.Set("/some/key", util.EncodeJSON(expect), 0)
|
||||
helper := EtcdHelper{fakeClient, latest.Codec, versioner}
|
||||
var got api.Pod
|
||||
@@ -263,7 +264,7 @@ func TestExtractObjNotFoundErr(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateObj(t *testing.T) {
|
||||
obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
helper := EtcdHelper{fakeClient, latest.Codec, versioner}
|
||||
err := helper.CreateObj("/some/key", obj, 5)
|
||||
@@ -284,7 +285,7 @@ func TestCreateObj(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetObj(t *testing.T) {
|
||||
obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
helper := EtcdHelper{fakeClient, latest.Codec, versioner}
|
||||
err := helper.SetObj("/some/key", obj)
|
||||
@@ -303,7 +304,7 @@ func TestSetObj(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetObjWithVersion(t *testing.T) {
|
||||
obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo", ResourceVersion: "1"}}
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}}
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
fakeClient.TestIndex = true
|
||||
fakeClient.Data["/some/key"] = EtcdResponseWithError{
|
||||
@@ -332,7 +333,7 @@ func TestSetObjWithVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetObjWithoutResourceVersioner(t *testing.T) {
|
||||
obj := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
helper := EtcdHelper{fakeClient, latest.Codec, nil}
|
||||
err := helper.SetObj("/some/key", obj)
|
||||
@@ -357,7 +358,7 @@ func TestAtomicUpdate(t *testing.T) {
|
||||
|
||||
// Create a new node.
|
||||
fakeClient.ExpectNotFoundGet("/some/key")
|
||||
obj := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 1}
|
||||
obj := &TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: 1}
|
||||
err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
|
||||
return obj, nil
|
||||
})
|
||||
@@ -376,7 +377,7 @@ func TestAtomicUpdate(t *testing.T) {
|
||||
|
||||
// Update an existing node.
|
||||
callbackCalled := false
|
||||
objUpdate := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 2}
|
||||
objUpdate := &TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: 2}
|
||||
err = helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
|
||||
callbackCalled = true
|
||||
|
||||
@@ -411,7 +412,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
|
||||
|
||||
// Create a new node.
|
||||
fakeClient.ExpectNotFoundGet("/some/key")
|
||||
obj := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 1}
|
||||
obj := &TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: 1}
|
||||
err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
|
||||
return obj, nil
|
||||
})
|
||||
@@ -421,7 +422,7 @@ func TestAtomicUpdateNoChange(t *testing.T) {
|
||||
|
||||
// Update an existing node with the same data
|
||||
callbackCalled := false
|
||||
objUpdate := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: 1}
|
||||
objUpdate := &TestResource{ObjectMeta: api.ObjectMeta{Name: "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
|
||||
@@ -464,7 +465,7 @@ func TestAtomicUpdate_CreateCollision(t *testing.T) {
|
||||
}
|
||||
|
||||
currValue := in.(*TestResource).Value
|
||||
obj := &TestResource{TypeMeta: api.TypeMeta{Name: "foo"}, Value: currValue + 1}
|
||||
obj := &TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: currValue + 1}
|
||||
return obj, nil
|
||||
})
|
||||
if err != nil {
|
||||
|
@@ -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{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
podBar := &api.Pod{TypeMeta: api.TypeMeta{Name: "bar"}}
|
||||
podBaz := &api.Pod{TypeMeta: api.TypeMeta{Name: "baz"}}
|
||||
podFoo := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
podBar := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "bar"}}
|
||||
podBaz := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "baz"}}
|
||||
firstLetterIsB := func(obj runtime.Object) bool {
|
||||
return obj.(*api.Pod).Name[0] == 'b'
|
||||
}
|
||||
@@ -236,7 +236,7 @@ func TestWatch(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test normal case
|
||||
pod := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -308,12 +308,12 @@ func TestWatchEtcdState(t *testing.T) {
|
||||
{
|
||||
Action: "compareAndSwap",
|
||||
Node: &etcd.Node{
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
||||
CreatedIndex: 1,
|
||||
ModifiedIndex: 2,
|
||||
},
|
||||
PrevNode: &etcd.Node{
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{"127.0.0.1:9000"}})),
|
||||
CreatedIndex: 1,
|
||||
ModifiedIndex: 2,
|
||||
},
|
||||
PrevNode: &etcd.Node{
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}})),
|
||||
Value: string(runtime.EncodeOrDie(codec, &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "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{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
|
||||
fakeClient := NewFakeEtcdClient(t)
|
||||
fakeClient.Data["/some/key"] = EtcdResponseWithError{
|
||||
|
@@ -36,7 +36,7 @@ func TestDecoder(t *testing.T) {
|
||||
out, in := io.Pipe()
|
||||
decoder := NewDecoder(out, testapi.Codec())
|
||||
|
||||
expect := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
expect := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
encoder := json.NewEncoder(in)
|
||||
go func() {
|
||||
data, err := testapi.Codec().Encode(expect)
|
||||
|
@@ -37,17 +37,17 @@ func TestEncodeDecodeRoundTrip(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
watch.Added,
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
v1beta1.Codec,
|
||||
},
|
||||
{
|
||||
watch.Modified,
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
v1beta2.Codec,
|
||||
},
|
||||
{
|
||||
watch.Deleted,
|
||||
&api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
api.Codec,
|
||||
},
|
||||
}
|
||||
|
@@ -145,8 +145,8 @@ func TestPollMinions(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
minions: []api.Minion{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -179,7 +179,7 @@ func TestPollMinions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDefaultErrorFunc(t *testing.T) {
|
||||
testPod := &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
|
||||
testPod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
handler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: runtime.EncodeOrDie(latest.Codec, testPod),
|
||||
@@ -219,7 +219,7 @@ func TestStoreToMinionLister(t *testing.T) {
|
||||
store := cache.NewStore()
|
||||
ids := util.NewStringSet("foo", "bar", "baz")
|
||||
for id := range ids {
|
||||
store.Add(id, &api.Minion{TypeMeta: api.TypeMeta{Name: id}})
|
||||
store.Add(id, &api.Minion{ObjectMeta: api.ObjectMeta{Name: id}})
|
||||
}
|
||||
sml := storeToMinionLister{store}
|
||||
|
||||
@@ -241,8 +241,10 @@ func TestStoreToPodLister(t *testing.T) {
|
||||
ids := []string{"foo", "bar", "baz"}
|
||||
for _, id := range ids {
|
||||
store.Add(id, &api.Pod{
|
||||
TypeMeta: api.TypeMeta{Name: id},
|
||||
Labels: map[string]string{"name": id},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: id,
|
||||
Labels: map[string]string{"name": id},
|
||||
},
|
||||
})
|
||||
}
|
||||
spl := storeToPodLister{store}
|
||||
@@ -267,9 +269,9 @@ func TestStoreToPodLister(t *testing.T) {
|
||||
func TestMinionEnumerator(t *testing.T) {
|
||||
testList := &api.MinionList{
|
||||
Items: []api.Minion{
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "baz"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "foo"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "bar"}},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "baz"}},
|
||||
},
|
||||
}
|
||||
me := minionEnumerator{testList}
|
||||
|
@@ -73,9 +73,9 @@ func (s *Scheduler) scheduleOne() {
|
||||
return
|
||||
}
|
||||
b := &api.Binding{
|
||||
TypeMeta: api.TypeMeta{Namespace: pod.Namespace},
|
||||
PodID: pod.Name,
|
||||
Host: dest,
|
||||
ObjectMeta: api.ObjectMeta{Namespace: pod.Namespace},
|
||||
PodID: pod.Name,
|
||||
Host: dest,
|
||||
}
|
||||
if err := s.config.Binder.Bind(b); err != nil {
|
||||
record.Eventf(pod, "", string(api.PodWaiting), "failedScheduling", "Binding rejected: %v", err)
|
||||
|
@@ -34,7 +34,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{TypeMeta: api.TypeMeta{Name: id, SelfLink: testapi.SelfLink("pods", id)}}
|
||||
return &api.Pod{ObjectMeta: api.ObjectMeta{Name: id, SelfLink: testapi.SelfLink("pods", id)}}
|
||||
}
|
||||
|
||||
type mockScheduler struct {
|
||||
@@ -88,7 +88,7 @@ func TestScheduler(t *testing.T) {
|
||||
var gotBinding *api.Binding
|
||||
c := &Config{
|
||||
MinionLister: scheduler.FakeMinionLister(
|
||||
api.MinionList{Items: []api.Minion{{TypeMeta: api.TypeMeta{Name: "machine1"}}}},
|
||||
api.MinionList{Items: []api.Minion{{ObjectMeta: api.ObjectMeta{Name: "machine1"}}}},
|
||||
),
|
||||
Algorithm: item.algo,
|
||||
Binder: fakeBinder{func(b *api.Binding) error {
|
||||
|
@@ -95,7 +95,7 @@ func TestWatch(t *testing.T) {
|
||||
client := newEtcdClient()
|
||||
helper := tools.EtcdHelper{Client: client, Codec: latest.Codec, ResourceVersioner: tools.RuntimeVersionAdapter{latest.ResourceVersioner}}
|
||||
withEtcdKey(func(key string) {
|
||||
resp, err := client.Set(key, runtime.EncodeOrDie(v1beta1.Codec, &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}), 0)
|
||||
resp, err := client.Set(key, runtime.EncodeOrDie(v1beta1.Codec, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user