From e944dd1fdd217eb79ea8bd8202ad08325fedc70f Mon Sep 17 00:00:00 2001 From: ecrupper Date: Fri, 6 Sep 2024 09:48:15 -0500 Subject: [PATCH] feat: user resource management --- action/pipeline/exec.go | 2 +- action/pipeline/validate.go | 5 +- action/user/update.go | 111 ++++++++++++++++++++++++++++++++ action/user/update_test.go | 120 +++++++++++++++++++++++++++++++++++ action/user/user.go | 51 +++++++++++++++ action/user/view.go | 33 ++++++++++ action/user/view_test.go | 92 +++++++++++++++++++++++++++ cmd/vela-cli/update.go | 6 ++ cmd/vela-cli/view.go | 6 ++ command/pipeline/exec.go | 8 +-- command/pipeline/validate.go | 6 +- command/user/update.go | 109 +++++++++++++++++++++++++++++++ command/user/update_test.go | 70 ++++++++++++++++++++ command/user/view.go | 80 +++++++++++++++++++++++ command/user/view_test.go | 68 ++++++++++++++++++++ go.mod | 21 +++--- go.sum | 42 ++++++------ internal/internal.go | 7 ++ 18 files changed, 791 insertions(+), 46 deletions(-) create mode 100644 action/user/update.go create mode 100644 action/user/update_test.go create mode 100644 action/user/user.go create mode 100644 action/user/view.go create mode 100644 action/user/view_test.go create mode 100644 command/user/update.go create mode 100644 command/user/update_test.go create mode 100644 command/user/view.go create mode 100644 command/user/view_test.go diff --git a/action/pipeline/exec.go b/action/pipeline/exec.go index 08d1a3d7..3385d6cd 100644 --- a/action/pipeline/exec.go +++ b/action/pipeline/exec.go @@ -109,7 +109,7 @@ func (c *Config) Exec(client compiler.Engine) error { WithLocal(true). WithRepo(r). WithLocalTemplates(c.TemplateFiles). - Compile(path) + Compile(context.Background(), path) if err != nil { return err } diff --git a/action/pipeline/validate.go b/action/pipeline/validate.go index 11ad1fb5..433e5c1f 100644 --- a/action/pipeline/validate.go +++ b/action/pipeline/validate.go @@ -3,6 +3,7 @@ package pipeline import ( + "context" "fmt" "os" "path/filepath" @@ -150,7 +151,7 @@ func (c *Config) ValidateLocal(client compiler.Engine) error { } // compile the object into a pipeline with ruledata - p, _, err = client.CompileLite(path, ruleData, false) + p, _, err = client.CompileLite(context.Background(), path, ruleData, false) if err != nil { return err } @@ -158,7 +159,7 @@ func (c *Config) ValidateLocal(client compiler.Engine) error { logrus.Debugf("compiling pipeline") // compile the object into a pipeline without ruledata - p, _, err = client.CompileLite(path, nil, false) + p, _, err = client.CompileLite(context.Background(), path, nil, false) if err != nil { return err } diff --git a/action/user/update.go b/action/user/update.go new file mode 100644 index 00000000..1e1789aa --- /dev/null +++ b/action/user/update.go @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: Apache-2.0 + +package user + +import ( + "fmt" + "slices" + "strings" + + "github.com/sirupsen/logrus" + + "github.com/go-vela/sdk-go/vela" + api "github.com/go-vela/server/api/types" +) + +// Update modifies a dashboard based off the provided configuration. +func (c *Config) Update(client *vela.Client) error { + logrus.Debug("executing update for dashboard configuration") + + var ( + user *api.User + err error + ) + + if len(c.Name) > 0 { + user, _, err = client.User.Get(c.Name) + } else { + user, _, err = client.User.GetCurrent() + } + + if err != nil { + return err + } + + // drop specified dashboards from the user + if len(c.DropDashboards) > 0 { + newDashboards := []string{} + + for _, d := range user.GetDashboards() { + if !slices.Contains(c.DropDashboards, d) { + newDashboards = append(newDashboards, d) + } + } + + user.SetDashboards(newDashboards) + } + + // add specified repositories to the dashboard + if len(c.AddDashboards) > 0 { + dashboards := user.GetDashboards() + + for _, d := range c.AddDashboards { + _, _, err := client.Dashboard.Get(d) + if err != nil { + return fmt.Errorf("unable to get dashboard %s: %w", d, err) + } + + dashboards = append(dashboards, d) + } + + user.SetDashboards(dashboards) + } + + // drop specified favorites from the user + if len(c.DropFavorites) > 0 { + newFavorites := []string{} + + for _, f := range user.GetFavorites() { + if !slices.Contains(c.DropFavorites, f) { + newFavorites = append(newFavorites, f) + } + } + + user.SetFavorites(newFavorites) + } + + // add specified favorites to the user + if len(c.AddFavorites) > 0 { + favorites := user.GetFavorites() + + for _, f := range c.AddFavorites { + splitRepo := strings.Split(f, "/") + + if len(splitRepo) != 2 { + return fmt.Errorf("invalid format for repository: %s (valid format: /)", f) + } + + _, _, err := client.Repo.Get(splitRepo[0], splitRepo[1]) + if err != nil { + return fmt.Errorf("unable to get repo %s: %w", f, err) + } + + favorites = append(favorites, f) + } + + user.SetFavorites(favorites) + } + + // send API call to modify the user + if len(c.Name) > 0 { + user, _, err = client.User.Update(c.Name, user) + } else { + user, _, err = client.User.UpdateCurrent(user) + } + + if err != nil { + return err + } + + return outputUser(user, c) +} diff --git a/action/user/update_test.go b/action/user/update_test.go new file mode 100644 index 00000000..83bf63e8 --- /dev/null +++ b/action/user/update_test.go @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: Apache-2.0 + +package user + +import ( + "net/http/httptest" + "testing" + + "github.com/go-vela/sdk-go/vela" + "github.com/go-vela/server/mock/server" +) + +func TestRepo_Config_Update(t *testing.T) { + // setup test server + s := httptest.NewServer(server.FakeHandler()) + + // create a vela client + client, err := vela.NewClient(s.URL, "vela", nil) + if err != nil { + t.Errorf("unable to create client: %v", err) + } + + // setup tests + tests := []struct { + failure bool + config *Config + }{ + { + failure: false, + config: &Config{ + Name: "octocat", + AddFavorites: []string{"foo/bar", "foo/baz"}, + AddDashboards: []string{"c8da1302-07d6-11ea-882f-4893bca275b8"}, + Output: "", + }, + }, + { + failure: false, + config: &Config{ + Name: "octocat", + DropFavorites: []string{"foo/bar", "foo/baz"}, + DropDashboards: []string{"c8da1302-07d6-11ea-882f-4893bca275b8"}, + Output: "dump", + }, + }, + { + failure: false, + config: &Config{ + AddFavorites: []string{"foo/bar", "foo/baz"}, + AddDashboards: []string{"c8da1302-07d6-11ea-882f-4893bca275b8"}, + Output: "", + }, + }, + { + failure: false, + config: &Config{ + DropFavorites: []string{"foo/bar", "foo/baz"}, + DropDashboards: []string{"c8da1302-07d6-11ea-882f-4893bca275b8"}, + Output: "dump", + }, + }, + { + failure: false, + config: &Config{ + AddFavorites: []string{"foo/bar", "foo/baz"}, + AddDashboards: []string{"c8da1302-07d6-11ea-882f-4893bca275b8"}, + Output: "json", + }, + }, + { + failure: false, + config: &Config{ + AddFavorites: []string{"foo/bar", "foo/baz"}, + AddDashboards: []string{"c8da1302-07d6-11ea-882f-4893bca275b8"}, + Output: "spew", + }, + }, + { + failure: false, + config: &Config{ + AddFavorites: []string{"foo/bar", "foo/baz"}, + AddDashboards: []string{"c8da1302-07d6-11ea-882f-4893bca275b8"}, + Output: "yaml", + }, + }, + { + failure: true, + config: &Config{ + AddFavorites: []string{"foo/bar", "not-found"}, + AddDashboards: []string{"c8da1302-07d6-11ea-882f-4893bca275b8"}, + Output: "", + }, + }, + { + failure: true, + config: &Config{ + AddFavorites: []string{"foo/bar"}, + AddDashboards: []string{"0"}, + Output: "", + }, + }, + } + + // run tests + for _, test := range tests { + err := test.config.Update(client) + + if test.failure { + if err == nil { + t.Errorf("Update should have returned err") + } + + continue + } + + if err != nil { + t.Errorf("Update returned err: %v", err) + } + } +} diff --git a/action/user/user.go b/action/user/user.go new file mode 100644 index 00000000..8d6000f3 --- /dev/null +++ b/action/user/user.go @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: Apache-2.0 + +package user + +import ( + "github.com/go-vela/cli/internal/output" + api "github.com/go-vela/server/api/types" +) + +// Config represents the configuration necessary +// to perform user related requests with Vela. +type Config struct { + Name string + AddFavorites []string + DropFavorites []string + AddDashboards []string + DropDashboards []string + Output string + Color output.ColorOptions +} + +func outputUser(user *api.User, c *Config) error { + // handle the output based off the provided configuration + switch c.Output { + case output.DriverDump: + // output the user in dump format + // + // https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#Dump + return output.Dump(user) + case output.DriverJSON: + // output the user in JSON format + // + // https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#JSON + return output.JSON(user, c.Color) + case output.DriverSpew: + // output the user in spew format + // + // https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#Spew + return output.Spew(user) + case output.DriverYAML: + // output the user in YAML format + // + // https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#YAML + return output.YAML(user, c.Color) + default: + // output the user in stdout format + // + // https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#Stdout + return output.Stdout(user) + } +} diff --git a/action/user/view.go b/action/user/view.go new file mode 100644 index 00000000..96d9a331 --- /dev/null +++ b/action/user/view.go @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: Apache-2.0 + +package user + +import ( + "github.com/sirupsen/logrus" + + "github.com/go-vela/sdk-go/vela" + api "github.com/go-vela/server/api/types" +) + +// View inspects a user based off the provided configuration. +func (c *Config) View(client *vela.Client) error { + logrus.Debug("executing view for user configuration") + + var ( + user *api.User + err error + ) + + // send API call to capture user + if len(c.Name) > 0 { + user, _, err = client.User.Get(c.Name) + } else { + user, _, err = client.User.GetCurrent() + } + + if err != nil { + return err + } + + return outputUser(user, c) +} diff --git a/action/user/view_test.go b/action/user/view_test.go new file mode 100644 index 00000000..ce4ffa7f --- /dev/null +++ b/action/user/view_test.go @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: Apache-2.0 + +package user + +import ( + "net/http/httptest" + "testing" + + "github.com/go-vela/sdk-go/vela" + "github.com/go-vela/server/mock/server" +) + +func TestUser_Config_View(t *testing.T) { + // setup test server + s := httptest.NewServer(server.FakeHandler()) + + // create a vela client + client, err := vela.NewClient(s.URL, "vela", nil) + if err != nil { + t.Errorf("unable to create client: %v", err) + } + + // setup tests + tests := []struct { + failure bool + config *Config + }{ + { + failure: false, + config: &Config{ + Name: "octocat", + Output: "", + }, + }, + { + failure: false, + config: &Config{ + Name: "octocat", + Output: "dump", + }, + }, + { + failure: false, + config: &Config{ + Name: "octocat", + Output: "json", + }, + }, + { + failure: false, + config: &Config{ + Name: "octocat", + Output: "spew", + }, + }, + { + failure: false, + config: &Config{ + Name: "octocat", + Output: "yaml", + }, + }, + { + failure: true, + config: &Config{ + Name: "not-found", + Output: "", + }, + }, + { + failure: false, + config: &Config{}, + }, + } + + // run tests + for _, test := range tests { + err := test.config.View(client) + + if test.failure { + if err == nil { + t.Errorf("View should have returned err") + } + + continue + } + + if err != nil { + t.Errorf("View returned err: %v", err) + } + } +} diff --git a/cmd/vela-cli/update.go b/cmd/vela-cli/update.go index ef6fc5d4..de422412 100644 --- a/cmd/vela-cli/update.go +++ b/cmd/vela-cli/update.go @@ -11,6 +11,7 @@ import ( "github.com/go-vela/cli/command/schedule" "github.com/go-vela/cli/command/secret" "github.com/go-vela/cli/command/settings" + "github.com/go-vela/cli/command/user" "github.com/go-vela/cli/command/worker" ) @@ -53,6 +54,11 @@ var updateCmds = &cli.Command{ // https://pkg.go.dev/github.com/go-vela/cli/command/settings?tab=doc#CommandUpdate settings.CommandUpdate, + // add the sub command for modifying a user + // + // https://pkg.go.dev/github.com/go-vela/cli/command/user?tab=doc#CommandUpdate + user.CommandUpdate, + // add the sub command for modifying a worker // // https://pkg.go.dev/github.com/go-vela/cli/command/worker?tab=doc#CommandUpdate diff --git a/cmd/vela-cli/view.go b/cmd/vela-cli/view.go index 4fa61076..5e5dc745 100644 --- a/cmd/vela-cli/view.go +++ b/cmd/vela-cli/view.go @@ -18,6 +18,7 @@ import ( "github.com/go-vela/cli/command/service" "github.com/go-vela/cli/command/settings" "github.com/go-vela/cli/command/step" + "github.com/go-vela/cli/command/user" "github.com/go-vela/cli/command/worker" ) @@ -95,6 +96,11 @@ var viewCmds = &cli.Command{ // https://pkg.go.dev/github.com/go-vela/cli/command/step?tab=doc#CommandView step.CommandView, + // add the sub command for viewing a user + // + // https://pkg.go.dev/github.com/go-vela/cli/command/user?tab=doc#CommandView + user.CommandView, + // add the sub command for viewing a worker // // https://pkg.go.dev/github.com/go-vela/cli/command/worker?tab=doc#CommandView diff --git a/command/pipeline/exec.go b/command/pipeline/exec.go index 20febd00..47d044cf 100644 --- a/command/pipeline/exec.go +++ b/command/pipeline/exec.go @@ -3,6 +3,7 @@ package pipeline import ( + "context" "fmt" "os" "strings" @@ -15,7 +16,6 @@ import ( "github.com/go-vela/cli/action/pipeline" "github.com/go-vela/cli/internal" "github.com/go-vela/server/compiler/native" - "github.com/go-vela/server/util" "github.com/go-vela/types/constants" ) @@ -328,16 +328,16 @@ func exec(c *cli.Context) error { // set when user is sourcing templates from local machine if len(p.TemplateFiles) != 0 { client.WithLocalTemplates(p.TemplateFiles) - client.SetTemplateDepth(util.MinInt(c.Int("max-template-depth"), 10)) + client.SetTemplateDepth(min(c.Int("max-template-depth"), 10)) } else { // set max template depth to minimum of 5 and provided value if local templates are not provided. // This prevents users from spamming SCM - client.SetTemplateDepth(util.MinInt(c.Int("max-template-depth"), 5)) + client.SetTemplateDepth(min(c.Int("max-template-depth"), 5)) logrus.Debugf("no local template files provided, setting max template depth to %d", client.GetTemplateDepth()) } // execute the exec call for the pipeline configuration // // https://pkg.go.dev/github.com/go-vela/cli/action/pipeline?tab=doc#Config.Exec - return p.Exec(client.WithPrivateGitHub(c.String(internal.FlagCompilerGitHubURL), c.String(internal.FlagCompilerGitHubToken))) + return p.Exec(client.WithPrivateGitHub(context.Background(), c.String(internal.FlagCompilerGitHubURL), c.String(internal.FlagCompilerGitHubToken))) } diff --git a/command/pipeline/validate.go b/command/pipeline/validate.go index ca3cf074..bb8b01e1 100644 --- a/command/pipeline/validate.go +++ b/command/pipeline/validate.go @@ -3,6 +3,7 @@ package pipeline import ( + "context" "fmt" "github.com/sirupsen/logrus" @@ -13,7 +14,6 @@ import ( "github.com/go-vela/cli/internal" "github.com/go-vela/cli/internal/client" "github.com/go-vela/server/compiler/native" - "github.com/go-vela/server/util" "github.com/go-vela/types/constants" ) @@ -286,12 +286,12 @@ func validate(c *cli.Context) error { } else { // set max template depth to minimum of 5 and provided value if local templates are not provided. // This prevents users from spamming SCM - client.SetTemplateDepth(util.MinInt(c.Int("max-template-depth"), 5)) + client.SetTemplateDepth(min(c.Int("max-template-depth"), 5)) logrus.Debugf("no local template files provided, setting max template depth to %d", client.GetTemplateDepth()) } // execute the validate local call for the pipeline configuration // // https://pkg.go.dev/github.com/go-vela/cli/action/pipeline?tab=doc#Config.ValidateLocal - return p.ValidateLocal(client.WithLocal(true).WithPrivateGitHub(c.String(internal.FlagCompilerGitHubURL), c.String(internal.FlagCompilerGitHubToken))) + return p.ValidateLocal(client.WithLocal(true).WithPrivateGitHub(context.Background(), c.String(internal.FlagCompilerGitHubURL), c.String(internal.FlagCompilerGitHubToken))) } diff --git a/command/user/update.go b/command/user/update.go new file mode 100644 index 00000000..7c4cf756 --- /dev/null +++ b/command/user/update.go @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: Apache-2.0 + +package user + +import ( + "fmt" + + "github.com/urfave/cli/v2" + + "github.com/go-vela/cli/action" + "github.com/go-vela/cli/action/user" + "github.com/go-vela/cli/internal" + "github.com/go-vela/cli/internal/client" + "github.com/go-vela/cli/internal/output" +) + +// CommandUpdate defines the command for updating a user. +var CommandUpdate = &cli.Command{ + Name: "user", + Description: "Use this command to update a user.", + Usage: "Update a user from the provided configuration", + Action: update, + Flags: []cli.Flag{ + + // User Flags + + &cli.StringFlag{ + EnvVars: []string{"VELA_USER_NAME", "USER_NAME"}, + Name: internal.FlagName, + Usage: "provide the name of the user", + }, + &cli.StringSliceFlag{ + EnvVars: []string{"VELA_USER_ADD_FAVORITES", "USER_ADD_FAVORITES"}, + Name: "add-favorites", + Usage: "provide the list of repositories to add as favorites for the user", + }, + &cli.StringSliceFlag{ + EnvVars: []string{"VELA_USER_DROP_FAVORITES", "USER_DROP_FAVORITES"}, + Name: "drop-favorites", + Usage: "provide the list of repositories to remove from favorites of the user", + }, + &cli.StringSliceFlag{ + EnvVars: []string{"VELA_USER_ADD_DASHBOARDS", "USER_ADD_DASHBOARDS"}, + Name: "add-dashboards", + Usage: "provide the list of UUIDs for dashboards to add to the user", + }, + &cli.StringSliceFlag{ + EnvVars: []string{"VELA_USER_DROP_DASHBOARDS", "USER_DROP_DASHBOARDS"}, + Name: "drop-dashboards", + Usage: "provide the list of UUIDs for dashboareds to remove from the user", + }, + + // Output Flags + + &cli.StringFlag{ + EnvVars: []string{"VELA_OUTPUT", "REPO_OUTPUT"}, + Name: internal.FlagOutput, + Aliases: []string{"op"}, + Usage: "format the output in json, spew or yaml", + }, + }, + CustomHelpTemplate: fmt.Sprintf(`%s +EXAMPLES: + 1. Update current user to add a repository to favorites. + $ {{.HelpName}} --add-favorites Org-1/Repo-1 + 2. Update current user to remove a repository from favorites. + $ {{.HelpName}} --drop-favorites Org-1/Repo-1 + 3. Update current user to add a dashboard. + $ {{.HelpName}} --add-dashboards c8da1302-07d6-11ea-882f-4893bca275b8 + 4. Update current user to remove a dashboard. + $ {{.HelpName}} --drop-dashboards c8da1302-07d6-11ea-882f-4893bca275b8 + +DOCUMENTATION: + + https://go-vela.github.io/docs/reference/cli/user/update/ +`, cli.CommandHelpTemplate), +} + +// helper function to capture the provided input +// and create the object used to update a user. +func update(c *cli.Context) error { + // load variables from the config file + err := action.Load(c) + if err != nil { + return err + } + + // parse the Vela client from the context + // + // https://pkg.go.dev/github.com/go-vela/cli/internal/client?tab=doc#Parse + client, err := client.Parse(c) + if err != nil { + return err + } + + // create the user configuration + u := &user.Config{ + Name: c.String(internal.FlagName), + AddFavorites: c.StringSlice("add-favorites"), + DropFavorites: c.StringSlice("drop-favorites"), + AddDashboards: c.StringSlice("add-dashboards"), + DropDashboards: c.StringSlice("drop-dashboards"), + Output: c.String(internal.FlagOutput), + Color: output.ColorOptionsFromCLIContext(c), + } + + // execute the update call for the user configuration + return u.Update(client) +} diff --git a/command/user/update_test.go b/command/user/update_test.go new file mode 100644 index 00000000..b57c6be2 --- /dev/null +++ b/command/user/update_test.go @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: Apache-2.0 + +package user + +import ( + "flag" + "net/http/httptest" + "testing" + + "github.com/urfave/cli/v2" + + "github.com/go-vela/cli/test" + "github.com/go-vela/server/mock/server" +) + +func TestUser_Update(t *testing.T) { + // setup test server + s := httptest.NewServer(server.FakeHandler()) + + // setup flags + authSet := flag.NewFlagSet("test", 0) + authSet.String("api.addr", s.URL, "doc") + authSet.String("api.token.access", test.TestTokenGood, "doc") + authSet.String("api.token.refresh", "superSecretRefreshToken", "doc") + authSet.String("add-favorites", "foo/bar", "doc") + + fullSet := flag.NewFlagSet("test", 0) + fullSet.String("api.addr", s.URL, "doc") + fullSet.String("api.token.access", test.TestTokenGood, "doc") + fullSet.String("api.token.refresh", "superSecretRefreshToken", "doc") + fullSet.String("name", "octocat", "doc") + fullSet.String("output", "json", "doc") + fullSet.String("add-favorites", "foo/bar", "doc") + + // setup tests + tests := []struct { + failure bool + set *flag.FlagSet + }{ + { + failure: false, + set: fullSet, + }, + { + failure: false, + set: authSet, + }, + { + failure: true, + set: flag.NewFlagSet("test", 0), + }, + } + + // run tests + for _, test := range tests { + err := update(cli.NewContext(&cli.App{Name: "vela", Version: "v0.0.0"}, test.set, nil)) + + if test.failure { + if err == nil { + t.Errorf("update should have returned err") + } + + continue + } + + if err != nil { + t.Errorf("update returned err: %v", err) + } + } +} diff --git a/command/user/view.go b/command/user/view.go new file mode 100644 index 00000000..ef2d0749 --- /dev/null +++ b/command/user/view.go @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: Apache-2.0 + +package user + +import ( + "fmt" + + "github.com/urfave/cli/v2" + + "github.com/go-vela/cli/action" + "github.com/go-vela/cli/action/user" + "github.com/go-vela/cli/internal" + "github.com/go-vela/cli/internal/client" + "github.com/go-vela/cli/internal/output" +) + +// CommandView defines the command for inspecting a user. +var CommandView = &cli.Command{ + Name: "user", + Description: "Use this command to view a user.", + Usage: "View details of the provided user", + Action: view, + Flags: []cli.Flag{ + + // User Flags + + &cli.StringFlag{ + EnvVars: []string{"VELA_USER_NAME", "USER_NAME"}, + Name: internal.FlagName, + Aliases: []string{"n"}, + Usage: "provide the name of the user to view", + }, + + // Output Flags + + &cli.StringFlag{ + EnvVars: []string{"VELA_OUTPUT", "REPO_OUTPUT"}, + Name: internal.FlagOutput, + Aliases: []string{"op"}, + Usage: "format the output in json, spew or yaml", + Value: "yaml", + }, + }, + CustomHelpTemplate: fmt.Sprintf(`%s +EXAMPLES: + 1. View details of the current user. + $ {{.HelpName}} + 2. View details of another user (admin). + $ {{.HelpName}} --name Octocat + 3. View details of current user with json output. + $ {{.HelpName}} --output json + +DOCUMENTATION: + + https://go-vela.github.io/docs/reference/cli/repo/view/ +`, cli.CommandHelpTemplate), +} + +// helper function to capture the provided input +// and create the object used to inspect a user. +func view(c *cli.Context) error { + // load variables from the config file + err := action.Load(c) + if err != nil { + return err + } + + client, err := client.Parse(c) + if err != nil { + return err + } + + u := &user.Config{ + Name: c.String(internal.FlagName), + Output: c.String(internal.FlagOutput), + Color: output.ColorOptionsFromCLIContext(c), + } + + return u.View(client) +} diff --git a/command/user/view_test.go b/command/user/view_test.go new file mode 100644 index 00000000..1a6d2f50 --- /dev/null +++ b/command/user/view_test.go @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: Apache-2.0 + +package user + +import ( + "flag" + "net/http/httptest" + "testing" + + "github.com/urfave/cli/v2" + + "github.com/go-vela/cli/test" + "github.com/go-vela/server/mock/server" +) + +func TestUser_View(t *testing.T) { + // setup test server + s := httptest.NewServer(server.FakeHandler()) + + // setup flags + authSet := flag.NewFlagSet("test", 0) + authSet.String("api.addr", s.URL, "doc") + authSet.String("api.token.access", test.TestTokenGood, "doc") + authSet.String("api.token.refresh", "superSecretRefreshToken", "doc") + + fullSet := flag.NewFlagSet("test", 0) + fullSet.String("api.addr", s.URL, "doc") + fullSet.String("api.token.access", test.TestTokenGood, "doc") + fullSet.String("api.token.refresh", "superSecretRefreshToken", "doc") + fullSet.String("name", "octocat", "doc") + fullSet.String("output", "json", "doc") + + // setup tests + tests := []struct { + failure bool + set *flag.FlagSet + }{ + { + failure: false, + set: fullSet, + }, + { + failure: false, + set: authSet, + }, + { + failure: true, + set: flag.NewFlagSet("test", 0), + }, + } + + // run tests + for _, test := range tests { + err := view(cli.NewContext(&cli.App{Name: "vela", Version: "v0.0.0"}, test.set, nil)) + + if test.failure { + if err == nil { + t.Errorf("view should have returned err") + } + + continue + } + + if err != nil { + t.Errorf("view returned err: %v", err) + } + } +} diff --git a/go.mod b/go.mod index fcede40d..5ffb77bd 100644 --- a/go.mod +++ b/go.mod @@ -14,9 +14,9 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/gin-gonic/gin v1.10.0 github.com/go-git/go-git/v5 v5.12.0 - github.com/go-vela/sdk-go v0.24.0 - github.com/go-vela/server v0.24.1 - github.com/go-vela/types v0.24.0 + github.com/go-vela/sdk-go v0.24.1-0.20240906142609-747bf8df428a + github.com/go-vela/server v0.24.3-0.20240905182859-d0fa4f7d8dad + github.com/go-vela/types v0.24.1-0.20240826141537-76a66e72d5dc github.com/go-vela/worker v0.24.0-rc2 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/gosuri/uitable v0.0.4 @@ -37,7 +37,6 @@ require ( github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect - github.com/aymerick/douceur v0.2.0 // indirect github.com/bytedance/sonic v1.11.6 // indirect github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect @@ -80,11 +79,10 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/go-github/v62 v62.0.0 // indirect + github.com/google/go-github/v63 v63.0.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/gorilla/css v1.0.0 // indirect github.com/goware/urlx v0.3.2 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -108,7 +106,6 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect - github.com/microcosm-cc/bluemonday v1.0.26 // indirect github.com/mitchellh/copystructure v1.0.0 // indirect github.com/mitchellh/reflectwalk v1.0.1 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect @@ -138,13 +135,13 @@ require ( go.opentelemetry.io/otel/trace v1.19.0 // indirect go.starlark.net v0.0.0-20240314022150-ee8ed142361c // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.24.0 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.25.0 // indirect + golang.org/x/net v0.26.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/term v0.21.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect @@ -153,7 +150,7 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/api v0.30.2 // indirect - k8s.io/apimachinery v0.30.2 // indirect + k8s.io/apimachinery v0.30.3 // indirect k8s.io/client-go v0.30.2 // indirect k8s.io/klog/v2 v2.120.1 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect diff --git a/go.sum b/go.sum index d69823f5..ad3311cb 100644 --- a/go.sum +++ b/go.sum @@ -28,8 +28,6 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= -github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/buildkite/yaml v0.0.0-20230306222819-0e4e032d4835 h1:Zfkih+Opdv9y5AOob+8iMsaMYnans+Ozrkb8wiPHbj0= github.com/buildkite/yaml v0.0.0-20230306222819-0e4e032d4835/go.mod h1:AV5wtJnn1/CRaRGlJ8xspkMWfKXV0/pkJVgGleTIrfk= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= @@ -137,12 +135,12 @@ github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBEx github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/go-vela/sdk-go v0.24.0 h1:QmwcF8h/Fq1mwbE8mdvqyTmXM2Z3sE0dLQLEMc7HA4w= -github.com/go-vela/sdk-go v0.24.0/go.mod h1:TmJI0KOt/KweLy0HE4JGpKYDPsbhW4sdl2AY/tWP0tY= -github.com/go-vela/server v0.24.1 h1:iM5REZBh6oHD0nxEH4O6dkUWNhY3MNrWBLNWGUUwcP8= -github.com/go-vela/server v0.24.1/go.mod h1:jCnJPiyaRLcdy1u5fKIf7BqsbYAbVMjjI7dlyxZovME= -github.com/go-vela/types v0.24.0 h1:KkkiXxw3uHckh/foyadmLY1YnLw6vhZbz9XwqONCj6o= -github.com/go-vela/types v0.24.0/go.mod h1:YWj6BIapl9Kbj4yHq/fp8jltXdGiwD/gTy1ez32Rzag= +github.com/go-vela/sdk-go v0.24.1-0.20240906142609-747bf8df428a h1:6EATSg+mQLyEpxQZjPFqS0bSLGZvqS7CzjmEJspN4YI= +github.com/go-vela/sdk-go v0.24.1-0.20240906142609-747bf8df428a/go.mod h1:23etn4hulHDeu7/Ww0eQNmt+9iUZU22PXrUnlACiFgA= +github.com/go-vela/server v0.24.3-0.20240905182859-d0fa4f7d8dad h1:JLd0G8P4Bi381bxSR8ws1nFvc7yGz0v1jcXGY3J1ChU= +github.com/go-vela/server v0.24.3-0.20240905182859-d0fa4f7d8dad/go.mod h1:3KmEXG+6N0jfwxPKBM8oIOM3iAcxwJvqsOs0RZvGYnI= +github.com/go-vela/types v0.24.1-0.20240826141537-76a66e72d5dc h1:VyT2tBwPVO9fMmn+22TC4rY4dp+d71To/Qo5Vk4cOSo= +github.com/go-vela/types v0.24.1-0.20240826141537-76a66e72d5dc/go.mod h1:WcSiFm8cWuErRw4aI08NrfM+SZzidnbUs2fmO5klFKo= github.com/go-vela/worker v0.24.0-rc2 h1:HjdJN240kX3B5fMJtbEYmgsTdGWfksC/zA02yAvwJTQ= github.com/go-vela/worker v0.24.0-rc2/go.mod h1:Dr+QxKxNalGuyMYnMNB5Sb6e38JTAK7aU2h7WIZTsvQ= github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= @@ -162,8 +160,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github/v62 v62.0.0 h1:/6mGCaRywZz9MuHyw9gD1CwsbmBX8GWsbFkwMmHdhl4= -github.com/google/go-github/v62 v62.0.0/go.mod h1:EMxeUqGJq2xRu9DYBMwel/mr7kZrzUOfQmmpYrZn2a4= +github.com/google/go-github/v63 v63.0.0 h1:13xwK/wk9alSokujB9lJkuzdmQuVn2QCPeck76wR3nE= +github.com/google/go-github/v63 v63.0.0/go.mod h1:IqbcrgUmIcEaioWrGYei/09o+ge5vhffGOcxrO0AfmA= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -174,8 +172,6 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= -github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY= github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= github.com/goware/urlx v0.3.2 h1:gdoo4kBHlkqZNaf6XlQ12LGtQOmpKJrR04Rc3RnpJEo= @@ -249,8 +245,6 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58= -github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -366,8 +360,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -385,8 +379,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -413,15 +407,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= -golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -474,8 +468,8 @@ gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI= k8s.io/api v0.30.2/go.mod h1:ULg5g9JvOev2dG0u2hig4Z7tQ2hHIuS+m8MNZ+X6EmI= -k8s.io/apimachinery v0.30.2 h1:fEMcnBj6qkzzPGSVsAZtQThU62SmQ4ZymlXRC5yFSCg= -k8s.io/apimachinery v0.30.2/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/apimachinery v0.30.3 h1:q1laaWCmrszyQuSQCfNB8cFgCuDAoPszKY4ucAjDwHc= +k8s.io/apimachinery v0.30.3/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50= k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs= k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= diff --git a/internal/internal.go b/internal/internal.go index 90865ca4..2a4b6c79 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -165,6 +165,13 @@ const ( FlagStep = "step" ) +// user flag keys. +const ( + // FlagName defines the key for the + // flag when setting the user name. + FlagName = "name" +) + // worker flag keys. const ( // FlagWorkerAddress defines the key for the