From 855c7cedccb635867811ab016147f0b0c3da5a3d Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 21 Aug 2015 14:24:16 -0700 Subject: [PATCH] Address comments. --- contrib/completions/bash/kubectl | 2 ++ pkg/expapi/types.go | 1 - pkg/expapi/v1/types.go | 1 - pkg/kubectl/resource_printer.go | 2 +- pkg/master/master.go | 4 ++-- pkg/master/master_test.go | 8 ++++---- pkg/registry/thirdpartyresource/etcd/etcd_test.go | 1 - pkg/registry/thirdpartyresourcedata/codec.go | 3 --- pkg/registry/thirdpartyresourcedata/etcd/etcd.go | 4 +++- 9 files changed, 12 insertions(+), 14 deletions(-) diff --git a/contrib/completions/bash/kubectl b/contrib/completions/bash/kubectl index 21fcb1ed34..08f18d5eb0 100644 --- a/contrib/completions/bash/kubectl +++ b/contrib/completions/bash/kubectl @@ -287,6 +287,7 @@ _kubectl_get() must_have_one_noun+=("secret") must_have_one_noun+=("service") must_have_one_noun+=("serviceaccount") + must_have_one_noun+=("thirdpartyresource") } _kubectl_describe() @@ -460,6 +461,7 @@ _kubectl_delete() must_have_one_noun+=("secret") must_have_one_noun+=("service") must_have_one_noun+=("serviceaccount") + must_have_one_noun+=("thirdpartyresource") } _kubectl_namespace() diff --git a/pkg/expapi/types.go b/pkg/expapi/types.go index 68ec8aadb2..d826c60e04 100644 --- a/pkg/expapi/types.go +++ b/pkg/expapi/types.go @@ -167,7 +167,6 @@ type ThirdPartyResourceData struct { Data []byte `json:"name,omitempty" description:"the raw JSON data for this data"` } -<<<<<<< HEAD type Deployment struct { api.TypeMeta `json:",inline"` api.ObjectMeta `json:"metadata,omitempty"` diff --git a/pkg/expapi/v1/types.go b/pkg/expapi/v1/types.go index 65d55c6748..956e733446 100644 --- a/pkg/expapi/v1/types.go +++ b/pkg/expapi/v1/types.go @@ -153,7 +153,6 @@ type ThirdPartyResourceData struct { Data []byte `json:"name,omitempty" description:"the raw JSON data for this data"` } -<<<<<<< HEAD type Deployment struct { v1.TypeMeta `json:",inline"` v1.ObjectMeta `json:"metadata,omitempty"` diff --git a/pkg/kubectl/resource_printer.go b/pkg/kubectl/resource_printer.go index 548f275316..3d649a6efc 100644 --- a/pkg/kubectl/resource_printer.go +++ b/pkg/kubectl/resource_printer.go @@ -1088,7 +1088,7 @@ func printThirdPartyResource(rsrc *expapi.ThirdPartyResource, w io.Writer, withN func printThirdPartyResourceList(list *expapi.ThirdPartyResourceList, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error { for _, item := range list.Items { - if err := printThirdPartyResource(&item, w, withNamespace, wide, columnLabels); err != nil { + if err := printThirdPartyResource(&item, w, withNamespace, wide, showAll, columnLabels); err != nil { return err } } diff --git a/pkg/master/master.go b/pkg/master/master.go index 30d6d4d55e..84fc0d7b84 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -776,7 +776,7 @@ func (m *Master) InstallThirdPartyAPI(rsrc *expapi.ThirdPartyResource) error { if err != nil { return err } - thirdparty := m.thirdpartyapi(group, strings.ToLower(kind)+"s", rsrc.Versions[0].Name) + thirdparty := m.thirdpartyapi(group, kind, rsrc.Versions[0].Name) if err := thirdparty.InstallREST(m.handlerContainer); err != nil { glog.Fatalf("Unable to setup thirdparty api: %v", err) } @@ -793,7 +793,7 @@ func (m *Master) thirdpartyapi(group, kind, version string) *apiserver.APIGroupV apiRoot := "/thirdparty/" + group + "/" storage := map[string]rest.Storage{ - kind: resourceStorage, + strings.ToLower(kind) + "s": resourceStorage, } return &apiserver.APIGroupVersion{ diff --git a/pkg/master/master_test.go b/pkg/master/master_test.go index 88137175de..d3712417eb 100644 --- a/pkg/master/master_test.go +++ b/pkg/master/master_test.go @@ -198,7 +198,7 @@ func TestInstallThirdPartyAPIGet(t *testing.T) { Name: "test", }, TypeMeta: api.TypeMeta{ - Kind: "foo", + Kind: "Foo", }, SomeField: "test field", OtherField: 10, @@ -237,12 +237,12 @@ func TestInstallThirdPartyAPIPost(t *testing.T) { Name: "test", }, TypeMeta: api.TypeMeta{ - Kind: "foo", + Kind: "Foo", }, SomeField: "test field", OtherField: 10, } - data, err := encodeToThirdParty("test", inputObj) + data, err := json.Marshal(inputObj) if err != nil { t.Errorf("unexpected error: %v") return @@ -298,7 +298,7 @@ func TestInstallThirdPartyAPIDelete(t *testing.T) { Name: "test", }, TypeMeta: api.TypeMeta{ - Kind: "foo", + Kind: "Foo", }, SomeField: "test field", OtherField: 10, diff --git a/pkg/registry/thirdpartyresource/etcd/etcd_test.go b/pkg/registry/thirdpartyresource/etcd/etcd_test.go index 3406b62bcd..b60bc020fe 100644 --- a/pkg/registry/thirdpartyresource/etcd/etcd_test.go +++ b/pkg/registry/thirdpartyresource/etcd/etcd_test.go @@ -101,7 +101,6 @@ func TestUpdate(t *testing.T) { ) } -<<<<<<< HEAD func TestDelete(t *testing.T) { ctx := api.NewDefaultContext() storage, fakeClient := newStorage(t) diff --git a/pkg/registry/thirdpartyresourcedata/codec.go b/pkg/registry/thirdpartyresourcedata/codec.go index 120a6caa30..7d2c75bb0b 100644 --- a/pkg/registry/thirdpartyresourcedata/codec.go +++ b/pkg/registry/thirdpartyresourcedata/codec.go @@ -85,9 +85,6 @@ func (t *thirdPartyResourceDataCodec) populate(objIn *expapi.ThirdPartyResourceD if !ok { return fmt.Errorf("unexpected object: %#v", obj) } - if kind == "ThirdPartyResourceData" { - return t.delegate.DecodeInto(data, objIn) - } if kind != t.kind { return fmt.Errorf("unexpected kind: %s, expected: %s", kind, t.kind) } diff --git a/pkg/registry/thirdpartyresourcedata/etcd/etcd.go b/pkg/registry/thirdpartyresourcedata/etcd/etcd.go index ea9495bb23..497f730ec5 100644 --- a/pkg/registry/thirdpartyresourcedata/etcd/etcd.go +++ b/pkg/registry/thirdpartyresourcedata/etcd/etcd.go @@ -17,6 +17,8 @@ limitations under the License. package etcd import ( + "strings" + "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/expapi" "k8s.io/kubernetes/pkg/fields" @@ -35,7 +37,7 @@ type REST struct { // NewREST returns a registry which will store ThirdPartyResourceData in the given helper func NewREST(s storage.Interface, group, kind string) *REST { - prefix := "/ThirdPartyResourceData/" + group + "/" + kind + prefix := "/ThirdPartyResourceData/" + group + "/" + strings.ToLower(kind) + "s" store := &etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &expapi.ThirdPartyResourceData{} },