From 78affcdaf0ac0333d809f123052632777ac4110f Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Mon, 23 Oct 2023 14:26:05 +0530 Subject: [PATCH] Revert "feat: support flag for token and hide token input" This reverts commit bf7a8be141c6507dc63bd4f28c54fb7fa4165012. Signed-off-by: Navendu Pottekkat --- cmd/configure.go | 17 ++++------------- go.mod | 1 - go.sum | 2 -- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/cmd/configure.go b/cmd/configure.go index 6bf6b89..c4b9163 100644 --- a/cmd/configure.go +++ b/cmd/configure.go @@ -17,7 +17,6 @@ import ( "github.com/fatih/color" "github.com/spf13/cobra" "github.com/spf13/viper" - "golang.org/x/term" ) // newConfigureCmd represents the configure command @@ -33,9 +32,8 @@ func newConfigureCmd() *cobra.Command { cmd.Flags().BoolP("overwrite", "f", false, "overwrite existed configuration file") - cmd.Flags().StringP("address", "a", "", "APISIX server address") + cmd.Flags().StringP("address", "a", "", "apisix server address") - cmd.Flags().StringP("token", "t", "", "APISIX token") cmd.Flags().String("capath", "", "ca path for mtls connection") cmd.Flags().String("cert", "", "certificate for mtls connection") cmd.Flags().String("cert-key", "", "certificate key for mtls connection") @@ -58,13 +56,7 @@ func saveConfiguration(cmd *cobra.Command) error { rootConfig.Server, err = cmd.Flags().GetString("address") if err != nil { - color.Red("Failed to get APISIX address: %v", err) - return err - } - - rootConfig.Token, err = cmd.Flags().GetString("token") - if err != nil { - color.Red("Failed to get token: %v", err) + color.Red("Failed to get apisix address: %v", err) return err } @@ -176,12 +168,11 @@ func saveConfiguration(cmd *cobra.Command) error { if rootConfig.Token == "" || overwrite { fmt.Println("Please enter the APISIX token: ") - byteToken, err := term.ReadPassword(0) + token, err := reader.ReadString('\n') if err != nil { return err } - rootConfig.Token = strings.TrimSpace(string(byteToken)) - fmt.Println("Token set successfully!") + rootConfig.Token = strings.TrimSpace(string(token)) } // use viper to save the configuration diff --git a/go.mod b/go.mod index aa980b0..74a7954 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/stretchr/testify v1.8.4 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.26.0 - golang.org/x/term v0.13.0 sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index 692637d..cea15de 100644 --- a/go.sum +++ b/go.sum @@ -496,8 +496,6 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=