Skip to content

Commit

Permalink
fix: modify both _ and - cases
Browse files Browse the repository at this point in the history
Signed-off-by: Youngjin Jo <youngjinjo@megazone.com>
  • Loading branch information
yjinjo committed Dec 5, 2024
1 parent bd1d930 commit 53ece85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
21 changes: 10 additions & 11 deletions cmd/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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:")
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 53ece85

Please sign in to comment.