diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index 3173ad4f02b..bc3a645b82a 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -333,7 +333,7 @@ func ValidatePodState(podState *api.PodState) errs.ErrorList { func ValidatePod(pod *api.Pod) errs.ErrorList { allErrs := errs.ErrorList{} if len(pod.Name) == 0 { - allErrs = append(allErrs, errs.NewFieldRequired("id", pod.Name)) + allErrs = append(allErrs, errs.NewFieldRequired("name", pod.Name)) } if !util.IsDNSSubdomain(pod.Namespace) { allErrs = append(allErrs, errs.NewFieldInvalid("namespace", pod.Namespace)) @@ -347,7 +347,7 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ErrorList { allErrs := errs.ErrorList{} if newPod.Name != oldPod.Name { - allErrs = append(allErrs, errs.NewFieldInvalid("ID", newPod.Name)) + allErrs = append(allErrs, errs.NewFieldInvalid("name", newPod.Name)) } if len(newPod.DesiredState.Manifest.Containers) != len(oldPod.DesiredState.Manifest.Containers) { @@ -374,9 +374,9 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) errs.ErrorList { func ValidateService(service *api.Service) errs.ErrorList { allErrs := errs.ErrorList{} if len(service.Name) == 0 { - allErrs = append(allErrs, errs.NewFieldRequired("id", service.Name)) + allErrs = append(allErrs, errs.NewFieldRequired("name", service.Name)) } else if !util.IsDNS952Label(service.Name) { - allErrs = append(allErrs, errs.NewFieldInvalid("id", service.Name)) + allErrs = append(allErrs, errs.NewFieldInvalid("name", service.Name)) } if !util.IsDNSSubdomain(service.Namespace) { allErrs = append(allErrs, errs.NewFieldInvalid("namespace", service.Namespace)) @@ -399,7 +399,7 @@ func ValidateService(service *api.Service) errs.ErrorList { func ValidateReplicationController(controller *api.ReplicationController) errs.ErrorList { allErrs := errs.ErrorList{} if len(controller.Name) == 0 { - allErrs = append(allErrs, errs.NewFieldRequired("id", controller.Name)) + allErrs = append(allErrs, errs.NewFieldRequired("name", controller.Name)) } if !util.IsDNSSubdomain(controller.Namespace) { allErrs = append(allErrs, errs.NewFieldInvalid("namespace", controller.Namespace)) @@ -441,7 +441,7 @@ 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.Name) { - errors = append(errors, errs.NewFieldInvalid("id", pod.Name)) + errors = append(errors, errs.NewFieldInvalid("name", pod.Name)) } if !util.IsDNSSubdomain(pod.Namespace) { errors = append(errors, errs.NewFieldInvalid("namespace", pod.Namespace)) diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 0414076fe49..b802463b093 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -813,7 +813,7 @@ func TestValidateReplicationController(t *testing.T) { for i := range errs { field := errs[i].(errors.ValidationError).Field if !strings.HasPrefix(field, "desiredState.podTemplate.") && - field != "id" && + field != "name" && field != "namespace" && field != "desiredState.replicaSelector" && field != "GCEPersistentDisk.ReadOnly" && diff --git a/pkg/kubecfg/resource_printer.go b/pkg/kubecfg/resource_printer.go index eb15f9e2ecc..1d90e3ee5f9 100644 --- a/pkg/kubecfg/resource_printer.go +++ b/pkg/kubecfg/resource_printer.go @@ -138,9 +138,9 @@ func (h *HumanReadablePrinter) validatePrintHandlerFunc(printFunc reflect.Value) return nil } -var podColumns = []string{"ID", "Image(s)", "Host", "Labels", "Status"} -var replicationControllerColumns = []string{"ID", "Image(s)", "Selector", "Replicas"} -var serviceColumns = []string{"ID", "Labels", "Selector", "IP", "Port"} +var podColumns = []string{"Name", "Image(s)", "Host", "Labels", "Status"} +var replicationControllerColumns = []string{"Name", "Image(s)", "Selector", "Replicas"} +var serviceColumns = []string{"Name", "Labels", "Selector", "IP", "Port"} var minionColumns = []string{"Minion identifier"} var statusColumns = []string{"Status"} var eventColumns = []string{"Name", "Kind", "Status", "Reason", "Message"} diff --git a/pkg/kubectl/cmd/delete.go b/pkg/kubectl/cmd/delete.go index a6cd1b70511..86c3b15cb04 100644 --- a/pkg/kubectl/cmd/delete.go +++ b/pkg/kubectl/cmd/delete.go @@ -50,7 +50,7 @@ Examples: Run: func(cmd *cobra.Command, args []string) { // If command line args are passed in, use those preferentially. if len(args) > 0 && len(args) != 2 { - usageError(cmd, "If passing in command line parameters, must be resource and id") + usageError(cmd, "If passing in command line parameters, must be resource and name") } var data []byte diff --git a/pkg/kubectl/modify.go b/pkg/kubectl/modify.go index dd3a96b40b1..3c06734d9f7 100644 --- a/pkg/kubectl/modify.go +++ b/pkg/kubectl/modify.go @@ -93,14 +93,14 @@ func doUpdate(c *client.RESTClient, resource string, obj runtime.Object) (string // object. id, err := getIDFromObj(obj) if err != nil { - return "", fmt.Errorf("ID not retrievable from object for update: %v", err) + return "", fmt.Errorf("Name not retrievable from object for update: %v", err) } // Get the object from the server to find out its current resource // version to prevent race conditions in updating the object. serverObj, err := c.Get().Path(resource).Path(id).Do().Get() if err != nil { - return "", fmt.Errorf("Item ID %s does not exist for update: %v", id, err) + return "", fmt.Errorf("Item Name %s does not exist for update: %v", id, err) } version, err := getResourceVersionFromObj(serverObj) if err != nil { @@ -134,7 +134,10 @@ func doUpdate(c *client.RESTClient, resource string, obj runtime.Object) (string func doDelete(c *client.RESTClient, resource string, obj runtime.Object) (string, error) { id, err := getIDFromObj(obj) if err != nil { - return "", fmt.Errorf("ID not retrievable from object for update: %v", err) + return "", fmt.Errorf("Name not retrievable from object for delete: %v", err) + } + if id == "" { + return "", fmt.Errorf("The supplied resource has no Name and cannot be deleted") } err = c.Delete().Path(resource).Path(id).Do().Error() diff --git a/pkg/kubectl/resource_printer.go b/pkg/kubectl/resource_printer.go index 1a6429b88be..20a1e9ad8b8 100644 --- a/pkg/kubectl/resource_printer.go +++ b/pkg/kubectl/resource_printer.go @@ -154,10 +154,10 @@ func (h *HumanReadablePrinter) validatePrintHandlerFunc(printFunc reflect.Value) return nil } -var podColumns = []string{"ID", "IMAGE(S)", "HOST", "LABELS", "STATUS"} -var replicationControllerColumns = []string{"ID", "IMAGE(S)", "SELECTOR", "REPLICAS"} -var serviceColumns = []string{"ID", "LABELS", "SELECTOR", "IP", "PORT"} -var minionColumns = []string{"ID"} +var podColumns = []string{"NAME", "IMAGE(S)", "HOST", "LABELS", "STATUS"} +var replicationControllerColumns = []string{"NAME", "IMAGE(S)", "SELECTOR", "REPLICAS"} +var serviceColumns = []string{"NAME", "LABELS", "SELECTOR", "IP", "PORT"} +var minionColumns = []string{"NAME"} var statusColumns = []string{"STATUS"} // addDefaultHandlers adds print handlers for default Kubernetes types. diff --git a/pkg/registry/etcd/etcd.go b/pkg/registry/etcd/etcd.go index 9f2ee557f90..8383a065170 100644 --- a/pkg/registry/etcd/etcd.go +++ b/pkg/registry/etcd/etcd.go @@ -522,7 +522,7 @@ func (r *Registry) WatchServices(ctx api.Context, label, field labels.Selector, if !label.Empty() { return nil, fmt.Errorf("label selectors are not supported on services") } - if value, found := field.RequiresExactMatch("ID"); found { + if value, found := field.RequiresExactMatch("name"); found { key, err := makeServiceKey(ctx, value) if err != nil { return nil, err @@ -532,7 +532,7 @@ func (r *Registry) WatchServices(ctx api.Context, label, field labels.Selector, if field.Empty() { return r.WatchList(makeServiceListKey(ctx), version, tools.Everything) } - return nil, fmt.Errorf("only the 'ID' and default (everything) field selectors are supported") + return nil, fmt.Errorf("only the 'name' and default (everything) field selectors are supported") } // ListEndpoints obtains a list of Services. @@ -567,7 +567,7 @@ func (r *Registry) WatchEndpoints(ctx api.Context, label, field labels.Selector, if !label.Empty() { return nil, fmt.Errorf("label selectors are not supported on endpoints") } - if value, found := field.RequiresExactMatch("ID"); found { + if value, found := field.RequiresExactMatch("name"); found { key, err := makeServiceEndpointsKey(ctx, value) if err != nil { return nil, err diff --git a/pkg/registry/etcd/etcd_test.go b/pkg/registry/etcd/etcd_test.go index e1a97f27611..bef2a77f368 100644 --- a/pkg/registry/etcd/etcd_test.go +++ b/pkg/registry/etcd/etcd_test.go @@ -1252,7 +1252,7 @@ func TestEtcdWatchServices(t *testing.T) { registry := NewTestEtcdRegistry(fakeClient) watching, err := registry.WatchServices(ctx, labels.Everything(), - labels.SelectorFromSet(labels.Set{"ID": "foo"}), + labels.SelectorFromSet(labels.Set{"name": "foo"}), "1", ) if err != nil { @@ -1306,7 +1306,7 @@ func TestEtcdWatchEndpoints(t *testing.T) { watching, err := registry.WatchEndpoints( ctx, labels.Everything(), - labels.SelectorFromSet(labels.Set{"ID": "foo"}), + labels.SelectorFromSet(labels.Set{"name": "foo"}), "1", ) if err != nil { diff --git a/pkg/registry/pod/rest.go b/pkg/registry/pod/rest.go index bc806ae8978..eec3f135b26 100644 --- a/pkg/registry/pod/rest.go +++ b/pkg/registry/pod/rest.go @@ -141,7 +141,7 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) { func (rs *REST) podToSelectableFields(pod *api.Pod) labels.Set { return labels.Set{ - "ID": pod.Name, + "name": pod.Name, "DesiredState.Status": string(pod.DesiredState.Status), "DesiredState.Host": pod.DesiredState.Host, } diff --git a/pkg/registry/pod/rest_test.go b/pkg/registry/pod/rest_test.go index 3670bae69ac..2dfa6a7b9b8 100644 --- a/pkg/registry/pod/rest_test.go +++ b/pkg/registry/pod/rest_test.go @@ -243,7 +243,7 @@ func TestListPodListSelection(t *testing.T) { { expectedIDs: util.NewStringSet("foo", "bar", "baz", "qux", "zot"), }, { - field: "ID=zot", + field: "name=zot", expectedIDs: util.NewStringSet("zot"), }, { label: "label=qux",