fix: downgrade urfave/cli to v1 to enable more flexible parsing (#154)
This commit is contained in:
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"github.com/influxdata/influx-cli/v2/clients/v1_auth"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// getAuthLookupFlags returns flags used for authorization, requiring either an ID or Username,
|
||||
@ -23,12 +23,12 @@ func getAuthLookupFlags(params *v1_auth.AuthLookupParams) []cli.Flag {
|
||||
}
|
||||
}
|
||||
|
||||
func newV1AuthCommand() *cli.Command {
|
||||
return &cli.Command{
|
||||
func newV1AuthCommand() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "auth",
|
||||
Usage: "Authorization management commands for v1 APIs",
|
||||
Aliases: []string{"authorization"},
|
||||
Subcommands: []*cli.Command{
|
||||
Subcommands: []cli.Command{
|
||||
newCreateV1AuthCmd(),
|
||||
newRemoveV1AuthCmd(),
|
||||
newListV1AuthCmd(),
|
||||
@ -39,14 +39,13 @@ func newV1AuthCommand() *cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func newCreateV1AuthCmd() *cli.Command {
|
||||
func newCreateV1AuthCmd() cli.Command {
|
||||
var params v1_auth.CreateParams
|
||||
flags := append(commonFlags(), getOrgFlags(¶ms.OrgParams)...)
|
||||
flags = append(flags,
|
||||
&cli.StringFlag{
|
||||
Name: "description",
|
||||
cli.StringFlag{
|
||||
Name: "description, d",
|
||||
Usage: "Token description",
|
||||
Aliases: []string{"d"},
|
||||
Destination: ¶ms.Desc,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
@ -74,7 +73,7 @@ func newCreateV1AuthCmd() *cli.Command {
|
||||
Usage: "The bucket id",
|
||||
},
|
||||
)
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "create",
|
||||
Usage: "Create authorization",
|
||||
Flags: flags,
|
||||
@ -89,15 +88,15 @@ func newCreateV1AuthCmd() *cli.Command {
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.Create(ctx.Context, ¶ms)
|
||||
return client.Create(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newRemoveV1AuthCmd() *cli.Command {
|
||||
func newRemoveV1AuthCmd() cli.Command {
|
||||
var params v1_auth.RemoveParams
|
||||
flags := append(commonFlags(), getAuthLookupFlags(¶ms.AuthLookupParams)...)
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "delete",
|
||||
Usage: "Delete authorization",
|
||||
Flags: flags,
|
||||
@ -114,20 +113,19 @@ func newRemoveV1AuthCmd() *cli.Command {
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.Remove(ctx.Context, ¶ms)
|
||||
return client.Remove(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newListV1AuthCmd() *cli.Command {
|
||||
func newListV1AuthCmd() cli.Command {
|
||||
var params v1_auth.ListParams
|
||||
flags := append(commonFlags(), getOrgFlags(¶ms.OrgParams)...)
|
||||
flags = append(flags, getAuthLookupFlags(¶ms.AuthLookupParams)...)
|
||||
flags = append(flags,
|
||||
&cli.StringFlag{
|
||||
Name: "user",
|
||||
Name: "user, u",
|
||||
Usage: "The user",
|
||||
Aliases: []string{"u"},
|
||||
Destination: ¶ms.User,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
@ -136,7 +134,7 @@ func newListV1AuthCmd() *cli.Command {
|
||||
Destination: ¶ms.UserID,
|
||||
},
|
||||
)
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "list",
|
||||
Usage: "List authorizations",
|
||||
Aliases: []string{"ls", "find"},
|
||||
@ -150,15 +148,15 @@ func newListV1AuthCmd() *cli.Command {
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.List(ctx.Context, ¶ms)
|
||||
return client.List(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newSetActiveV1AuthCmd() *cli.Command {
|
||||
func newSetActiveV1AuthCmd() cli.Command {
|
||||
var params v1_auth.ActiveParams
|
||||
flags := append(commonFlags(), getAuthLookupFlags(¶ms.AuthLookupParams)...)
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "set-active",
|
||||
Usage: "Change the status of an authorization to active",
|
||||
Flags: flags,
|
||||
@ -175,15 +173,15 @@ func newSetActiveV1AuthCmd() *cli.Command {
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.SetActive(ctx.Context, ¶ms, true)
|
||||
return client.SetActive(getContext(ctx), ¶ms, true)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newSetInactiveV1AuthCmd() *cli.Command {
|
||||
func newSetInactiveV1AuthCmd() cli.Command {
|
||||
var params v1_auth.ActiveParams
|
||||
flags := append(commonFlags(), getAuthLookupFlags(¶ms.AuthLookupParams)...)
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "set-inactive",
|
||||
Usage: "Change the status of an authorization to inactive",
|
||||
Flags: flags,
|
||||
@ -200,12 +198,12 @@ func newSetInactiveV1AuthCmd() *cli.Command {
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.SetActive(ctx.Context, ¶ms, false)
|
||||
return client.SetActive(getContext(ctx), ¶ms, false)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newSetPswdV1AuthCmd() *cli.Command {
|
||||
func newSetPswdV1AuthCmd() cli.Command {
|
||||
var params v1_auth.SetPasswordParams
|
||||
flags := append(coreFlags(), commonTokenFlag())
|
||||
flags = append(flags, getAuthLookupFlags(¶ms.AuthLookupParams)...)
|
||||
@ -216,7 +214,7 @@ func newSetPswdV1AuthCmd() *cli.Command {
|
||||
Destination: ¶ms.Password,
|
||||
},
|
||||
)
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "set-password",
|
||||
Usage: "Set a password for an existing authorization",
|
||||
Flags: flags,
|
||||
@ -227,7 +225,7 @@ func newSetPswdV1AuthCmd() *cli.Command {
|
||||
CLI: getCLI(ctx),
|
||||
LegacyAuthorizationsApi: api.LegacyAuthorizationsApi,
|
||||
}
|
||||
return client.SetPassword(ctx.Context, ¶ms)
|
||||
return client.SetPassword(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user