Skip to content

Commit

Permalink
Use group with thirdpartyresource (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mir Shahriar authored and tamalsaha committed May 26, 2017
1 parent af6316c commit c007020
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/cmd/util/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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()
Expand Down

0 comments on commit c007020

Please sign in to comment.