Skip to content

Commit

Permalink
refactor auth method args
Browse files Browse the repository at this point in the history
use string slice flag instead

Signed-off-by: Daniel Chaplin <black.danek@gmail.com>
  • Loading branch information
Strangerxxx committed Apr 25, 2023
1 parent fcfa6a4 commit b7b8db5
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
7 changes: 6 additions & 1 deletion internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"time"

cli "github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"

"github.com/mvisonneau/vac/internal/cmd"
)
Expand Down Expand Up @@ -65,6 +65,11 @@ func NewApp(version string, start time.Time) (app *cli.App) {
Usage: "method `name` (token, oidc, write)",
Value: "token",
},
&cli.StringSliceFlag{
Name: "auth-method-args",
EnvVars: []string{"VAC_AUTH_METHOD_ARGS"},
Usage: "method `args` `=`(equals sign) delimited (listenaddress=0.0.0.0, port=8250)",
},
&cli.StringFlag{
Name: "auth-path",
EnvVars: []string{"VAC_AUTH_PATH"},
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

log "github.com/sirupsen/logrus"
cli "github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"

"github.com/mvisonneau/vac/pkg/client"
"github.com/mvisonneau/vac/pkg/state"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/olekukonko/tablewriter"
cli "github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"
"github.com/xeonx/timeago"

"github.com/mvisonneau/vac/pkg/client"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"github.com/ktr0731/go-fuzzyfinder"
log "github.com/sirupsen/logrus"
cli "github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"

"github.com/mvisonneau/vac/pkg/client"
"github.com/mvisonneau/vac/pkg/state"
Expand Down
9 changes: 2 additions & 7 deletions internal/cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"fmt"
"strings"
"time"

kvbuilder "github.com/hashicorp/go-secure-stdlib/kv-builder"
Expand Down Expand Up @@ -74,15 +73,11 @@ func configure(ctx *cli.Context) (*Config, error) {

var authMethodArgs []string

for _, v := range ctx.Args().Slice() {
if strings.Contains(v, "=") {
authMethodArgs = append(authMethodArgs, v)
}
}
authMethodArgs = ctx.StringSlice("auth-method-args")

authMethodConfig, err := parseArgsDataString(authMethodArgs)
if err != nil {
return nil, fmt.Errorf("error parsing configuration: %s", err)
return nil, fmt.Errorf("error parsing auth method args: %s", err)
}

return &Config{
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
cli "github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"
)

func NewTestContext() (ctx *cli.Context, flags, globalFlags *flag.FlagSet) {
Expand Down

0 comments on commit b7b8db5

Please sign in to comment.