Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commitc3d6592

Browse files
committed
fixup! Move user flag to entclient req options
1 parentaa5597c commitc3d6592

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-
funcgetEnvsForCompletion(userstring) []string {
24-
// TODO(@cmoog): Enable this if speed issue can be resolved. Otherwise, all commands will take > 1 second.
25-
returnnil
26-
27-
varenvNames []string
28-
client,err:=newClient()
29-
iferr!=nil {
30-
returnenvNames
31-
}
32-
envs,err:=getEnvs(context.TODO(),client,user)
33-
iferr!=nil {
34-
returnenvNames
35-
}
36-
for_,e:=rangeenvs {
37-
envNames=append(envNames,e.Name)
23+
funcgetEnvsForCompletion(userstring)func(cmd*cobra.Command,args[]string,toCompletestring) ([]string, cobra.ShellCompDirective) {
24+
returnfunc(cmd*cobra.Command,args []string,toCompletestring) ([]string, cobra.ShellCompDirective) {
25+
varenvNames []string
26+
client,err:=newClient()
27+
iferr!=nil {
28+
returnenvNames,cobra.ShellCompDirectiveDefault
29+
}
30+
envs,err:=getEnvs(context.TODO(),client,user)
31+
iferr!=nil {
32+
returnenvNames,cobra.ShellCompDirectiveDefault
33+
}
34+
for_,e:=rangeenvs {
35+
envNames=append(envNames,e.Name)
36+
}
37+
returnenvNames,cobra.ShellCompDirectiveDefault
3838
}
39-
returnenvNames
4039
}
4140

4241
funcmakeShellCmd()*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
typeReqOptionsstruct {
21+
// User defines the users whose resources should be targeted
2022
Userstring
2123
}
2224

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp