Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit a5f34c9

Browse files
committed
fixup! Add --user flag to "secrets" and "envs"
1 parent 13a89c4 commit a5f34c9

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

cmd/coder/envs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func makeEnvsCommand() *cobra.Command {
1818
Short: "Interact with Coder environments",
1919
Long: "Perform operations on the Coder environments owned by the active user.",
2020
}
21-
cmd.PersistentFlags().StringVar(&user, "user",entclient.Me, "Specify the user whose resources to target")
21+
cmd.PersistentFlags().StringVar(&user, "user", entclient.Me, "Specify the user whose resources to target")
2222

2323
lsCmd := &cobra.Command{
2424
Use: "ls",

cmd/coder/secrets.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -156,30 +156,30 @@ func listSecrets(user *string) func(cmd *cobra.Command, _ []string) error {
156156
}
157157

158158
func makeViewSecret(user *string) func(cmd *cobra.Command, args []string) error {
159-
return func (_ *cobra.Command, args []string) error {
160-
var (
161-
client = requireAuth(*user)
162-
name = args[0]
163-
)
164-
if name == "" {
165-
return xerrors.New("[name] is a required argument")
166-
}
159+
return func(_ *cobra.Command, args []string) error {
160+
var (
161+
client = requireAuth(*user)
162+
name = args[0]
163+
)
164+
if name == "" {
165+
return xerrors.New("[name] is a required argument")
166+
}
167167

168-
secret, err := client.SecretByName(name)
169-
if err != nil {
170-
return xerrors.Errorf("get secret by name: %w", err)
171-
}
168+
secret, err := client.SecretByName(name)
169+
if err != nil {
170+
return xerrors.Errorf("get secret by name: %w", err)
171+
}
172172

173-
_, err = fmt.Fprintln(os.Stdout, secret.Value)
174-
if err != nil {
175-
return xerrors.Errorf("write secret value: %w", err)
176-
}
177-
return nil
178-
}
173+
_, err = fmt.Fprintln(os.Stdout, secret.Value)
174+
if err != nil {
175+
return xerrors.Errorf("write secret value: %w", err)
176+
}
177+
return nil
178+
}
179179
}
180180

181181
func makeRemoveSecrets(user *string) func(c *cobra.Command, args []string) error {
182-
return func (_ *cobra.Command, args []string) error {
182+
return func(_ *cobra.Command, args []string) error {
183183
var (
184184
client = requireAuth(*user)
185185
)
@@ -203,4 +203,3 @@ func makeRemoveSecrets(user *string) func(c *cobra.Command, args []string) error
203203
return nil
204204
}
205205
}
206-

cmd/coder/shell.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import (
2020
"go.coder.com/flog"
2121
)
2222

23-
func getEnvsForCompletion() []string {
23+
func getEnvsForCompletion(user string) []string {
2424
var envNames []string
25-
client, err := newClient()
25+
client, err := newClient(user)
2626
if err != nil {
2727
return envNames
2828
}
@@ -43,7 +43,7 @@ func makeShellCmd() *cobra.Command {
4343
Long: "Execute a remote command on the environment\\nIf no command is specified, the default shell is opened.",
4444
Args: cobra.MinimumNArgs(1),
4545
DisableFlagParsing: true,
46-
ValidArgs: getEnvsForCompletion(),
46+
ValidArgs: getEnvsForCompletion(entclient.Me),
4747
RunE: shell,
4848
Example: "coder sh backend-env",
4949
}

cmd/coder/urls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func makeURLCmd() *cobra.Command {
2727
Use: "ls [environment_name]",
2828
Short: "List all DevURLs for an environment",
2929
Args: cobra.ExactArgs(1),
30-
ValidArgs: getEnvsForCompletion(),
30+
ValidArgs: getEnvsForCompletion(entclient.Me),
3131
RunE: makeListDevURLs(&outputFmt),
3232
}
3333
lsCmd.Flags().StringVarP(&outputFmt, "output", "o", "human", "human|json")

0 commit comments

Comments
 (0)