Skip to content

Commit

Permalink
Revert "feat: support flag for token and hide token input"
Browse files Browse the repository at this point in the history
This reverts commit bf7a8be.

Signed-off-by: Navendu Pottekkat <navendu@apache.org>
  • Loading branch information
pottekkat committed Oct 23, 2023
1 parent bf7a8be commit 78affcd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
17 changes: 4 additions & 13 deletions cmd/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 78affcd

Please sign in to comment.