From 39d83c75f0bb4d34767ebdedcf1e46fd3311bb30 Mon Sep 17 00:00:00 2001 From: Jaesang Lee Date: Mon, 25 Oct 2021 02:23:40 +0000 Subject: [PATCH] Change App to Service. Change the command to receive input as Service instead of App for easier understanding by users. --- cmd/{app.go => service.go} | 23 +++++++--------- cmd/{app_create.go => service_create.go} | 34 ++++++++++++------------ 2 files changed, 26 insertions(+), 31 deletions(-) rename cmd/{app.go => service.go} (62%) rename cmd/{app_create.go => service_create.go} (72%) diff --git a/cmd/app.go b/cmd/service.go similarity index 62% rename from cmd/app.go rename to cmd/service.go index 74f9991..b188719 100644 --- a/cmd/app.go +++ b/cmd/service.go @@ -21,31 +21,26 @@ import ( "github.com/spf13/cobra" ) -// appCmd represents the app command -var appCmd = &cobra.Command{ - Use: "app", - Short: "Operation for TACO App", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, +// serviceCmd represents the service command +var serviceCmd = &cobra.Command{ + Use: "service", + Short: "Operation for TACO Service", + Long: `Operation for TACO Service`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("app called") + fmt.Println("service called") }, } func init() { - rootCmd.AddCommand(appCmd) + rootCmd.AddCommand(serviceCmd) // Here you will define your flags and configuration settings. // Cobra supports Persistent Flags which will work for this command // and all subcommands, e.g.: - // appCmd.PersistentFlags().String("foo", "", "A help for foo") + // serviceCmd.PersistentFlags().String("foo", "", "A help for foo") // Cobra supports local flags which will only run when this command // is called directly, e.g.: - // appCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + // serviceCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") } diff --git a/cmd/app_create.go b/cmd/service_create.go similarity index 72% rename from cmd/app_create.go rename to cmd/service_create.go index cad3467..95e0a3b 100644 --- a/cmd/app_create.go +++ b/cmd/service_create.go @@ -31,24 +31,24 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" ) -// appCreateCmd represents the create command -var appCreateCmd = &cobra.Command{ +// serviceCreateCmd represents the create command +var serviceCreateCmd = &cobra.Command{ Use: "create", - Short: "Create a TACO App.", - Long: `Create a TACO App. supported: LMA, SERVICE_MESH + Short: "Create a TACO Service.", + Long: `Create a TACO Service. supported: LMA, SERVICE_MESH Example: -tks app create --cluster-id --app-name `, +tks service create --cluster-id --service-name `, Run: func(cmd *cobra.Command, args []string) { fmt.Println("create called") - AppName, _ := cmd.Flags().GetString("app-name") + ServiceName, _ := cmd.Flags().GetString("service-name") var Type pb.AppGroupType - if AppName == "LMA" { + if ServiceName == "LMA" { Type = pb.AppGroupType_LMA - } else if AppName == "SERVICE_MESH" { + } else if ServiceName == "SERVICE_MESH" { Type = pb.AppGroupType_SERVICE_MESH } else { - fmt.Println("You must specify App Name. LMA or SERVICE_MESH") + fmt.Println("You must specify Service Name. LMA or SERVICE_MESH") os.Exit(1) } @@ -65,7 +65,7 @@ tks app create --cluster-id --app-name `, ClusterId, _ := cmd.Flags().GetString("cluster-id") ClusterIdPre := strings.Split(ClusterId, "-") - AppGroupName := ClusterIdPre[0] + "_" + AppName + AppGroupName := ClusterIdPre[0] + "_" + ServiceName data := make([]pb.InstallAppGroupsRequest, 1) appgroups := make([]pb.AppGroup, 1) @@ -93,19 +93,19 @@ tks app create --cluster-id --app-name `, } func init() { - appCmd.AddCommand(appCreateCmd) + serviceCmd.AddCommand(serviceCreateCmd) // Here you will define your flags and configuration settings. // Cobra supports Persistent Flags which will work for this command // and all subcommands, e.g.: - // appCreateCmd.PersistentFlags().String("foo", "", "A help for foo") + // serviceCreateCmd.PersistentFlags().String("foo", "", "A help for foo") // Cobra supports local flags which will only run when this command // is called directly, e.g.: - // appCreateCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") - appCreateCmd.Flags().String("cluster-id", "", "Cluster ID") - appCreateCmd.MarkFlagRequired("cluster-id") - appCreateCmd.Flags().String("app-name", "", "App Name") - appCreateCmd.MarkFlagRequired("app-name") + // serviceCreateCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + serviceCreateCmd.Flags().String("cluster-id", "", "Cluster ID") + serviceCreateCmd.MarkFlagRequired("cluster-id") + serviceCreateCmd.Flags().String("service-name", "", "Service Name") + serviceCreateCmd.MarkFlagRequired("service-name") }