From 0a4d4b43f6b3611b30381c63f837ac05d6d50561 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Fri, 3 Oct 2014 18:31:23 -0400 Subject: [PATCH 1/2] Move IsAnAPIObject() declarations to register.go * Add Namespace, UID, Annotations to internal/v1beta1/v1beta2 * Update v1beta3 with minor consistency tweaks --- pkg/api/types.go | 7 +++ pkg/api/v1beta1/register.go | 36 ++++++++--- pkg/api/v1beta1/types.go | 43 +++---------- pkg/api/v1beta2/register.go | 36 ++++++++--- pkg/api/v1beta2/types.go | 41 +++---------- pkg/api/v1beta3/doc.go | 18 ++++++ pkg/api/v1beta3/register.go | 73 ++++++++++++++++++++++ pkg/api/v1beta3/types.go | 119 ++++++++++++++++++++++-------------- 8 files changed, 240 insertions(+), 133 deletions(-) create mode 100644 pkg/api/v1beta3/doc.go create mode 100644 pkg/api/v1beta3/register.go diff --git a/pkg/api/types.go b/pkg/api/types.go index e296cc6a71c..c1fe4eec4b0 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -253,6 +253,12 @@ type TypeMeta struct { ResourceVersion uint64 `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 ( @@ -665,6 +671,7 @@ func (*ServerOpList) IsAnAPIObject() {} // ObjectReference contains enough information to let you inspect or modify the referred object. type ObjectReference struct { Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` UID string `json:"uid,omitempty" yaml:"uid,omitempty"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` diff --git a/pkg/api/v1beta1/register.go b/pkg/api/v1beta1/register.go index 4d60afbbcdf..acfeec50131 100644 --- a/pkg/api/v1beta1/register.go +++ b/pkg/api/v1beta1/register.go @@ -26,22 +26,40 @@ var Codec = runtime.CodecFor(api.Scheme, "v1beta1") func init() { api.Scheme.AddKnownTypes("v1beta1", - &PodList{}, &Pod{}, - &ReplicationControllerList{}, + &PodList{}, &ReplicationController{}, - &ServiceList{}, + &ReplicationControllerList{}, &Service{}, - &MinionList{}, - &Minion{}, - &Status{}, - &ServerOpList{}, - &ServerOp{}, - &ContainerManifestList{}, + &ServiceList{}, &Endpoints{}, &EndpointsList{}, + &Minion{}, + &MinionList{}, &Binding{}, + &Status{}, + &ServerOp{}, + &ServerOpList{}, &Event{}, &EventList{}, + &ContainerManifestList{}, ) } + +func (*Pod) IsAnAPIObject() {} +func (*PodList) IsAnAPIObject() {} +func (*ReplicationController) IsAnAPIObject() {} +func (*ReplicationControllerList) IsAnAPIObject() {} +func (*Service) IsAnAPIObject() {} +func (*ServiceList) IsAnAPIObject() {} +func (*Endpoints) IsAnAPIObject() {} +func (*EndpointsList) IsAnAPIObject() {} +func (*Minion) IsAnAPIObject() {} +func (*MinionList) IsAnAPIObject() {} +func (*Binding) IsAnAPIObject() {} +func (*Status) IsAnAPIObject() {} +func (*ServerOp) IsAnAPIObject() {} +func (*ServerOpList) IsAnAPIObject() {} +func (*Event) IsAnAPIObject() {} +func (*EventList) IsAnAPIObject() {} +func (*ContainerManifestList) IsAnAPIObject() {} diff --git a/pkg/api/v1beta1/types.go b/pkg/api/v1beta1/types.go index 30bb11081da..6548303103e 100644 --- a/pkg/api/v1beta1/types.go +++ b/pkg/api/v1beta1/types.go @@ -69,8 +69,6 @@ type ContainerManifestList struct { Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"` } -func (*ContainerManifestList) IsAnAPIObject() {} - // 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 @@ -259,14 +257,18 @@ type Lifecycle struct { type TypeMeta struct { Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` ID string `json:"id,omitempty" yaml:"id,omitempty"` + UID string `json:"uid,omitempty" yaml:"uid,omitempty"` CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"` SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"` ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` Namespace string `json:"namespace",omitempty" yaml:"namespace,omitempty"` -} -func (*TypeMeta) IsAnAPIObject() {} + // 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"` +} // PodStatus represents a status of a pod. type PodStatus string @@ -363,8 +365,6 @@ type PodList struct { Items []Pod `json:"items" yaml:"items,omitempty"` } -func (*PodList) IsAnAPIObject() {} - // 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"` @@ -373,8 +373,6 @@ type Pod struct { CurrentState PodState `json:"currentState,omitempty" yaml:"currentState,omitempty"` } -func (*Pod) IsAnAPIObject() {} - // ReplicationControllerState is the state of a replication controller, either input (create, update) or as output (list, get). type ReplicationControllerState struct { Replicas int `json:"replicas" yaml:"replicas"` @@ -388,8 +386,6 @@ type ReplicationControllerList struct { Items []ReplicationController `json:"items,omitempty" yaml:"items,omitempty"` } -func (*ReplicationControllerList) IsAnAPIObject() {} - // ReplicationController represents the configuration of a replication controller. type ReplicationController struct { TypeMeta `json:",inline" yaml:",inline"` @@ -398,8 +394,6 @@ type ReplicationController struct { Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` } -func (*ReplicationController) IsAnAPIObject() {} - // PodTemplate holds the information used for creating pods. type PodTemplate struct { DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"` @@ -412,8 +406,6 @@ type ServiceList struct { Items []Service `json:"items" yaml:"items"` } -func (*ServiceList) IsAnAPIObject() {} - // 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. @@ -437,8 +429,6 @@ type Service struct { ContainerPort util.IntOrString `json:"containerPort,omitempty" yaml:"containerPort,omitempty"` } -func (*Service) IsAnAPIObject() {} - // Endpoints is a collection of endpoints that implement the actual service, for example: // Name: "mysql", Endpoints: ["10.10.1.1:1909", "10.10.2.2:8834"] type Endpoints struct { @@ -446,16 +436,12 @@ type Endpoints struct { Endpoints []string `json:"endpoints,omitempty" yaml:"endpoints,omitempty"` } -func (*Endpoints) IsAnAPIObject() {} - // EndpointsList is a list of endpoints. type EndpointsList struct { TypeMeta `json:",inline" yaml:",inline"` Items []Endpoints `json:"items,omitempty" yaml:"items,omitempty"` } -func (*EndpointsList) IsAnAPIObject() {} - // NodeResources represents resources on a Kubernetes system node // see https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/resources.md for more details. type NodeResources struct { @@ -477,8 +463,6 @@ type Minion struct { NodeResources NodeResources `json:"resources,omitempty" yaml:"resources,omitempty"` } -func (*Minion) IsAnAPIObject() {} - // MinionList is a list of minions. type MinionList struct { TypeMeta `json:",inline" yaml:",inline"` @@ -488,8 +472,6 @@ type MinionList struct { Items []Minion `json:"items,omitempty" yaml:"items,omitempty"` } -func (*MinionList) IsAnAPIObject() {} - // Binding is written by a scheduler to cause a pod to be bound to a host. type Binding struct { TypeMeta `json:",inline" yaml:",inline"` @@ -497,8 +479,6 @@ type Binding struct { Host string `json:"host" yaml:"host"` } -func (*Binding) IsAnAPIObject() {} - // 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. @@ -522,8 +502,6 @@ type Status struct { Code int `json:"code,omitempty" yaml:"code,omitempty"` } -func (*Status) IsAnAPIObject() {} - // StatusDetails is a set of additional properties that MAY be set by the // server to provide additional information about a response. The Reason // field of a Status object defines what attributes will be set. Clients @@ -647,19 +625,16 @@ type ServerOp struct { TypeMeta `yaml:",inline" json:",inline"` } -func (*ServerOp) IsAnAPIObject() {} - // 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"` } -func (*ServerOpList) IsAnAPIObject() {} - // ObjectReference contains enough information to let you inspect or modify the referred object. type ObjectReference struct { Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` UID string `json:"uid,omitempty" yaml:"uid,omitempty"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` @@ -707,12 +682,8 @@ type Event struct { Source string `json:"source,omitempty" yaml:"source,omitempty"` } -func (*Event) IsAnAPIObject() {} - // EventList is a list of events. type EventList struct { TypeMeta `yaml:",inline" json:",inline"` Items []Event `yaml:"items,omitempty" json:"items,omitempty"` } - -func (*EventList) IsAnAPIObject() {} diff --git a/pkg/api/v1beta2/register.go b/pkg/api/v1beta2/register.go index 0e5de823b16..514c5d0b3a1 100644 --- a/pkg/api/v1beta2/register.go +++ b/pkg/api/v1beta2/register.go @@ -26,22 +26,40 @@ var Codec = runtime.CodecFor(api.Scheme, "v1beta2") func init() { api.Scheme.AddKnownTypes("v1beta2", - &PodList{}, &Pod{}, - &ReplicationControllerList{}, + &PodList{}, &ReplicationController{}, - &ServiceList{}, + &ReplicationControllerList{}, &Service{}, - &MinionList{}, - &Minion{}, - &Status{}, - &ServerOpList{}, - &ServerOp{}, - &ContainerManifestList{}, + &ServiceList{}, &Endpoints{}, &EndpointsList{}, + &Minion{}, + &MinionList{}, &Binding{}, + &Status{}, + &ServerOp{}, + &ServerOpList{}, &Event{}, &EventList{}, + &ContainerManifestList{}, ) } + +func (*Pod) IsAnAPIObject() {} +func (*PodList) IsAnAPIObject() {} +func (*ReplicationController) IsAnAPIObject() {} +func (*ReplicationControllerList) IsAnAPIObject() {} +func (*Service) IsAnAPIObject() {} +func (*ServiceList) IsAnAPIObject() {} +func (*Endpoints) IsAnAPIObject() {} +func (*EndpointsList) IsAnAPIObject() {} +func (*Minion) IsAnAPIObject() {} +func (*MinionList) IsAnAPIObject() {} +func (*Binding) IsAnAPIObject() {} +func (*Status) IsAnAPIObject() {} +func (*ServerOp) IsAnAPIObject() {} +func (*ServerOpList) IsAnAPIObject() {} +func (*Event) IsAnAPIObject() {} +func (*EventList) IsAnAPIObject() {} +func (*ContainerManifestList) IsAnAPIObject() {} diff --git a/pkg/api/v1beta2/types.go b/pkg/api/v1beta2/types.go index f011840b77e..1bb3e8e737d 100644 --- a/pkg/api/v1beta2/types.go +++ b/pkg/api/v1beta2/types.go @@ -69,8 +69,6 @@ type ContainerManifestList struct { Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"` } -func (*ContainerManifestList) IsAnAPIObject() {} - // 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 @@ -257,11 +255,17 @@ type Lifecycle struct { type TypeMeta struct { Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` ID string `json:"id,omitempty" yaml:"id,omitempty"` + UID string `json:"uid,omitempty" yaml:"uid,omitempty"` CreationTimestamp util.Time `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"` SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"` ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` Namespace string `json:"namespace",omitempty" yaml:"namespace,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"` } // PodStatus represents a status of a pod. @@ -359,8 +363,6 @@ type PodList struct { Items []Pod `json:"items" yaml:"items,omitempty"` } -func (*PodList) IsAnAPIObject() {} - // 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"` @@ -369,8 +371,6 @@ type Pod struct { CurrentState PodState `json:"currentState,omitempty" yaml:"currentState,omitempty"` } -func (*Pod) IsAnAPIObject() {} - // ReplicationControllerState is the state of a replication controller, either input (create, update) or as output (list, get). type ReplicationControllerState struct { Replicas int `json:"replicas" yaml:"replicas"` @@ -384,8 +384,6 @@ type ReplicationControllerList struct { Items []ReplicationController `json:"items,omitempty" yaml:"items,omitempty"` } -func (*ReplicationControllerList) IsAnAPIObject() {} - // ReplicationController represents the configuration of a replication controller. type ReplicationController struct { TypeMeta `json:",inline" yaml:",inline"` @@ -394,8 +392,6 @@ type ReplicationController struct { Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` } -func (*ReplicationController) IsAnAPIObject() {} - // PodTemplate holds the information used for creating pods. type PodTemplate struct { DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"` @@ -408,8 +404,6 @@ type ServiceList struct { Items []Service `json:"items" yaml:"items"` } -func (*ServiceList) IsAnAPIObject() {} - // 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. @@ -433,8 +427,6 @@ type Service struct { ContainerPort util.IntOrString `json:"containerPort,omitempty" yaml:"containerPort,omitempty"` } -func (*Service) IsAnAPIObject() {} - // Endpoints is a collection of endpoints that implement the actual service, for example: // Name: "mysql", Endpoints: ["10.10.1.1:1909", "10.10.2.2:8834"] type Endpoints struct { @@ -442,16 +434,12 @@ type Endpoints struct { Endpoints []string `json:"endpoints,omitempty" yaml:"endpoints,omitempty"` } -func (*Endpoints) IsAnAPIObject() {} - // EndpointsList is a list of endpoints. type EndpointsList struct { TypeMeta `json:",inline" yaml:",inline"` Items []Endpoints `json:"items,omitempty" yaml:"items,omitempty"` } -func (*EndpointsList) IsAnAPIObject() {} - // NodeResources represents resources on a Kubernetes system node // see https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/resources.md for more details. type NodeResources struct { @@ -473,8 +461,6 @@ type Minion struct { NodeResources NodeResources `json:"resources,omitempty" yaml:"resources,omitempty"` } -func (*Minion) IsAnAPIObject() {} - // MinionList is a list of minions. type MinionList struct { TypeMeta `json:",inline" yaml:",inline"` @@ -484,8 +470,6 @@ type MinionList struct { Items []Minion `json:"items,omitempty" yaml:"items,omitempty"` } -func (*MinionList) IsAnAPIObject() {} - // Binding is written by a scheduler to cause a pod to be bound to a host. type Binding struct { TypeMeta `json:",inline" yaml:",inline"` @@ -493,8 +477,6 @@ type Binding struct { Host string `json:"host" yaml:"host"` } -func (*Binding) IsAnAPIObject() {} - // 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. @@ -518,8 +500,6 @@ type Status struct { Code int `json:"code,omitempty" yaml:"code,omitempty"` } -func (*Status) IsAnAPIObject() {} - // StatusDetails is a set of additional properties that MAY be set by the // server to provide additional information about a response. The Reason // field of a Status object defines what attributes will be set. Clients @@ -656,19 +636,16 @@ type ServerOp struct { TypeMeta `yaml:",inline" json:",inline"` } -func (*ServerOp) IsAnAPIObject() {} - // 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"` } -func (*ServerOpList) IsAnAPIObject() {} - // ObjectReference contains enough information to let you inspect or modify the referred object. type ObjectReference struct { Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` UID string `json:"uid,omitempty" yaml:"uid,omitempty"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` @@ -716,12 +693,8 @@ type Event struct { Source string `json:"source,omitempty" yaml:"source,omitempty"` } -func (*Event) IsAnAPIObject() {} - // EventList is a list of events. type EventList struct { TypeMeta `yaml:",inline" json:",inline"` Items []Event `yaml:"items,omitempty" json:"items,omitempty"` } - -func (*EventList) IsAnAPIObject() {} diff --git a/pkg/api/v1beta3/doc.go b/pkg/api/v1beta3/doc.go new file mode 100644 index 00000000000..b110b4453bc --- /dev/null +++ b/pkg/api/v1beta3/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1beta3 is the v1beta3 version of the API. +package v1beta3 diff --git a/pkg/api/v1beta3/register.go b/pkg/api/v1beta3/register.go new file mode 100644 index 00000000000..c5dbecb512d --- /dev/null +++ b/pkg/api/v1beta3/register.go @@ -0,0 +1,73 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta3 + +import ( + "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" +) + +// Codec encodes internal objects to the v1beta3 scheme +var Codec = runtime.CodecFor(api.Scheme, "v1beta3") + +func init() { + api.Scheme.AddKnownTypes("v1beta3", + &Pod{}, + &PodList{}, + &PodTemplate{}, + &PodTemplateList{}, + &BoundPod{}, + &BoundPods{}, + &ReplicationController{}, + &ReplicationControllerList{}, + &Service{}, + &ServiceList{}, + &Endpoints{}, + &EndpointsList{}, + &Node{}, + &NodeList{}, + &Binding{}, + &Status{}, + &Operation{}, + &OperationList{}, + &Event{}, + &EventList{}, + &ContainerManifestList{}, + ) +} + +func (*Pod) IsAnAPIObject() {} +func (*PodList) IsAnAPIObject() {} +func (*PodTemplate) IsAnAPIObject() {} +func (*PodTemplateList) IsAnAPIObject() {} +func (*BoundPod) IsAnAPIObject() {} +func (*BoundPods) IsAnAPIObject() {} +func (*ReplicationController) IsAnAPIObject() {} +func (*ReplicationControllerList) IsAnAPIObject() {} +func (*Service) IsAnAPIObject() {} +func (*ServiceList) IsAnAPIObject() {} +func (*Endpoints) IsAnAPIObject() {} +func (*EndpointsList) IsAnAPIObject() {} +func (*Node) IsAnAPIObject() {} +func (*NodeList) IsAnAPIObject() {} +func (*Binding) IsAnAPIObject() {} +func (*Status) IsAnAPIObject() {} +func (*Operation) IsAnAPIObject() {} +func (*OperationList) IsAnAPIObject() {} +func (*Event) IsAnAPIObject() {} +func (*EventList) IsAnAPIObject() {} +func (*ContainerManifestList) IsAnAPIObject() {} diff --git a/pkg/api/v1beta3/types.go b/pkg/api/v1beta3/types.go index 4b8ac2c653d..7d59fc90a73 100644 --- a/pkg/api/v1beta3/types.go +++ b/pkg/api/v1beta3/types.go @@ -62,7 +62,8 @@ type TypeMeta struct { // ListMeta describes metadata that synthetic resources must have, including lists and // various status objects. type ListMeta struct { - // TODO: SelfLink + // 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 @@ -86,7 +87,8 @@ type ObjectMeta struct { // those objects will be empty. Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` - // TODO: SelfLink + // 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 @@ -114,6 +116,44 @@ type ObjectMeta struct { 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 = "" +) + +// ContainerManifest corresponds to the Container Manifest format, documented at: +// https://developers.google.com/compute/docs/containers/container_vms#container_manifest +// This is used as the representation of Kubernetes workloads. +// DEPRECATED: Exists to allow backwards compatible storage for clients accessing etcd +// directly. +type ContainerManifest struct { + // Required: This must be a supported version string, such as "v1beta1". + Version string `json:"version" yaml:"version"` + // Required: This must be a DNS_SUBDOMAIN. + // TODO: ID on Manifest is deprecated and will be removed in the future. + ID string `json:"id" yaml:"id"` + // TODO: UUID on Manifest is deprecated in the future once we are done + // with the API refactoring. It is required for now to determine the instance + // of a Pod. + UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + Volumes []Volume `json:"volumes" yaml:"volumes"` + Containers []Container `json:"containers" yaml:"containers"` + RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" yaml:"restartPolicy,omitempty"` +} + +// ContainerManifestList is used to communicate container manifests to kubelet. +// DEPRECATED: Exists to allow backwards compatible storage for clients accessing etcd +// directly. +type ContainerManifestList struct { + TypeMeta `json:",inline" yaml:",inline"` + // ID is the legacy field representing Name + ID string `json:"id,omitempty" yaml:"id,omitempty"` + + Items []ContainerManifest `json:"items,omitempty" yaml:"items,omitempty"` +} + // 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 @@ -215,7 +255,7 @@ type ExecAction struct { // LivenessProbe describes how to probe a container for liveness. // TODO: pass structured data to the actions, and document that data here. type LivenessProbe struct { - // Type of liveness probe. Current legal values "HTTP", "TCP" + // Type of liveness probe. Current legal values "HTTP", "TCP", "Exec" Type string `json:"type,omitempty" yaml:"type,omitempty"` // HTTPGetProbe parameters, required if Type == 'HTTP' HTTPGet *HTTPGetAction `json:"httpGet,omitempty" yaml:"httpGet,omitempty"` @@ -344,7 +384,6 @@ type ContainerStatus struct { } // PodInfo contains one entry for every container with available info. -// TODO(dchen1107): Replace docker.Container below with ContainerStatus defined above. type PodInfo map[string]ContainerStatus type RestartPolicyAlways struct{} @@ -391,14 +430,6 @@ type PodStatus struct { Info PodInfo `json:"info,omitempty" yaml:"info,omitempty"` } -// PodList is a list of Pods. -type PodList struct { - TypeMeta `json:",inline" yaml:",inline"` - Metadata ListMeta `json:"metadata,inline" yaml:"metadata,inline"` - - Items []Pod `json:"items" yaml:"items"` -} - // Pod is a collection of containers that can run on a host. This resource is created // by clients and scheduled onto hosts. BoundPod represents the state of this resource // to hosts. @@ -414,6 +445,14 @@ type Pod struct { Status PodStatus `json:"status,omitempty" yaml:"status,omitempty"` } +// PodList is a list of Pods. +type PodList struct { + TypeMeta `json:",inline" yaml:",inline"` + Metadata ListMeta `json:"metadata" yaml:"metadata"` + + Items []Pod `json:"items" yaml:"items"` +} + // PodTemplateSpec describes the data a pod should have when created from a template type PodTemplateSpec struct { // Metadata of the pods created from this template. @@ -432,10 +471,19 @@ type PodTemplate struct { Spec PodTemplateSpec `json:"spec,omitempty" yaml:"spec,omitempty"` } +// PodTemplateList is a list of PodTemplates. +type PodTemplateList struct { + TypeMeta `json:",inline" yaml:",inline"` + Metadata ListMeta `json:"metadata" yaml:"metadata"` + + Items []PodTemplate `json:"items" yaml:"items"` +} + // BoundPod is a collection of containers that should be run on a host. A BoundPod // 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"` Metadata ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"` // Spec defines the behavior of a pod. @@ -491,7 +539,7 @@ type ReplicationController struct { // ReplicationControllerList is a collection of replication controllers. type ReplicationControllerList struct { TypeMeta `json:",inline" yaml:",inline"` - Metadata ListMeta `json:"metadata,inline" yaml:"metadata,inline"` + Metadata ListMeta `json:"metadata" yaml:"metadata"` Items []ReplicationController `json:"items" yaml:"items"` } @@ -537,7 +585,7 @@ type Service struct { // ServiceList holds a list of services. type ServiceList struct { TypeMeta `json:",inline" yaml:",inline"` - Metadata ListMeta `json:"metadata,inline" yaml:"metadata,inline"` + Metadata ListMeta `json:"metadata" yaml:"metadata"` Items []Service `json:"items" yaml:"items"` } @@ -546,7 +594,7 @@ type ServiceList struct { // Name: "mysql", Endpoints: ["10.10.1.1:1909", "10.10.2.2:8834"] type Endpoints struct { TypeMeta `json:",inline" yaml:",inline"` - Metadata ObjectMeta `json:"metadata,inline" yaml:"metadata,inline"` + Metadata ObjectMeta `json:"metadata" yaml:"metadata"` // Endpoints is the list of host ports that satisfy the service selector Endpoints []string `json:"endpoints" yaml:"endpoints"` @@ -555,7 +603,7 @@ type Endpoints struct { // EndpointsList is a list of endpoints. type EndpointsList struct { TypeMeta `json:",inline" yaml:",inline"` - Metadata ListMeta `json:"metadata,inline" yaml:"metadata,inline"` + Metadata ListMeta `json:"metadata" yaml:"metadata"` Items []Endpoints `json:"items" yaml:"items"` } @@ -598,7 +646,7 @@ type Node struct { // NodeList is a list of minions. type NodeList struct { TypeMeta `json:",inline" yaml:",inline"` - Metadata ListMeta `json:"metadata,inline" yaml:"metadata,inline"` + Metadata ListMeta `json:"metadata" yaml:"metadata"` Items []Node `json:"items" yaml:"items"` } @@ -618,7 +666,7 @@ type Binding struct { // Status is a return value for calls that don't return other objects. type Status struct { TypeMeta `json:",inline" yaml:",inline"` - Metadata ListMeta `json:"metadata,inline" yaml:"metadata,inline"` + Metadata ListMeta `json:"metadata" yaml:"metadata"` // One of: "Success", "Failure", "Working" (for operations not yet completed) Status string `json:"status,omitempty" yaml:"status,omitempty"` @@ -774,13 +822,13 @@ const ( // clients to retrieve the final result of the operation at a later time. type Operation struct { TypeMeta `json:",inline" yaml:",inline"` - Metadata ObjectMeta `json:"metadata,inline" yaml:"metadata,inline"` + Metadata ObjectMeta `json:"metadata" yaml:"metadata"` } // OperationList is a list of operations, as delivered to API clients. type OperationList struct { TypeMeta `json:",inline" yaml:",inline"` - Metadata ListMeta `json:"metadata,inline" yaml:"metadata,inline"` + Metadata ListMeta `json:"metadata" yaml:"metadata"` Items []Operation `json:"items" yaml:"items"` } @@ -788,10 +836,11 @@ type OperationList struct { // ObjectReference contains enough information to let you inspect or modify the referred object. type ObjectReference struct { Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` UID string `json:"uid,omitempty" yaml:"uid,omitempty"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` - ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"` + ResourceVersion string `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"` // Optional. If referring to a piece of an object instead of an entire object, this string // should contain a valid field access statement. For example, @@ -807,7 +856,7 @@ type ObjectReference struct { // TODO: Decide whether to store these separately or with the object they apply to. type Event struct { TypeMeta `json:",inline" yaml:",inline"` - Metadata ObjectMeta `json:"metadata,inline" yaml:"metadata,inline"` + Metadata ObjectMeta `json:"metadata" yaml:"metadata"` // Required. The object that this event is about. InvolvedObject ObjectReference `json:"involvedObject,omitempty" yaml:"involvedObject,omitempty"` @@ -839,27 +888,7 @@ type Event struct { // EventList is a list of events. type EventList struct { TypeMeta `json:",inline" yaml:",inline"` - Metadata ListMeta `json:"metadata,inline" yaml:"metadata,inline"` - Items []Event `json:"items" yaml:"items"` -} + Metadata ListMeta `json:"metadata" yaml:"metadata"` -// TODO: for readability -func (*Pod) IsAnAPIObject() {} -func (*PodList) IsAnAPIObject() {} -func (*PodTemplate) IsAnAPIObject() {} -func (*BoundPod) IsAnAPIObject() {} -func (*BoundPods) IsAnAPIObject() {} -func (*ReplicationController) IsAnAPIObject() {} -func (*ReplicationControllerList) IsAnAPIObject() {} -func (*Service) IsAnAPIObject() {} -func (*ServiceList) IsAnAPIObject() {} -func (*Endpoints) IsAnAPIObject() {} -func (*EndpointsList) IsAnAPIObject() {} -func (*Node) IsAnAPIObject() {} -func (*NodeList) IsAnAPIObject() {} -func (*Binding) IsAnAPIObject() {} -func (*Status) IsAnAPIObject() {} -func (*Operation) IsAnAPIObject() {} -func (*OperationList) IsAnAPIObject() {} -func (*Event) IsAnAPIObject() {} -func (*EventList) IsAnAPIObject() {} + Items []Event `json:"items" yaml:"items"` +} From 338ee1e4586da5b7fb456c03865479f44256b6fb Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Tue, 7 Oct 2014 10:50:35 -0400 Subject: [PATCH 2/2] Add additional debugging output on mistyped conversion --- pkg/conversion/converter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/conversion/converter.go b/pkg/conversion/converter.go index f61433910a3..1ad27e196ac 100644 --- a/pkg/conversion/converter.go +++ b/pkg/conversion/converter.go @@ -253,7 +253,7 @@ func (c *Converter) convert(sv, dv reflect.Value, scope *scope) error { } if !scope.flags.IsSet(AllowDifferentFieldTypeNames) && c.NameFunc(dt) != c.NameFunc(st) { - return fmt.Errorf("Can't convert %v to %v because type names don't match.", st, dt) + return fmt.Errorf("Can't convert %v to %v because type names don't match (%v, %v).", st, dt, c.NameFunc(st), c.NameFunc(dt)) } // This should handle all simple types.