diff --git a/cmd/configure.go b/cmd/configure.go index def2cc6..bb4b089 100644 --- a/cmd/configure.go +++ b/cmd/configure.go @@ -18,8 +18,8 @@ import ( func newConfigureCmd() *cobra.Command { cmd := &cobra.Command{ Use: "configure", - Short: "Configure the connection of API7", - Long: `The ping command can be used to configure the connection to the API7.`, + Short: "Configure ADC with APISIX instance", + Long: `Configures ADC with APISIX's server address and token.`, RunE: func(cmd *cobra.Command, args []string) error { return saveConfiguration() }, @@ -30,20 +30,20 @@ func newConfigureCmd() *cobra.Command { func saveConfiguration() error { if rootConfig.Server != "" && rootConfig.Token != "" { - color.Yellow("adc has been configured, you can use `adc ping` to test the connection") + color.Yellow("ADC configured. Run `adc ping` to test the configuration.") return nil } reader := bufio.NewReader(os.Stdin) if rootConfig.Server == "" { - fmt.Println("Please input the server address: ") + fmt.Println("Please enter the APISIX server address: ") server, _ := reader.ReadString('\n') rootConfig.Server = strings.TrimSpace(server) } if rootConfig.Token == "" { - fmt.Println("Please input the Token: ") + fmt.Println("Please enter the token: ") token, _ := reader.ReadString('\n') rootConfig.Token = strings.TrimSpace(token) } @@ -52,11 +52,11 @@ func saveConfiguration() error { viper.Set("server", rootConfig.Server) viper.Set("token", rootConfig.Token) if err := viper.SafeWriteConfig(); err != nil { - color.Red("failed configure ADC") + color.Red("Failed to configure ADC") return err } - color.Green("Successfully configure ADC") + color.Green("ADC configured successfully!") return pingAPISIX() } diff --git a/cmd/diff.go b/cmd/diff.go index b32869f..65b902a 100644 --- a/cmd/diff.go +++ b/cmd/diff.go @@ -11,8 +11,8 @@ import ( func newDiffCmd() *cobra.Command { cmd := &cobra.Command{ Use: "diff", - Short: "Diff the configurations between local and API7", - Long: `The diff command can be used to diff the configurations between local and API7.`, + Short: "Show the differences between the local and existing APISIX configuration", + Long: `Shows the differences in the configuration between the local confguration file and the connected APISIX instance.`, RunE: func(cmd *cobra.Command, args []string) error { checkConfig() diff --git a/cmd/dump.go b/cmd/dump.go index 2808a79..a7c187b 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -20,8 +20,8 @@ import ( func newDumpCmd() *cobra.Command { cmd := &cobra.Command{ Use: "dump", - Short: "Dump the configurations of API7", - Long: `The dump command can be used to dump the configurations to the API7.`, + Short: "Dump the APISIX configuration", + Long: `Dumps the configuration of the connected APISIX instance to a local file.`, RunE: func(cmd *cobra.Command, args []string) error { checkConfig() @@ -41,11 +41,11 @@ func newDumpCmd() *cobra.Command { func dumpConfiguration(cmd *cobra.Command) error { path, err := cmd.Flags().GetString("output") if err != nil { - color.Red("Get file path failed: %v", err) + color.Red("Failed to get output file path: %v", err) return err } if path == "" { - color.Red("Output path is empty. Example: adc dump -o config.yaml") + color.Red("Output file path is empty. Please specify a file path: adc dump -o config.yaml") return nil } diff --git a/cmd/ping.go b/cmd/ping.go index c08449d..9ccf0dc 100644 --- a/cmd/ping.go +++ b/cmd/ping.go @@ -17,8 +17,8 @@ import ( func newPingCmd() *cobra.Command { cmd := &cobra.Command{ Use: "ping", - Short: "Verify the connection to the APISIX", - Long: `The ping command can be used to verify the connection to the APISIX.`, + Short: "Verify connectivity with APISIX", + Long: `Pings the configured APISIX instance to verify connectivity.`, RunE: func(cmd *cobra.Command, args []string) error { checkConfig() @@ -40,9 +40,9 @@ func pingAPISIX() error { UpstreamId: "abcd", }) if err != nil { - color.Red("failed to ping APISIX: %v", err.Error()) + color.Red("Failed to ping APISIX: %v", err.Error()) } else { - color.Green("Successfully connected to APISIX") + color.Green("Connected to APISIX successfully!") } return nil } diff --git a/cmd/root.go b/cmd/root.go index 7a9346d..e8a2fdf 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -24,10 +24,10 @@ var ( func newRootCmd() *cobra.Command { rootCmd := &cobra.Command{ Use: "adc", - Short: "API7 Declarative CLI", - Long: `A CLI tool for API7 Declarative configurations. + Short: "APISIX Declarative CLI", + Long: `A command line interface for configuring APISIX declaratively. -It can be used to dump, diff, sync configurations to API7 server. +It can be used to validate, dump, diff, and sync configurations with an APISIX instance. `, } cobra.OnInitialize(initConfig) @@ -66,7 +66,7 @@ func initConfig() { viper.AddConfigPath("$HOME/") err := viper.ReadInConfig() if err != nil { - color.Red("Fatal to read config file, please run `adc configure` to configure the client first.") + color.Red("Failed to read configuration file, please run `adc configure` first to configure ADC.") return } @@ -74,7 +74,7 @@ func initConfig() { rootConfig.Token = viper.GetString("token") cluser := apisix.NewCluster(context.Background(), rootConfig.Server, rootConfig.Token) if err != nil { - color.RedString("Fatal to create cluster: %v", err) + color.RedString("Failed to create a new cluster: %v", err) return } rootConfig.APISIXCluster = cluser diff --git a/cmd/sync.go b/cmd/sync.go index d954e00..a562d97 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -20,8 +20,8 @@ import ( func newSyncCmd() *cobra.Command { cmd := &cobra.Command{ Use: "sync", - Short: "Sync the configurations from local to API7", - Long: `The sync command can be used to sync the configurations from local to API7.`, + Short: "Sync local configuration to APISIX", + Long: `Syncs the configuration in adc.yaml (or other provided file) to APISIX.`, RunE: func(cmd *cobra.Command, args []string) error { checkConfig() @@ -39,31 +39,31 @@ func newSyncCmd() *cobra.Command { func sync(cmd *cobra.Command, dryRun bool) error { file, err := cmd.Flags().GetString("file") if err != nil { - color.Red("Get file path failed: %v", err) + color.Red("Failed to get the configuration file: %v", err) return err } config, err := common.GetContentFromFile(file) if err != nil { - color.Red("Get file content failed: %v", err) + color.Red("Failed to read configuration file: %v", err) return err } remoteConfig, err := common.GetContentFromRemote(rootConfig.APISIXCluster) if err != nil { - color.Red("Failed to get remote config: %v", err) + color.Red("Failed to get remote configuration: %v", err) return err } d, err := differ.NewDiffer(config, remoteConfig) if err != nil { - color.Red("Failed to create differ: %v", err) + color.Red("Failed to create a Differ object: %v", err) return err } events, err := d.Diff() if err != nil { - color.Red("Failed to diff: %v", err) + color.Red("Failed to compare local and remote configuration: %v", err) return err } @@ -84,14 +84,14 @@ func sync(cmd *cobra.Command, dryRun bool) error { str, err := event.Output() if err != nil { - color.Red("Failed to get output: %v", err) + color.Red("Failed to get output of the event: %v", err) return err } if !dryRun { err = event.Apply(rootConfig.APISIXCluster) if err != nil { - color.Red("Failed to apply: %v", err) + color.Red("Failed to apply configuration: %v", err) return err } time.Sleep(100 * time.Millisecond) diff --git a/cmd/utils.go b/cmd/utils.go index 0d96c3e..83c8ca7 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -8,7 +8,7 @@ import ( func checkConfig() { if rootConfig.Server == "" || rootConfig.Token == "" { - color.Yellow("adc hasn't been configured, you can use `adc configure` to configure adc") + color.Yellow("ADC isn't configured, run `adc configure` to configure ADC.") os.Exit(0) } } diff --git a/cmd/validate.go b/cmd/validate.go index 9768ee1..cb3dd31 100644 --- a/cmd/validate.go +++ b/cmd/validate.go @@ -20,28 +20,28 @@ import ( func newValidateCmd() *cobra.Command { cmd := &cobra.Command{ Use: "validate", - Short: "Validate the configurations", - Long: `The validate command can be used to validate the configurations.`, + Short: "Validate the provided configuration file", + Long: `Validates the provided configuration file with the connected APISIX instance.`, RunE: func(cmd *cobra.Command, args []string) error { checkConfig() file, err := cmd.Flags().GetString("file") if err != nil { - color.Red("Get file path failed: %v", err) + color.Red("Failed to get file path: %v", err) return err } if file == "" { - color.Red("Input path is empty. Example: adc validate -f config.yaml") + color.Red("File path is empty. Please specify a file path: adc validate -f config.yaml") return nil } d, err := common.GetContentFromFile(file) if err != nil { - color.Red("Get file content failed: %v", err) + color.Red("Failed to read configuration file: %v", err) return err } - msg := fmt.Sprintf("Get file content success: config name: %v, version: %v", d.Name, d.Version) + msg := fmt.Sprintf("Read configuration file successfully: config name: %v, version: %v", d.Name, d.Version) changed := false if len(d.Routes) > 0 { msg += fmt.Sprintf(", routes: %v", len(d.Routes)) @@ -84,7 +84,7 @@ func newValidateCmd() *cobra.Command { err = validateContent(d) if err != nil { - color.Red("Command failed: %v", err) + color.Red("Failed to validate configuration file: %v", err) return err } return nil @@ -111,7 +111,7 @@ func validateContent(c *types.Configuration) error { color.Red(err.Error()) } } else { - color.Green("Validate file content success") + color.Green("Successfully validated configuration file!") } return nil } diff --git a/cmd/version.go b/cmd/version.go index 06eb608..50a6f04 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -14,10 +14,10 @@ var ( func newVersionCmd() *cobra.Command { cmd := &cobra.Command{ Use: "version", - Short: "Print the version of adc", - Long: `The version command can be used to print the version of adc.`, + Short: "Print the version of ADC", + Long: `Prints the version of ADC. See https://github.com/api7/adc for details on how to update.`, Run: func(cmd *cobra.Command, args []string) { - color.Green("adc version: %s - %s\n", VERSION, GitRevision) + color.Green("ADC version: %s - %s\n", VERSION, GitRevision) }, } diff --git a/test/cli/suites-consumer-group/validate.go b/test/cli/suites-consumer-group/validate.go index 263c2a2..060041f 100644 --- a/test/cli/suites-consumer-group/validate.go +++ b/test/cli/suites-consumer-group/validate.go @@ -13,7 +13,7 @@ var _ = ginkgo.Describe("`adc validate` consumer group tests", func() { ginkgo.It("should validate consumer group schema", func() { validateOutput, err := s.Validate("suites-consumer-group/testdata/test.yaml") gomega.Expect(err).To(gomega.BeNil()) - gomega.Expect(validateOutput).To(gomega.Equal("Get file content success: config name: , version: , consumers: 1, consumer_groups: 1.\nValidate file content success\n")) + gomega.Expect(validateOutput).To(gomega.Equal("Read configuration file successfully: config name: , version: , consumers: 1, consumer_groups: 1.\nSuccessfully validated configuration file!\n")) }) }) }) diff --git a/test/cli/suites-consumer/validate.go b/test/cli/suites-consumer/validate.go index 25befed..578ad27 100644 --- a/test/cli/suites-consumer/validate.go +++ b/test/cli/suites-consumer/validate.go @@ -13,7 +13,7 @@ var _ = ginkgo.Describe("`adc validate` consumer tests", func() { ginkgo.It("should validate consumer schema", func() { validateOutput, err := s.Validate("suites-consumer/testdata/test.yaml") gomega.Expect(err).To(gomega.BeNil()) - gomega.Expect(validateOutput).To(gomega.Equal("Get file content success: config name: , version: , consumers: 1.\nValidate file content success\n")) + gomega.Expect(validateOutput).To(gomega.Equal("Read configuration file successfully: config name: , version: , consumers: 1.\nSuccessfully validated configuration file!\n")) }) }) }) diff --git a/test/cli/suites-global-rule/validate.go b/test/cli/suites-global-rule/validate.go index 0f6c11e..58a2170 100644 --- a/test/cli/suites-global-rule/validate.go +++ b/test/cli/suites-global-rule/validate.go @@ -13,7 +13,7 @@ var _ = ginkgo.Describe("`adc validate` global rule tests", func() { ginkgo.It("should validate global rule schema", func() { validateOutput, err := s.Validate("suites-global-rule/testdata/test.yaml") gomega.Expect(err).To(gomega.BeNil()) - gomega.Expect(validateOutput).To(gomega.Equal("Get file content success: config name: , version: , global_rules: 1.\nValidate file content success\n")) + gomega.Expect(validateOutput).To(gomega.Equal("Read configuration file successfully: config name: , version: , global_rules: 1.\nSuccessfully validated configuration file!\n")) }) }) }) diff --git a/test/cli/suites-plugin-config/validate.go b/test/cli/suites-plugin-config/validate.go index 96a39b6..d3b2c5c 100644 --- a/test/cli/suites-plugin-config/validate.go +++ b/test/cli/suites-plugin-config/validate.go @@ -13,7 +13,7 @@ var _ = ginkgo.Describe("`adc validate` plugin config tests", func() { ginkgo.It("should validate plugin config schema", func() { validateOutput, err := s.Validate("suites-plugin-config/testdata/test.yaml") gomega.Expect(err).To(gomega.BeNil()) - gomega.Expect(validateOutput).To(gomega.Equal("Get file content success: config name: , version: , plugin_configs: 1.\nValidate file content success\n")) + gomega.Expect(validateOutput).To(gomega.Equal("Read configuration file successfully: config name: , version: , plugin_configs: 1.\nSuccessfully validated configuration file!\n")) }) }) }) diff --git a/test/cli/suites/ping.go b/test/cli/suites/ping.go index 8deaa54..2ca7892 100644 --- a/test/cli/suites/ping.go +++ b/test/cli/suites/ping.go @@ -13,7 +13,7 @@ var _ = ginkgo.Describe("`adc ping` tests", func() { ginkgo.It("should connect to APISIX", func() { output, err := s.Ping() gomega.Expect(err).To(gomega.BeNil()) - gomega.Expect(output).To(gomega.Equal("Successfully connected to APISIX\n")) + gomega.Expect(output).To(gomega.Equal("Connected to APISIX successfully!\n")) }) }) }) diff --git a/test/cli/suites/validate.go b/test/cli/suites/validate.go index 203e416..d8a2692 100644 --- a/test/cli/suites/validate.go +++ b/test/cli/suites/validate.go @@ -13,7 +13,7 @@ var _ = ginkgo.Describe("`adc validate` tests", func() { ginkgo.It("should validate schema", func() { validateOutput, err := s.Validate("testdata/test.yaml") gomega.Expect(err).To(gomega.BeNil()) - gomega.Expect(validateOutput).To(gomega.Equal("Get file content success: config name: test, version: 1.0.0, routes: 2, services: 2.\nValidate file content success\n")) + gomega.Expect(validateOutput).To(gomega.Equal("Read configuration file successfully: config name: test, version: 1.0.0, routes: 2, services: 2.\nSuccessfully validated configuration file!\n")) }) }) })