Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use group name with thirdpartyresource #42

Merged
merged 1 commit into from
May 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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