From b2cd3c73bfcd5a020686902a03ff42209cb665c3 Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Thu, 10 Dec 2020 22:51:20 +0000 Subject: [PATCH 1/2] Remove --user flag from "envs create" --- internal/cmd/envs.go | 64 ++++++++++++++++++++++++----------------- internal/cmd/rebuild.go | 12 +++++--- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/internal/cmd/envs.go b/internal/cmd/envs.go index 8ba33fb8..4cc62e50 100644 --- a/internal/cmd/envs.go +++ b/internal/cmd/envs.go @@ -18,22 +18,20 @@ import ( const defaultImgTag = "latest" func envsCmd() *cobra.Command { - var user string cmd := &cobra.Command{ Use: "envs", Short: "Interact with Coder environments", Long: "Perform operations on the Coder environments owned by the active user.", } - cmd.PersistentFlags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target") cmd.AddCommand( - lsEnvsCommand(&user), - stopEnvsCmd(&user), - rmEnvsCmd(&user), - watchBuildLogCommand(&user), - rebuildEnvCommand(&user), - createEnvCmd(&user), - editEnvCmd(&user), + lsEnvsCommand(), + stopEnvsCmd(), + rmEnvsCmd(), + watchBuildLogCommand(), + rebuildEnvCommand(), + createEnvCmd(), + editEnvCmd(), ) return cmd } @@ -43,8 +41,11 @@ const ( jsonOutput = "json" ) -func lsEnvsCommand(user *string) *cobra.Command { - var outputFmt string +func lsEnvsCommand() *cobra.Command { + var ( + outputFmt string + user string + ) cmd := &cobra.Command{ Use: "ls", @@ -56,7 +57,7 @@ func lsEnvsCommand(user *string) *cobra.Command { if err != nil { return err } - envs, err := getEnvs(ctx, client, *user) + envs, err := getEnvs(ctx, client, user) if err != nil { return err } @@ -85,13 +86,15 @@ func lsEnvsCommand(user *string) *cobra.Command { }, } + cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target") cmd.Flags().StringVarP(&outputFmt, "output", "o", humanOutput, "human | json") return cmd } -func stopEnvsCmd(user *string) *cobra.Command { - return &cobra.Command{ +func stopEnvsCmd() *cobra.Command { + var user string + cmd := &cobra.Command{ Use: "stop [...environment_names]", Short: "stop Coder environments by name", Long: "Stop Coder environments by name", @@ -117,7 +120,7 @@ coder envs --user charlie@coder.com ls -o json \ for _, envName := range args { envName := envName egroup.Go(func() error { - env, err := findEnv(ctx, client, envName, *user) + env, err := findEnv(ctx, client, envName, user) if err != nil { return err } @@ -136,9 +139,11 @@ coder envs --user charlie@coder.com ls -o json \ return egroup.Wait() }, } + cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target") + return cmd } -func createEnvCmd(user *string) *cobra.Command { +func createEnvCmd() *cobra.Command { var ( org string cpu float32 @@ -170,7 +175,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub return err } - multiOrgMember, err := isMultiOrgMember(ctx, client, *user) + multiOrgMember, err := isMultiOrgMember(ctx, client, coder.Me) if err != nil { return err } @@ -180,7 +185,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub } importedImg, err := findImg(ctx, client, findImgConf{ - email: *user, + email: coder.Me, imgName: img, orgName: org, }) @@ -245,7 +250,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub return cmd } -func editEnvCmd(user *string) *cobra.Command { +func editEnvCmd() *cobra.Command { var ( org string img string @@ -257,6 +262,7 @@ func editEnvCmd(user *string) *cobra.Command { follow bool useCVM bool notCVM bool + user string ) cmd := &cobra.Command{ @@ -276,12 +282,12 @@ coder envs edit back-end-env --disk 20`, envName := args[0] - env, err := findEnv(ctx, client, envName, *user) + env, err := findEnv(ctx, client, envName, user) if err != nil { return err } - multiOrgMember, err := isMultiOrgMember(ctx, client, *user) + multiOrgMember, err := isMultiOrgMember(ctx, client, user) if err != nil { return err } @@ -337,11 +343,16 @@ coder envs edit back-end-env --disk 20`, cmd.Flags().BoolVar(&follow, "follow", false, "follow buildlog after initiating rebuild") cmd.Flags().BoolVar(&useCVM, "container-vm", false, "deploy the environment as a Container-based VM") cmd.Flags().BoolVar(¬CVM, "not-container-vm", false, "do not deploy the environment as a Container-based VM") + cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target") return cmd } -func rmEnvsCmd(user *string) *cobra.Command { - var force bool +func rmEnvsCmd() *cobra.Command { + var ( + force bool + user string + ) + cmd := &cobra.Command{ Use: "rm [...environment_names]", Short: "remove Coder environments by name", @@ -369,7 +380,7 @@ func rmEnvsCmd(user *string) *cobra.Command { for _, envName := range args { envName := envName egroup.Go(func() error { - env, err := findEnv(ctx, client, envName, *user) + env, err := findEnv(ctx, client, envName, user) if err != nil { return err } @@ -387,6 +398,7 @@ func rmEnvsCmd(user *string) *cobra.Command { }, } cmd.Flags().BoolVarP(&force, "force", "f", false, "force remove the specified environments without prompting first") + cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target") return cmd } @@ -396,7 +408,7 @@ type updateConf struct { diskGB int gpus int environment *coder.Environment - user *string + user string image string imageTag string orgName string @@ -427,7 +439,7 @@ func buildUpdateReq(ctx context.Context, client *coder.Client, conf updateConf) // If this is not empty it means the user is requesting to change the environment image. if conf.image != "" { importedImg, err := findImg(ctx, client, findImgConf{ - email: *conf.user, + email: conf.user, imgName: conf.image, orgName: conf.orgName, }) diff --git a/internal/cmd/rebuild.go b/internal/cmd/rebuild.go index ae2907d3..c3a8f9bd 100644 --- a/internal/cmd/rebuild.go +++ b/internal/cmd/rebuild.go @@ -17,9 +17,10 @@ import ( "golang.org/x/xerrors" ) -func rebuildEnvCommand(user *string) *cobra.Command { +func rebuildEnvCommand() *cobra.Command { var follow bool var force bool + var user string cmd := &cobra.Command{ Use: "rebuild [environment_name]", Short: "rebuild a Coder environment", @@ -32,7 +33,7 @@ coder envs rebuild backend-env --force`, if err != nil { return err } - env, err := findEnv(ctx, client, args[0], *user) + env, err := findEnv(ctx, client, args[0], user) if err != nil { return err } @@ -67,6 +68,7 @@ coder envs rebuild backend-env --force`, }, } + cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target") cmd.Flags().BoolVar(&follow, "follow", false, "follow build log after initiating rebuild") cmd.Flags().BoolVar(&force, "force", false, "force rebuild without showing a confirmation prompt") return cmd @@ -136,7 +138,8 @@ func trailBuildLogs(ctx context.Context, client *coder.Client, envID string) err return nil } -func watchBuildLogCommand(user *string) *cobra.Command { +func watchBuildLogCommand() *cobra.Command { + var user string cmd := &cobra.Command{ Use: "watch-build [environment_name]", Example: "coder envs watch-build front-end-env", @@ -148,7 +151,7 @@ func watchBuildLogCommand(user *string) *cobra.Command { if err != nil { return err } - env, err := findEnv(ctx, client, args[0], *user) + env, err := findEnv(ctx, client, args[0], user) if err != nil { return err } @@ -159,5 +162,6 @@ func watchBuildLogCommand(user *string) *cobra.Command { return nil }, } + cmd.Flags().StringVar(&user, "user", coder.Me, "Specify the user whose resources to target") return cmd } From c4319ab49599d98b435b8c36581c18a3bcf45b7e Mon Sep 17 00:00:00 2001 From: Charlie Moog Date: Thu, 10 Dec 2020 22:54:02 +0000 Subject: [PATCH 2/2] fixup! Remove --user flag from "envs create" --- docs/coder_envs.md | 3 +-- docs/coder_envs_create.md | 3 +-- docs/coder_envs_edit.md | 4 ++-- docs/coder_envs_ls.md | 4 ++-- docs/coder_envs_rebuild.md | 10 +++++----- docs/coder_envs_rm.md | 8 ++++---- docs/coder_envs_stop.md | 6 +++--- docs/coder_envs_watch-build.md | 6 +++--- 8 files changed, 21 insertions(+), 23 deletions(-) diff --git a/docs/coder_envs.md b/docs/coder_envs.md index 90d14880..82897598 100644 --- a/docs/coder_envs.md +++ b/docs/coder_envs.md @@ -9,8 +9,7 @@ Perform operations on the Coder environments owned by the active user. ### Options ``` - -h, --help help for envs - --user string Specify the user whose resources to target (default "me") + -h, --help help for envs ``` ### Options inherited from parent commands diff --git a/docs/coder_envs_create.md b/docs/coder_envs_create.md index 91daaf07..c708fa3e 100644 --- a/docs/coder_envs_create.md +++ b/docs/coder_envs_create.md @@ -36,8 +36,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub ### Options inherited from parent commands ``` - --user string Specify the user whose resources to target (default "me") - -v, --verbose show verbose output + -v, --verbose show verbose output ``` ### SEE ALSO diff --git a/docs/coder_envs_edit.md b/docs/coder_envs_edit.md index da94adcc..abec71f2 100644 --- a/docs/coder_envs_edit.md +++ b/docs/coder_envs_edit.md @@ -32,13 +32,13 @@ coder envs edit back-end-env --disk 20 --not-container-vm do not deploy the environment as a Container-based VM -o, --org string name of the organization the environment should be created under. -t, --tag string image tag of the image you want to base the environment off of. (default "latest") + --user string Specify the user whose resources to target (default "me") ``` ### Options inherited from parent commands ``` - --user string Specify the user whose resources to target (default "me") - -v, --verbose show verbose output + -v, --verbose show verbose output ``` ### SEE ALSO diff --git a/docs/coder_envs_ls.md b/docs/coder_envs_ls.md index d4b78438..daa12f4a 100644 --- a/docs/coder_envs_ls.md +++ b/docs/coder_envs_ls.md @@ -15,13 +15,13 @@ coder envs ls [flags] ``` -h, --help help for ls -o, --output string human | json (default "human") + --user string Specify the user whose resources to target (default "me") ``` ### Options inherited from parent commands ``` - --user string Specify the user whose resources to target (default "me") - -v, --verbose show verbose output + -v, --verbose show verbose output ``` ### SEE ALSO diff --git a/docs/coder_envs_rebuild.md b/docs/coder_envs_rebuild.md index bcfdcd3c..a18d279e 100644 --- a/docs/coder_envs_rebuild.md +++ b/docs/coder_envs_rebuild.md @@ -16,16 +16,16 @@ coder envs rebuild backend-env --force ### Options ``` - --follow follow build log after initiating rebuild - --force force rebuild without showing a confirmation prompt - -h, --help help for rebuild + --follow follow build log after initiating rebuild + --force force rebuild without showing a confirmation prompt + -h, --help help for rebuild + --user string Specify the user whose resources to target (default "me") ``` ### Options inherited from parent commands ``` - --user string Specify the user whose resources to target (default "me") - -v, --verbose show verbose output + -v, --verbose show verbose output ``` ### SEE ALSO diff --git a/docs/coder_envs_rm.md b/docs/coder_envs_rm.md index 416ef369..e39acffd 100644 --- a/docs/coder_envs_rm.md +++ b/docs/coder_envs_rm.md @@ -9,15 +9,15 @@ coder envs rm [...environment_names] [flags] ### Options ``` - -f, --force force remove the specified environments without prompting first - -h, --help help for rm + -f, --force force remove the specified environments without prompting first + -h, --help help for rm + --user string Specify the user whose resources to target (default "me") ``` ### Options inherited from parent commands ``` - --user string Specify the user whose resources to target (default "me") - -v, --verbose show verbose output + -v, --verbose show verbose output ``` ### SEE ALSO diff --git a/docs/coder_envs_stop.md b/docs/coder_envs_stop.md index b6cc6ec6..4fd38db2 100644 --- a/docs/coder_envs_stop.md +++ b/docs/coder_envs_stop.md @@ -28,14 +28,14 @@ coder envs --user charlie@coder.com ls -o json \ ### Options ``` - -h, --help help for stop + -h, --help help for stop + --user string Specify the user whose resources to target (default "me") ``` ### Options inherited from parent commands ``` - --user string Specify the user whose resources to target (default "me") - -v, --verbose show verbose output + -v, --verbose show verbose output ``` ### SEE ALSO diff --git a/docs/coder_envs_watch-build.md b/docs/coder_envs_watch-build.md index 7065a6b6..19901fc5 100644 --- a/docs/coder_envs_watch-build.md +++ b/docs/coder_envs_watch-build.md @@ -15,14 +15,14 @@ coder envs watch-build front-end-env ### Options ``` - -h, --help help for watch-build + -h, --help help for watch-build + --user string Specify the user whose resources to target (default "me") ``` ### Options inherited from parent commands ``` - --user string Specify the user whose resources to target (default "me") - -v, --verbose show verbose output + -v, --verbose show verbose output ``` ### SEE ALSO pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy