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

Commit c3d6592

Browse files
committed
fixup! Move user flag to entclient req options
1 parent aa5597c commit c3d6592

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

cmd/coder/shell.go

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

23-
func getEnvsForCompletion(user string) []string {
24-
// TODO(@cmoog): Enable this if speed issue can be resolved. Otherwise, all commands will take > 1 second.
25-
return nil
26-
27-
var envNames []string
28-
client, err := newClient()
29-
if err != nil {
30-
return envNames
31-
}
32-
envs, err := getEnvs(context.TODO(), client, user)
33-
if err != nil {
34-
return envNames
35-
}
36-
for _, e := range envs {
37-
envNames = append(envNames, e.Name)
23+
func getEnvsForCompletion(user string) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
24+
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
25+
var envNames []string
26+
client, err := newClient()
27+
if err != nil {
28+
return envNames, cobra.ShellCompDirectiveDefault
29+
}
30+
envs, err := getEnvs(context.TODO(), client, user)
31+
if err != nil {
32+
return envNames, cobra.ShellCompDirectiveDefault
33+
}
34+
for _, e := range envs {
35+
envNames = append(envNames, e.Name)
36+
}
37+
return envNames, cobra.ShellCompDirectiveDefault
3838
}
39-
return envNames
4039
}
4140

4241
func makeShellCmd() *cobra.Command {
@@ -46,7 +45,7 @@ func makeShellCmd() *cobra.Command {
4645
Long: "Execute a remote command on the environment\\nIf no command is specified, the default shell is opened.",
4746
Args: cobra.MinimumNArgs(1),
4847
DisableFlagParsing: true,
49-
ValidArgs: getEnvsForCompletion(entclient.Me),
48+
ValidArgsFunction: getEnvsForCompletion(entclient.Me),
5049
RunE: shell,
5150
Example: "coder sh backend-env",
5251
}

cmd/coder/urls.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func makeURLCmd() *cobra.Command {
2525
Short: "Interact with environment DevURLs",
2626
}
2727
lsCmd := &cobra.Command{
28-
Use: "ls [environment_name]",
29-
Short: "List all DevURLs for an environment",
30-
Args: cobra.ExactArgs(1),
31-
ValidArgs: getEnvsForCompletion(entclient.Me),
32-
RunE: makeListDevURLs(&outputFmt),
28+
Use: "ls [environment_name]",
29+
Short: "List all DevURLs for an environment",
30+
Args: cobra.ExactArgs(1),
31+
ValidArgsFunction: getEnvsForCompletion(entclient.Me),
32+
RunE: makeListDevURLs(&outputFmt),
3333
}
3434
lsCmd.Flags().StringVarP(&outputFmt, "output", "o", "human", "human|json")
3535

internal/entclient/secrets.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ type Secret struct {
1616
UpdatedAt time.Time `json:"updated_at" tab:"-"`
1717
}
1818

19+
// ReqOptions define api request configuration options
1920
type ReqOptions struct {
21+
// User defines the users whose resources should be targeted
2022
User string
2123
}
2224

25+
// DefaultReqOptions define reasonable defaults for an api request
2326
var DefaultReqOptions = &ReqOptions{
2427
User: Me,
2528
}

0 commit comments

Comments
 (0)
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