From 53ece853e142ccf61aa99571a4962d145d18b6d5 Mon Sep 17 00:00:00 2001 From: Youngjin Jo Date: Thu, 5 Dec 2024 20:51:33 +0900 Subject: [PATCH] fix: modify both _ and - cases Signed-off-by: Youngjin Jo --- cmd/common/helpers.go | 21 ++++++++++----------- cmd/root.go | 1 + 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/common/helpers.go b/cmd/common/helpers.go index c9f10a0..50f749b 100644 --- a/cmd/common/helpers.go +++ b/cmd/common/helpers.go @@ -21,6 +21,12 @@ import ( "github.com/jhump/protoreflect/grpcreflect" ) +func convertServiceNameToEndpoint(serviceName string) string { + // cost_analysis -> cost-analysis + // file_manager -> file-manager + return strings.ReplaceAll(serviceName, "_", "-") +} + // BuildVerbResourceMap builds a mapping from verbs to resources for a given service func BuildVerbResourceMap(serviceName string) (map[string][]string, error) { config, err := loadConfig() @@ -36,7 +42,10 @@ func BuildVerbResourceMap(serviceName string) (map[string][]string, error) { } else { return nil, fmt.Errorf("unsupported environment prefix") } - hostPort := fmt.Sprintf("%s.api.%s.spaceone.dev:443", serviceName, envPrefix) + + // Convert service name to endpoint format + endpointServiceName := convertServiceNameToEndpoint(serviceName) + hostPort := fmt.Sprintf("%s.api.%s.spaceone.dev:443", endpointServiceName, envPrefix) // Configure gRPC connection var opts []grpc.DialOption @@ -117,11 +126,6 @@ func CustomParentHelpFunc(cmd *cobra.Command, args []string) { cmd.Println() } - if cmd.Long != "" { - cmd.Println(cmd.Long) - cmd.Println() - } - printSortedBulletList(cmd, "Verbs") cmd.Println("Flags:") @@ -173,11 +177,6 @@ func CustomVerbHelpFunc(cmd *cobra.Command, args []string) { cmd.Println() } - if cmd.Long != "" { - cmd.Println(cmd.Long) - cmd.Println() - } - if resourcesStr, ok := cmd.Annotations["resources"]; ok && resourcesStr != "" { resources := strings.Split(resourcesStr, ", ") sort.Strings(resources) diff --git a/cmd/root.go b/cmd/root.go index 98b970a..7d853e6 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -113,6 +113,7 @@ func init() { rootCmd.AddCommand(other.SettingCmd) rootCmd.AddCommand(other.LoginCmd) rootCmd.AddCommand(other.ShortNameCmd) + rootCmd.AddCommand(other.AnalyzeCmd) // Set default group for commands without a group for _, cmd := range rootCmd.Commands() {