diff --git a/cmd/fleetctl/api.go b/cmd/fleetctl/api.go index 91460ea19a..9c4bd9a2c9 100644 --- a/cmd/fleetctl/api.go +++ b/cmd/fleetctl/api.go @@ -6,7 +6,7 @@ import ( "github.com/fleetdm/fleet/server/service" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) func unauthenticatedClientFromCLI(c *cli.Context) (*service.Client, error) { diff --git a/cmd/fleetctl/apply.go b/cmd/fleetctl/apply.go index 92c8378226..2f49b6f388 100644 --- a/cmd/fleetctl/apply.go +++ b/cmd/fleetctl/apply.go @@ -10,7 +10,7 @@ import ( "github.com/fleetdm/fleet/server/kolide" "github.com/ghodss/yaml" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) var ( @@ -114,18 +114,18 @@ func specGroupFromBytes(b []byte) (*specGroup, error) { return specs, nil } -func applyCommand() cli.Command { +func applyCommand() *cli.Command { var ( flFilename string ) - return cli.Command{ + return &cli.Command{ Name: "apply", Usage: "Apply files to declaratively manage osquery configurations", UsageText: `fleetctl apply [options]`, Flags: []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "f", - EnvVar: "FILENAME", + EnvVars: []string{"FILENAME"}, Value: "", Destination: &flFilename, Usage: "A file to apply", diff --git a/cmd/fleetctl/config.go b/cmd/fleetctl/config.go index b756210353..014c5b30dc 100644 --- a/cmd/fleetctl/config.go +++ b/cmd/fleetctl/config.go @@ -9,7 +9,7 @@ import ( "github.com/ghodss/yaml" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) const ( @@ -35,20 +35,20 @@ func configFlag() cli.Flag { homeDir = "~" } defaultConfigPath := filepath.Join(homeDir, ".fleet", "config") - return cli.StringFlag{ - Name: "config", - Value: defaultConfigPath, - EnvVar: "CONFIG", - Usage: "Path to the fleetctl config file", + return &cli.StringFlag{ + Name: "config", + Value: defaultConfigPath, + EnvVars: []string{"CONFIG"}, + Usage: "Path to the fleetctl config file", } } func contextFlag() cli.Flag { - return cli.StringFlag{ - Name: "context", - Value: "default", - EnvVar: "CONTEXT", - Usage: "Name of fleetctl config context to use", + return &cli.StringFlag{ + Name: "context", + Value: "default", + EnvVars: []string{"CONTEXT"}, + Usage: "Name of fleetctl config context to use", } } @@ -175,7 +175,7 @@ func setConfigValue(configPath, context, key, value string) error { return nil } -func configSetCommand() cli.Command { +func configSetCommand() *cli.Command { var ( flAddress string flEmail string @@ -184,50 +184,50 @@ func configSetCommand() cli.Command { flRootCA string flURLPrefix string ) - return cli.Command{ + return &cli.Command{ Name: "set", Usage: "Set config options", UsageText: `fleetctl config set [options]`, Flags: []cli.Flag{ configFlag(), contextFlag(), - cli.StringFlag{ + &cli.StringFlag{ Name: "address", - EnvVar: "ADDRESS", + EnvVars: []string{"ADDRESS"}, Value: "", Destination: &flAddress, Usage: "Address of the Fleet server", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "email", - EnvVar: "EMAIL", + EnvVars: []string{"EMAIL"}, Value: "", Destination: &flEmail, Usage: "Email to use when connecting to the Fleet server", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "token", - EnvVar: "TOKEN", + EnvVars: []string{"TOKEN"}, Value: "", Destination: &flToken, Usage: "Fleet API token", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "tls-skip-verify", - EnvVar: "INSECURE", + EnvVars: []string{"INSECURE"}, Destination: &flTLSSkipVerify, Usage: "Skip TLS certificate validation", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "rootca", - EnvVar: "ROOTCA", + EnvVars: []string{"ROOTCA"}, Value: "", Destination: &flRootCA, Usage: "Specify RootCA chain used to communicate with fleet", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "url-prefix", - EnvVar: "URL_PREFIX", + EnvVars: []string{"URL_PREFIX"}, Value: "", Destination: &flURLPrefix, Usage: "Specify URL Prefix to use with Fleet server (copy from server configuration)", @@ -295,8 +295,8 @@ func configSetCommand() cli.Command { } } -func configGetCommand() cli.Command { - return cli.Command{ +func configGetCommand() *cli.Command { + return &cli.Command{ Name: "get", Usage: "Get a config option", UsageText: `fleetctl config get [options]`, @@ -305,11 +305,11 @@ func configGetCommand() cli.Command { contextFlag(), }, Action: func(c *cli.Context) error { - if len(c.Args()) != 1 { + if c.Args().Len() != 1 { return cli.ShowCommandHelp(c, "get") } - key := c.Args()[0] + key := c.Args().Get(0) // validate key switch key { diff --git a/cmd/fleetctl/convert.go b/cmd/fleetctl/convert.go index 1d059b8b23..16a43541e9 100644 --- a/cmd/fleetctl/convert.go +++ b/cmd/fleetctl/convert.go @@ -12,7 +12,7 @@ import ( "github.com/fleetdm/fleet/server/kolide" "github.com/ghodss/yaml" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) func specGroupFromPack(name string, inputPack kolide.PermissivePackContent) (*specGroup, error) { @@ -66,20 +66,20 @@ func specGroupFromPack(name string, inputPack kolide.PermissivePackContent) (*sp return specs, nil } -func convertCommand() cli.Command { +func convertCommand() *cli.Command { var ( flFilename string ) - return cli.Command{ + return &cli.Command{ Name: "convert", Usage: "Convert osquery packs into decomposed fleet configs", UsageText: `fleetctl convert [options]`, Flags: []cli.Flag{ configFlag(), contextFlag(), - cli.StringFlag{ + &cli.StringFlag{ Name: "f", - EnvVar: "FILENAME", + EnvVars: []string{"FILENAME"}, Value: "", Destination: &flFilename, Usage: "A file to apply", diff --git a/cmd/fleetctl/debug.go b/cmd/fleetctl/debug.go index 115a7325b6..52585c5054 100644 --- a/cmd/fleetctl/debug.go +++ b/cmd/fleetctl/debug.go @@ -10,11 +10,11 @@ import ( "time" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) -func debugCommand() cli.Command { - return cli.Command{ +func debugCommand() *cli.Command { + return &cli.Command{ Name: "debug", Usage: "Tools for debugging Fleet", Flags: []cli.Flag{ @@ -22,7 +22,7 @@ func debugCommand() cli.Command { contextFlag(), debugFlag(), }, - Subcommands: []cli.Command{ + Subcommands: []*cli.Command{ debugProfileCommand(), debugCmdlineCommand(), debugHeapCommand(), @@ -46,8 +46,8 @@ func outfileName(name string) string { return fmt.Sprintf("fleet-%s-%s", name, time.Now().Format(time.RFC3339)) } -func debugProfileCommand() cli.Command { - return cli.Command{ +func debugProfileCommand() *cli.Command { + return &cli.Command{ Name: "profile", Usage: "Record a CPU profile from the Fleet server.", UsageText: "Record a 30-second CPU profile. The output can be analyzed with go tool pprof.", @@ -90,8 +90,8 @@ func joinCmdline(cmdline string) string { return fmt.Sprintf("[%s]", strings.Join(tokens, ", ")) } -func debugCmdlineCommand() cli.Command { - return cli.Command{ +func debugCmdlineCommand() *cli.Command { + return &cli.Command{ Name: "cmdline", Usage: "Get the command line used to invoke the Fleet server.", Flags: []cli.Flag{ @@ -127,9 +127,9 @@ func debugCmdlineCommand() cli.Command { } } -func debugHeapCommand() cli.Command { +func debugHeapCommand() *cli.Command { name := "heap" - return cli.Command{ + return &cli.Command{ Name: name, Usage: "Report the allocated memory in the Fleet server.", UsageText: "Report the heap-allocated memory. The output can be analyzed with go tool pprof.", @@ -164,9 +164,9 @@ func debugHeapCommand() cli.Command { } } -func debugGoroutineCommand() cli.Command { +func debugGoroutineCommand() *cli.Command { name := "goroutine" - return cli.Command{ + return &cli.Command{ Name: name, Usage: "Get stack traces of all goroutines (threads) in the Fleet server.", UsageText: "Get stack traces of all current goroutines (threads). The output can be analyzed with go tool pprof.", @@ -201,9 +201,9 @@ func debugGoroutineCommand() cli.Command { } } -func debugTraceCommand() cli.Command { +func debugTraceCommand() *cli.Command { name := "trace" - return cli.Command{ + return &cli.Command{ Name: name, Usage: "Record an execution trace on the Fleet server.", UsageText: "Record a 1 second execution trace. The output can be analyzed with go tool trace.", @@ -238,8 +238,8 @@ func debugTraceCommand() cli.Command { } } -func debugArchiveCommand() cli.Command { - return cli.Command{ +func debugArchiveCommand() *cli.Command { + return &cli.Command{ Name: "archive", Usage: "Create an archive with the entire suite of debug profiles.", Flags: []cli.Flag{ diff --git a/cmd/fleetctl/delete.go b/cmd/fleetctl/delete.go index d5718641dc..363ad06a9d 100644 --- a/cmd/fleetctl/delete.go +++ b/cmd/fleetctl/delete.go @@ -6,21 +6,21 @@ import ( "github.com/fleetdm/fleet/server/service" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) -func deleteCommand() cli.Command { +func deleteCommand() *cli.Command { var ( flFilename string ) - return cli.Command{ + return &cli.Command{ Name: "delete", Usage: "Specify files to declaratively batch delete osquery configurations", UsageText: `fleetctl delete [options]`, Flags: []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "f", - EnvVar: "FILENAME", + EnvVars: []string{"FILENAME"}, Value: "", Destination: &flFilename, Usage: "A file to apply", diff --git a/cmd/fleetctl/flags.go b/cmd/fleetctl/flags.go index 70acb87969..af1bca89d8 100644 --- a/cmd/fleetctl/flags.go +++ b/cmd/fleetctl/flags.go @@ -1,6 +1,6 @@ package main -import "github.com/urfave/cli" +import "github.com/urfave/cli/v2" const ( outfileFlagName = "outfile" @@ -8,11 +8,11 @@ const ( ) func outfileFlag() cli.Flag { - return cli.StringFlag{ - Name: outfileFlagName, - Value: "", - EnvVar: "OUTFILE", - Usage: "Path to output file", + return &cli.StringFlag{ + Name: outfileFlagName, + Value: "", + EnvVars: []string{"OUTFILE"}, + Usage: "Path to output file", } } @@ -21,10 +21,10 @@ func getOutfile(c *cli.Context) string { } func debugFlag() cli.Flag { - return cli.BoolFlag{ - Name: debugFlagName, - EnvVar: "DEBUG", - Usage: "Enable debug http request logging", + return &cli.BoolFlag{ + Name: debugFlagName, + EnvVars: []string{"DEBUG"}, + Usage: "Enable debug http request logging", } } diff --git a/cmd/fleetctl/fleetctl.go b/cmd/fleetctl/fleetctl.go index 9b9110ca70..8c57f7ddb5 100644 --- a/cmd/fleetctl/fleetctl.go +++ b/cmd/fleetctl/fleetctl.go @@ -5,7 +5,7 @@ import ( "time" "github.com/kolide/kit/version" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) const ( @@ -25,7 +25,7 @@ func main() { version.PrintFull() } - app.Commands = []cli.Command{ + app.Commands = []*cli.Command{ applyCommand(), deleteCommand(), setupCommand(), @@ -33,10 +33,10 @@ func main() { logoutCommand(), queryCommand(), getCommand(), - cli.Command{ + &cli.Command{ Name: "config", Usage: "Modify Fleet server connection settings", - Subcommands: []cli.Command{ + Subcommands: []*cli.Command{ configSetCommand(), configGetCommand(), }, diff --git a/cmd/fleetctl/get.go b/cmd/fleetctl/get.go index cb061946f9..a183115890 100644 --- a/cmd/fleetctl/get.go +++ b/cmd/fleetctl/get.go @@ -11,7 +11,7 @@ import ( "github.com/ghodss/yaml" "github.com/olekukonko/tablewriter" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) const ( @@ -34,15 +34,15 @@ func defaultTable() *tablewriter.Table { return table } -func yamlFlag() cli.BoolFlag { - return cli.BoolFlag{ +func yamlFlag() cli.Flag { + return &cli.BoolFlag{ Name: yamlFlagName, Usage: "Output in yaml format", } } -func jsonFlag() cli.BoolFlag { - return cli.BoolFlag{ +func jsonFlag() cli.Flag { + return &cli.BoolFlag{ Name: jsonFlagName, Usage: "Output in JSON format", } @@ -201,11 +201,11 @@ func printConfig(c *cli.Context, config *kolide.AppConfigPayload) error { return err } -func getCommand() cli.Command { - return cli.Command{ +func getCommand() *cli.Command { + return &cli.Command{ Name: "get", Usage: "Get/list resources", - Subcommands: []cli.Command{ + Subcommands: []*cli.Command{ getQueriesCommand(), getPacksCommand(), getLabelsCommand(), @@ -219,8 +219,8 @@ func getCommand() cli.Command { } } -func getQueriesCommand() cli.Command { - return cli.Command{ +func getQueriesCommand() *cli.Command { + return &cli.Command{ Name: "queries", Aliases: []string{"query", "q"}, Usage: "List information about one or more queries", @@ -292,13 +292,13 @@ func getQueriesCommand() cli.Command { } } -func getPacksCommand() cli.Command { - return cli.Command{ +func getPacksCommand() *cli.Command { + return &cli.Command{ Name: "packs", Aliases: []string{"pack", "p"}, Usage: "List information about one or more packs", Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: withQueriesFlagName, Usage: "Output queries included in pack(s) too", }, @@ -412,8 +412,8 @@ func getPacksCommand() cli.Command { } } -func getLabelsCommand() cli.Command { - return cli.Command{ +func getLabelsCommand() *cli.Command { + return &cli.Command{ Name: "labels", Aliases: []string{"label", "l"}, Usage: "List information about one or more labels", @@ -484,8 +484,8 @@ func getLabelsCommand() cli.Command { } } -func getOptionsCommand() cli.Command { - return cli.Command{ +func getOptionsCommand() *cli.Command { + return &cli.Command{ Name: "options", Usage: "Retrieve the osquery configuration", Flags: []cli.Flag{ @@ -516,8 +516,8 @@ func getOptionsCommand() cli.Command { } } -func getEnrollSecretCommand() cli.Command { - return cli.Command{ +func getEnrollSecretCommand() *cli.Command { + return &cli.Command{ Name: "enroll_secret", Aliases: []string{"enroll_secrets", "enroll-secret", "enroll-secrets"}, Usage: "Retrieve the osquery enroll secrets", @@ -549,8 +549,8 @@ func getEnrollSecretCommand() cli.Command { } } -func getAppConfigCommand() cli.Command { - return cli.Command{ +func getAppConfigCommand() *cli.Command { + return &cli.Command{ Name: "config", Usage: "Retrieve the Fleet configuration", Flags: []cli.Flag{ @@ -581,8 +581,8 @@ func getAppConfigCommand() cli.Command { } } -func getHostsCommand() cli.Command { - return cli.Command{ +func getHostsCommand() *cli.Command { + return &cli.Command{ Name: "hosts", Aliases: []string{"host", "h"}, Usage: "List information about one or more hosts", @@ -656,12 +656,12 @@ func getHostsCommand() cli.Command { } } -func getCarvesCommand() cli.Command { - return cli.Command{ +func getCarvesCommand() *cli.Command { + return &cli.Command{ Name: "carves", Usage: "Retrieve the file carving sessions", Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: expiredFlagName, Usage: "Include expired carves", }, @@ -716,12 +716,12 @@ func getCarvesCommand() cli.Command { } } -func getCarveCommand() cli.Command { - return cli.Command{ +func getCarveCommand() *cli.Command { + return &cli.Command{ Name: "carve", Usage: "Retrieve details for a carve by ID", Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: stdoutFlagName, Usage: "Print carve contents to stdout", }, diff --git a/cmd/fleetctl/goquery.go b/cmd/fleetctl/goquery.go index ed5880edc7..515eddfa7d 100644 --- a/cmd/fleetctl/goquery.go +++ b/cmd/fleetctl/goquery.go @@ -11,7 +11,7 @@ import ( "github.com/fleetdm/fleet/server/kolide" "github.com/fleetdm/fleet/server/service" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) type activeQuery struct { @@ -110,8 +110,8 @@ func (c *goqueryClient) FetchResults(queryName string) (gqmodels.Rows, string, e return res.results, res.status, nil } -func goqueryCommand() cli.Command { - return cli.Command{ +func goqueryCommand() *cli.Command { + return &cli.Command{ Name: "goquery", Usage: "Start the goquery interface", Flags: []cli.Flag{ diff --git a/cmd/fleetctl/login.go b/cmd/fleetctl/login.go index 0c7582d1ac..7ff71e2c3b 100644 --- a/cmd/fleetctl/login.go +++ b/cmd/fleetctl/login.go @@ -6,16 +6,16 @@ import ( "github.com/fleetdm/fleet/server/service" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" "golang.org/x/crypto/ssh/terminal" ) -func loginCommand() cli.Command { +func loginCommand() *cli.Command { var ( flEmail string flPassword string ) - return cli.Command{ + return &cli.Command{ Name: "login", Usage: "Login to Fleet", UsageText: ` @@ -24,16 +24,16 @@ fleetctl login [options] Interactively prompts for email and password if not specified in the flags or environment variables. `, Flags: []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "email", - EnvVar: "EMAIL", + EnvVars: []string{"EMAIL"}, Value: "", Destination: &flEmail, Usage: "Email or username to use to log in", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "password", - EnvVar: "PASSWORD", + EnvVars: []string{"PASSWORD"}, Value: "", Destination: &flPassword, Usage: "Password to use to log in (recommended to use interactive entry)", diff --git a/cmd/fleetctl/logout.go b/cmd/fleetctl/logout.go index 8df90ab710..142409e899 100644 --- a/cmd/fleetctl/logout.go +++ b/cmd/fleetctl/logout.go @@ -4,11 +4,11 @@ import ( "fmt" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) -func logoutCommand() cli.Command { - return cli.Command{ +func logoutCommand() *cli.Command { + return &cli.Command{ Name: "logout", Usage: "Log out of Fleet", UsageText: `fleetctl logout [options]`, diff --git a/cmd/fleetctl/preview.go b/cmd/fleetctl/preview.go index ec71696be1..a6c5d45dc9 100644 --- a/cmd/fleetctl/preview.go +++ b/cmd/fleetctl/preview.go @@ -17,21 +17,21 @@ import ( "github.com/cenkalti/backoff/v4" "github.com/fleetdm/fleet/server/service" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) const ( downloadUrl = "https://github.com/fleetdm/osquery-in-a-box/archive/master.zip" ) -func previewCommand() cli.Command { - return cli.Command{ +func previewCommand() *cli.Command { + return &cli.Command{ Name: "preview", Usage: "Set up a preview deployment of the Fleet server", UsageText: `Set up a preview deployment of the Fleet server using Docker and docker-compose. Docker tools must be available in the environment. This command will create a directory fleet-preview in the current working directory. Configurations can be modified in that directory.`, - Subcommands: []cli.Command{}, + Subcommands: []*cli.Command{}, Flags: []cli.Flag{ configFlag(), contextFlag(), diff --git a/cmd/fleetctl/query.go b/cmd/fleetctl/query.go index e2c0933b33..8fa9116979 100644 --- a/cmd/fleetctl/query.go +++ b/cmd/fleetctl/query.go @@ -9,69 +9,69 @@ import ( "time" "github.com/briandowns/spinner" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) -func queryCommand() cli.Command { +func queryCommand() *cli.Command { var ( flHosts, flLabels, flQuery, flQueryName string flQuiet, flExit, flPretty bool flTimeout time.Duration ) - return cli.Command{ + return &cli.Command{ Name: "query", Usage: "Run a live query", UsageText: `fleetctl query [options]`, Flags: []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "hosts", - EnvVar: "HOSTS", + EnvVars: []string{"HOSTS"}, Value: "", Destination: &flHosts, Usage: "Comma separated hostnames to target", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "labels", - EnvVar: "LABELS", + EnvVars: []string{"LABELS"}, Value: "", Destination: &flLabels, Usage: "Comma separated label names to target", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "quiet", - EnvVar: "QUIET", + EnvVars: []string{"QUIET"}, Destination: &flQuiet, Usage: "Only print results (no status information)", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "exit", - EnvVar: "EXIT", + EnvVars: []string{"EXIT"}, Destination: &flExit, Usage: "Exit when 100% of online hosts have results returned", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "query", - EnvVar: "QUERY", + EnvVars: []string{"QUERY"}, Value: "", Destination: &flQuery, Usage: "Query to run", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "query-name", - EnvVar: "QUERYNAME", + EnvVars: []string{"QUERYNAME"}, Value: "", Destination: &flQueryName, Usage: "Name of saved query to run", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "pretty", - EnvVar: "PRETTY", + EnvVars: []string{"PRETTY"}, Destination: &flPretty, Usage: "Enable pretty-printing", }, - cli.DurationFlag{ + &cli.DurationFlag{ Name: "timeout", - EnvVar: "TIMEOUT", + EnvVars: []string{"TIMEOUT"}, Destination: &flTimeout, Usage: "How long to run query before exiting (10s, 1h, etc.)", }, diff --git a/cmd/fleetctl/setup.go b/cmd/fleetctl/setup.go index 209efad954..d69641731f 100644 --- a/cmd/fleetctl/setup.go +++ b/cmd/fleetctl/setup.go @@ -6,46 +6,46 @@ import ( "github.com/fleetdm/fleet/server/service" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" "golang.org/x/crypto/ssh/terminal" ) -func setupCommand() cli.Command { +func setupCommand() *cli.Command { var ( flEmail string flUsername string flPassword string flOrgName string ) - return cli.Command{ + return &cli.Command{ Name: "setup", Usage: "Set up a Fleet instance", UsageText: `fleetctl setup [options]`, Flags: []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "email", - EnvVar: "EMAIL", + EnvVars: []string{"EMAIL"}, Value: "", Destination: &flEmail, Usage: "Email of the admin user to create", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "username", - EnvVar: "USERNAME", + EnvVars: []string{"USERNAME"}, Value: "", Destination: &flUsername, Usage: "Username of the admin user to create", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "password", - EnvVar: "PASSWORD", + EnvVars: []string{"PASSWORD"}, Value: "", Destination: &flPassword, Usage: "Password for the admin user (recommended to use interactive entry)", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "org-name", - EnvVar: "ORG_NAME", + EnvVars: []string{"ORG_NAME"}, Value: "", Destination: &flOrgName, Usage: "Name of the organization", diff --git a/cmd/fleetctl/user.go b/cmd/fleetctl/user.go index 98a986f3cb..8a0fc422da 100644 --- a/cmd/fleetctl/user.go +++ b/cmd/fleetctl/user.go @@ -7,7 +7,7 @@ import ( "github.com/fleetdm/fleet/server/kolide" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" "golang.org/x/crypto/ssh/terminal" ) @@ -19,43 +19,43 @@ const ( ssoFlagName = "sso" ) -func userCommand() cli.Command { - return cli.Command{ +func userCommand() *cli.Command { + return &cli.Command{ Name: "user", Usage: "Manage Fleet users", - Subcommands: []cli.Command{ + Subcommands: []*cli.Command{ createUserCommand(), }, } } -func createUserCommand() cli.Command { - return cli.Command{ +func createUserCommand() *cli.Command { + return &cli.Command{ Name: "create", Usage: "Create a new user", UsageText: `This command will create a new user in Fleet. By default, the user will authenticate with a password and will not have admin privileges. If a password is required and not provided by flag, the command will prompt for password input through stdin.`, Flags: []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: usernameFlagName, Usage: "Username for new user (required)", Required: true, }, - cli.StringFlag{ + &cli.StringFlag{ Name: emailFlagName, Usage: "Email for new user (required)", Required: true, }, - cli.StringFlag{ + &cli.StringFlag{ Name: passwordFlagName, Usage: "Password for new user", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: adminFlagName, Usage: "Grant admin privileges to created user (default false)", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: ssoFlagName, Usage: "Enable user login via SSO (default false)", }, diff --git a/go.mod b/go.mod index d06517586e..0dc29cfbd3 100644 --- a/go.mod +++ b/go.mod @@ -48,6 +48,7 @@ require ( github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 github.com/russellhaering/gosaml2 v0.3.1 github.com/russellhaering/goxmldsig v1.1.0 + github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/spf13/afero v1.1.0 // indirect github.com/spf13/cast v1.2.0 github.com/spf13/cobra v0.0.2 @@ -55,7 +56,7 @@ require ( github.com/spf13/pflag v1.0.1 // indirect github.com/spf13/viper v1.0.2 github.com/stretchr/testify v1.6.1 - github.com/urfave/cli v1.22.4 + github.com/urfave/cli/v2 v2.3.0 github.com/ziutek/mymysql v1.5.4 // indirect go.opencensus.io v0.20.2 // indirect golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 @@ -66,5 +67,5 @@ require ( google.golang.org/grpc v1.19.0 gopkg.in/guregu/null.v3 v3.4.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3 - gopkg.in/yaml.v2 v2.2.2 + gopkg.in/yaml.v2 v2.2.3 ) diff --git a/go.sum b/go.sum index f2d3306812..e9425f3668 100644 --- a/go.sum +++ b/go.sum @@ -202,6 +202,8 @@ github.com/russellhaering/goxmldsig v1.1.0 h1:lK/zeJie2sqG52ZAlPNn1oBBqsIsEKypUU github.com/russellhaering/goxmldsig v1.1.0/go.mod h1:QK8GhXPB3+AfuCrfo0oRISa9NfzeCpWmxeGnqEpDF9o= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -226,8 +228,8 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA= -github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= @@ -320,6 +322,8 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=