diff --git a/pkg/cmd/delete.go b/pkg/cmd/delete.go index 53c50df1c..c52d36c42 100644 --- a/pkg/cmd/delete.go +++ b/pkg/cmd/delete.go @@ -68,7 +68,7 @@ func RunDelete(f cmdutil.Factory, cmd *cobra.Command, out io.Writer, args []stri resources := strings.Split(args[0], ",") for i, r := range resources { items := strings.Split(r, "/") - kind, err := util.GetSupportedResourceKind(items[0]) + kind, err := util.GetSupportedResource(items[0]) if err != nil { return err } diff --git a/pkg/cmd/describe.go b/pkg/cmd/describe.go index 1b617c978..eebba2f41 100644 --- a/pkg/cmd/describe.go +++ b/pkg/cmd/describe.go @@ -79,7 +79,7 @@ func RunDescribe(f cmdutil.Factory, out, cmdErr io.Writer, cmd *cobra.Command, a printAll = true } else { items := strings.Split(r, "/") - kind, err := util.GetSupportedResourceKind(items[0]) + kind, err := util.GetSupportedResource(items[0]) if err != nil { return err } diff --git a/pkg/cmd/edit.go b/pkg/cmd/edit.go index 4f6b749ac..2d2cecc40 100644 --- a/pkg/cmd/edit.go +++ b/pkg/cmd/edit.go @@ -81,7 +81,7 @@ func runEdit(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args resources := strings.Split(args[0], ",") for i, r := range resources { items := strings.Split(r, "/") - kind, err := util.GetSupportedResourceKind(items[0]) + kind, err := util.GetSupportedResource(items[0]) if err != nil { return err } diff --git a/pkg/cmd/get.go b/pkg/cmd/get.go index 0a359000f..c3adfbe84 100644 --- a/pkg/cmd/get.go +++ b/pkg/cmd/get.go @@ -99,7 +99,7 @@ func RunGet(f cmdutil.Factory, cmd *cobra.Command, out, errOut io.Writer, args [ printAll = true } else { items := strings.Split(r, "/") - kind, err := util.GetSupportedResourceKind(items[0]) + kind, err := util.GetSupportedResource(items[0]) if err != nil { return err } diff --git a/pkg/cmd/util/resource.go b/pkg/cmd/util/resource.go index 76380ba19..c7e68941d 100644 --- a/pkg/cmd/util/resource.go +++ b/pkg/cmd/util/resource.go @@ -13,24 +13,24 @@ import ( "k8s.io/kubernetes/pkg/util/strategicpatch" ) -func GetSupportedResourceKind(resource string) (string, error) { +func GetSupportedResource(resource string) (string, error) { switch strings.ToLower(resource) { case strings.ToLower(tapi.ResourceKindElastic): case strings.ToLower(tapi.ResourceTypeElastic): case strings.ToLower(tapi.ResourceCodeElastic): - return tapi.ResourceKindElastic, nil + return tapi.ResourceKindElastic + "." + tapi.V1beta1SchemeGroupVersion.Group, nil case strings.ToLower(tapi.ResourceKindPostgres): case strings.ToLower(tapi.ResourceTypePostgres): case strings.ToLower(tapi.ResourceCodePostgres): - return tapi.ResourceKindPostgres, nil + return tapi.ResourceKindPostgres + "." + tapi.V1beta1SchemeGroupVersion.Group, nil case strings.ToLower(tapi.ResourceKindSnapshot): case strings.ToLower(tapi.ResourceTypeSnapshot): case strings.ToLower(tapi.ResourceCodeSnapshot): - return tapi.ResourceKindSnapshot, nil + return tapi.ResourceKindSnapshot + "." + tapi.V1beta1SchemeGroupVersion.Group, nil case strings.ToLower(tapi.ResourceKindDormantDatabase): case strings.ToLower(tapi.ResourceTypeDormantDatabase): case strings.ToLower(tapi.ResourceCodeDormantDatabase): - return tapi.ResourceKindDormantDatabase, nil + return tapi.ResourceKindDormantDatabase + "." + tapi.V1beta1SchemeGroupVersion.Group, nil default: return "", fmt.Errorf(`kubedb doesn't support a resource type "%v"`, resource) } @@ -53,10 +53,10 @@ func CheckSupportedResource(kind string) error { func GetAllSupportedResources(f cmdutil.Factory) ([]string, error) { resources := map[string]string{ - tapi.ResourceNameElastic: tapi.ResourceTypeElastic, - tapi.ResourceNamePostgres: tapi.ResourceTypePostgres, - tapi.ResourceNameSnapshot: tapi.ResourceTypeSnapshot, - tapi.ResourceNameDormantDatabase: tapi.ResourceTypeDormantDatabase, + tapi.ResourceNameElastic: tapi.ResourceKindElastic + "." + tapi.V1beta1SchemeGroupVersion.Group, + tapi.ResourceNamePostgres: tapi.ResourceKindPostgres + "." + tapi.V1beta1SchemeGroupVersion.Group, + tapi.ResourceNameSnapshot: tapi.ResourceKindSnapshot + "." + tapi.V1beta1SchemeGroupVersion.Group, + tapi.ResourceNameDormantDatabase: tapi.ResourceKindDormantDatabase + "." + tapi.V1beta1SchemeGroupVersion.Group, } clientset, err := f.ClientSet()