Skip to content

Commit

Permalink
Rename ID -> Name
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Oct 22, 2014
1 parent bdebff5 commit bb77a5d
Show file tree
Hide file tree
Showing 107 changed files with 777 additions and 777 deletions.
8 changes: 4 additions & 4 deletions cmd/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ func TestPodUpdate(c *client.Client) bool {
glog.Errorf("Failed to create pod: %v", err)
return false
}
defer c.DeletePod(ctx, pod.ID)
waitForPodRunning(c, pod.ID)
defer c.DeletePod(ctx, pod.Name)
waitForPodRunning(c, pod.Name)
pods, err := c.ListPods(ctx, labels.SelectorFromSet(labels.Set(map[string]string{"time": value})))
if len(pods.Items) != 1 {
glog.Errorf("Failed to find the correct pod")
return false
}

podOut, err := c.GetPod(ctx, pod.ID)
podOut, err := c.GetPod(ctx, pod.Name)
if err != nil {
glog.Errorf("Failed to get pod: %v", err)
return false
Expand All @@ -133,7 +133,7 @@ func TestPodUpdate(c *client.Client) bool {
glog.Errorf("Failed to update pod: %v", err)
return false
}
waitForPodRunning(c, pod.ID)
waitForPodRunning(c, pod.Name)
pods, err = c.ListPods(ctx, labels.SelectorFromSet(labels.Set(map[string]string{"time": value})))
if len(pods.Items) != 1 {
glog.Errorf("Failed to find the correct pod after update.")
Expand Down
22 changes: 11 additions & 11 deletions cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func podsOnMinions(c *client.Client, pods api.PodList) wait.ConditionFunc {
podInfo := fakePodInfoGetter{}
return func() (bool, error) {
for i := range pods.Items {
host, id, namespace := pods.Items[i].CurrentState.Host, pods.Items[i].ID, pods.Items[i].Namespace
host, id, namespace := pods.Items[i].CurrentState.Host, pods.Items[i].Name, pods.Items[i].Namespace
if len(host) == 0 {
return false, nil
}
Expand Down Expand Up @@ -251,7 +251,7 @@ func runAtomicPutTest(c *client.Client) {
var svc api.Service
err := c.Post().Path("services").Body(
&api.Service{
TypeMeta: api.TypeMeta{ID: "atomicservice", APIVersion: latest.Version},
TypeMeta: api.TypeMeta{Name: "atomicservice", APIVersion: latest.Version},
Port: 12345,
Labels: map[string]string{
"name": "atomicService",
Expand Down Expand Up @@ -282,7 +282,7 @@ func runAtomicPutTest(c *client.Client) {
var tmpSvc api.Service
err := c.Get().
Path("services").
Path(svc.ID).
Path(svc.Name).
PollPeriod(100 * time.Millisecond).
Do().
Into(&tmpSvc)
Expand All @@ -296,7 +296,7 @@ func runAtomicPutTest(c *client.Client) {
tmpSvc.Selector[l] = v
}
glog.Infof("Posting update (%s, %s)", l, v)
err = c.Put().Path("services").Path(svc.ID).Body(&tmpSvc).Do().Error()
err = c.Put().Path("services").Path(svc.Name).Body(&tmpSvc).Do().Error()
if err != nil {
if errors.IsConflict(err) {
glog.Infof("Conflict: (%s, %s)", l, v)
Expand All @@ -313,7 +313,7 @@ func runAtomicPutTest(c *client.Client) {
}(label, value)
}
wg.Wait()
if err := c.Get().Path("services").Path(svc.ID).Do().Into(&svc); err != nil {
if err := c.Get().Path("services").Path(svc.Name).Do().Into(&svc); err != nil {
glog.Fatalf("Failed getting atomicService after writers are complete: %v", err)
}
if !reflect.DeepEqual(testLabels, labels.Set(svc.Selector)) {
Expand All @@ -325,7 +325,7 @@ func runAtomicPutTest(c *client.Client) {
func runServiceTest(client *client.Client) {
ctx := api.NewDefaultContext()
pod := api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"},
TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: api.PodState{
Manifest: api.ContainerManifest{
Version: "v1beta1",
Expand All @@ -351,11 +351,11 @@ func runServiceTest(client *client.Client) {
if err != nil {
glog.Fatalf("Failed to create pod: %v, %v", pod, err)
}
if err := wait.Poll(time.Second, time.Second*20, podExists(client, ctx, pod.ID)); err != nil {
if err := wait.Poll(time.Second, time.Second*20, podExists(client, ctx, pod.Name)); err != nil {
glog.Fatalf("FAILED: pod never started running %v", err)
}
svc1 := api.Service{
TypeMeta: api.TypeMeta{ID: "service1"},
TypeMeta: api.TypeMeta{Name: "service1"},
Selector: map[string]string{
"name": "thisisalonglabel",
},
Expand All @@ -365,12 +365,12 @@ func runServiceTest(client *client.Client) {
if err != nil {
glog.Fatalf("Failed to create service: %v, %v", svc1, err)
}
if err := wait.Poll(time.Second, time.Second*20, endpointsSet(client, ctx, svc1.ID, 1)); err != nil {
if err := wait.Poll(time.Second, time.Second*20, endpointsSet(client, ctx, svc1.Name, 1)); err != nil {
glog.Fatalf("FAILED: unexpected endpoints: %v", err)
}
// A second service with the same port.
svc2 := api.Service{
TypeMeta: api.TypeMeta{ID: "service2"},
TypeMeta: api.TypeMeta{Name: "service2"},
Selector: map[string]string{
"name": "thisisalonglabel",
},
Expand All @@ -380,7 +380,7 @@ func runServiceTest(client *client.Client) {
if err != nil {
glog.Fatalf("Failed to create service: %v, %v", svc2, err)
}
if err := wait.Poll(time.Second, time.Second*20, endpointsSet(client, ctx, svc2.ID, 1)); err != nil {
if err := wait.Poll(time.Second, time.Second*20, endpointsSet(client, ctx, svc2.Name, 1)); err != nil {
glog.Fatalf("FAILED: unexpected endpoints: %v", err)
}
glog.Info("Service test passed.")
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func init() {
out.Spec.Containers = in.Containers
out.Spec.Volumes = in.Volumes
out.Spec.RestartPolicy = in.RestartPolicy
out.ID = in.ID
out.Name = in.ID
out.UID = in.UUID
return nil
},
Expand All @@ -41,7 +41,7 @@ func init() {
out.Volumes = in.Spec.Volumes
out.RestartPolicy = in.Spec.RestartPolicy
out.Version = "v1beta2"
out.ID = in.ID
out.ID = in.Name
out.UUID = in.UID
return nil
},
Expand Down Expand Up @@ -71,7 +71,7 @@ func init() {
// Only copy a subset of fields, and override manifest attributes with the pod
// metadata
out.UID = in.UID
out.ID = in.ID
out.Name = in.Name
out.Namespace = in.Namespace
out.CreationTimestamp = in.CreationTimestamp
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/latest/latest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
// APIVersion and Kind must remain blank in memory.
j.APIVersion = ""
j.Kind = ""
j.ID = c.RandString()
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.
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestGetReference(t *testing.T) {
"pod": {
obj: &Pod{
TypeMeta: TypeMeta{
ID: "foo",
Name: "foo",
ResourceVersion: "42",
SelfLink: "/api/v1beta1/pods/foo",
},
Expand All @@ -52,7 +52,7 @@ func TestGetReference(t *testing.T) {
"serviceList": {
obj: &ServiceList{
TypeMeta: TypeMeta{
ID: "foo",
Name: "foo",
ResourceVersion: "42",
SelfLink: "/api/v1beta2/services",
},
Expand All @@ -68,7 +68,7 @@ func TestGetReference(t *testing.T) {
"badSelfLink": {
obj: &ServiceList{
TypeMeta: TypeMeta{
ID: "foo",
Name: "foo",
ResourceVersion: "42",
SelfLink: "v1beta2/services",
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
// APIVersion and Kind must remain blank in memory.
j.APIVersion = ""
j.Kind = ""
j.ID = c.RandString()
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.
Expand All @@ -63,7 +63,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
// APIVersion and Kind must remain blank in memory.
j.APIVersion = ""
j.Kind = ""
j.ID = c.RandString()
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.
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ type Lifecycle struct {
// TypeMeta is shared by all objects sent to, or returned from the client.
type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
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"`
Expand Down Expand Up @@ -458,7 +458,7 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString

// Minion is a worker node in Kubernetenes.
// The name of the minion according to etcd is in TypeMeta.ID.
// The name of the minion according to etcd is in ID.
type Minion struct {
TypeMeta `json:",inline" yaml:",inline"`
// Queried from cloud provider, if available.
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
out.APIVersion = in.APIVersion
out.Kind = in.Kind
out.Namespace = in.Namespace
out.ID = in.ID
out.ID = in.Name
out.CreationTimestamp = in.CreationTimestamp
out.SelfLink = in.SelfLink
out.Annotations = in.Annotations
Expand All @@ -48,7 +48,7 @@ func init() {
out.APIVersion = in.APIVersion
out.Kind = in.Kind
out.Namespace = in.Namespace
out.ID = in.ID
out.Name = in.ID
out.CreationTimestamp = in.CreationTimestamp
out.SelfLink = in.SelfLink
out.Annotations = in.Annotations
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/v1beta1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{ID: id}}
return newer.Minion{TypeMeta: newer.TypeMeta{Name: id}}
}
oldMinions := []v1beta1.Minion{
oldMinion("foo"),
Expand Down Expand Up @@ -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{ID: id}}
return newer.Minion{TypeMeta: newer.TypeMeta{Name: id}}
}
oldMinions := []v1beta1.Minion{
oldMinion("foo"),
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString

// Minion is a worker node in Kubernetenes.
// The name of the minion according to etcd is in TypeMeta.ID.
// The name of the minion according to etcd is in ID.
type Minion struct {
TypeMeta `json:",inline" yaml:",inline"`
// Queried from cloud provider, if available.
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/v1beta2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
out.APIVersion = in.APIVersion
out.Kind = in.Kind
out.Namespace = in.Namespace
out.ID = in.ID
out.ID = in.Name
out.CreationTimestamp = in.CreationTimestamp
out.SelfLink = in.SelfLink
out.Annotations = in.Annotations
Expand All @@ -48,7 +48,7 @@ func init() {
out.APIVersion = in.APIVersion
out.Kind = in.Kind
out.Namespace = in.Namespace
out.ID = in.ID
out.Name = in.ID
out.CreationTimestamp = in.CreationTimestamp
out.SelfLink = in.SelfLink
out.Annotations = in.Annotations
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString

// Minion is a worker node in Kubernetenes.
// The name of the minion according to etcd is in TypeMeta.ID.
// The name of the minion according to etcd is in ID.
type Minion struct {
TypeMeta `json:",inline" yaml:",inline"`
// Queried from cloud provider, if available.
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString

// Node is a worker node in Kubernetenes.
// The name of the node according to etcd is in TypeMeta.ID.
// The name of the node according to etcd is in ID.
type Node struct {
TypeMeta `json:",inline" yaml:",inline"`
Metadata ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Expand Down
26 changes: 13 additions & 13 deletions pkg/api/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ func ValidatePodState(podState *api.PodState) errs.ErrorList {
// ValidatePod tests if required fields in the pod are set.
func ValidatePod(pod *api.Pod) errs.ErrorList {
allErrs := errs.ErrorList{}
if len(pod.ID) == 0 {
allErrs = append(allErrs, errs.NewFieldRequired("id", pod.ID))
if len(pod.Name) == 0 {
allErrs = append(allErrs, errs.NewFieldRequired("id", pod.Name))
}
if !util.IsDNSSubdomain(pod.Namespace) {
allErrs = append(allErrs, errs.NewFieldInvalid("namespace", pod.Namespace))
Expand All @@ -346,8 +346,8 @@ func ValidatePod(pod *api.Pod) errs.ErrorList {
func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ErrorList {
allErrs := errs.ErrorList{}

if newPod.ID != oldPod.ID {
allErrs = append(allErrs, errs.NewFieldInvalid("ID", newPod.ID))
if newPod.Name != oldPod.Name {
allErrs = append(allErrs, errs.NewFieldInvalid("ID", newPod.Name))
}

if len(newPod.DesiredState.Manifest.Containers) != len(oldPod.DesiredState.Manifest.Containers) {
Expand All @@ -373,10 +373,10 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ErrorList {
// ValidateService tests if required fields in the service are set.
func ValidateService(service *api.Service) errs.ErrorList {
allErrs := errs.ErrorList{}
if len(service.ID) == 0 {
allErrs = append(allErrs, errs.NewFieldRequired("id", service.ID))
} else if !util.IsDNS952Label(service.ID) {
allErrs = append(allErrs, errs.NewFieldInvalid("id", service.ID))
if len(service.Name) == 0 {
allErrs = append(allErrs, errs.NewFieldRequired("id", service.Name))
} else if !util.IsDNS952Label(service.Name) {
allErrs = append(allErrs, errs.NewFieldInvalid("id", service.Name))
}
if !util.IsDNSSubdomain(service.Namespace) {
allErrs = append(allErrs, errs.NewFieldInvalid("namespace", service.Namespace))
Expand All @@ -398,8 +398,8 @@ func ValidateService(service *api.Service) errs.ErrorList {
// ValidateReplicationController tests if required fields in the replication controller are set.
func ValidateReplicationController(controller *api.ReplicationController) errs.ErrorList {
allErrs := errs.ErrorList{}
if len(controller.ID) == 0 {
allErrs = append(allErrs, errs.NewFieldRequired("id", controller.ID))
if len(controller.Name) == 0 {
allErrs = append(allErrs, errs.NewFieldRequired("id", controller.Name))
}
if !util.IsDNSSubdomain(controller.Namespace) {
allErrs = append(allErrs, errs.NewFieldInvalid("namespace", controller.Namespace))
Expand Down Expand Up @@ -440,15 +440,15 @@ func ValidateReadOnlyPersistentDisks(volumes []api.Volume) errs.ErrorList {

// ValidateBoundPod tests if required fields on a bound pod are set.
func ValidateBoundPod(pod *api.BoundPod) (errors []error) {
if !util.IsDNSSubdomain(pod.ID) {
errors = append(errors, errs.NewFieldInvalid("id", pod.ID))
if !util.IsDNSSubdomain(pod.Name) {
errors = append(errors, errs.NewFieldInvalid("id", pod.Name))
}
if !util.IsDNSSubdomain(pod.Namespace) {
errors = append(errors, errs.NewFieldInvalid("namespace", pod.Namespace))
}
containerManifest := &api.ContainerManifest{
Version: "v1beta2",
ID: pod.ID,
ID: pod.Name,
UUID: pod.UID,
Containers: pod.Spec.Containers,
Volumes: pod.Spec.Volumes,
Expand Down
Loading

0 comments on commit bb77a5d

Please sign in to comment.