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

Commit68114e3

Browse files
authored
Remove --user flag from "envs create" (#203)
1 parente99a75b commit68114e3

10 files changed

+67
-53
lines changed

‎docs/coder_envs.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ Perform operations on the Coder environments owned by the active user.
99
###Options
1010

1111
```
12-
-h, --help help for envs
13-
--user string Specify the user whose resources to target (default "me")
12+
-h, --help help for envs
1413
```
1514

1615
###Options inherited from parent commands

‎docs/coder_envs_create.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
3636
###Options inherited from parent commands
3737

3838
```
39-
--user string Specify the user whose resources to target (default "me")
40-
-v, --verbose show verbose output
39+
-v, --verbose show verbose output
4140
```
4241

4342
###SEE ALSO

‎docs/coder_envs_edit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ coder envs edit back-end-env --disk 20
3232
--not-container-vm do not deploy the environment as a Container-based VM
3333
-o, --org string name of the organization the environment should be created under.
3434
-t, --tag string image tag of the image you want to base the environment off of. (default "latest")
35+
--user string Specify the user whose resources to target (default "me")
3536
```
3637

3738
###Options inherited from parent commands
3839

3940
```
40-
--user string Specify the user whose resources to target (default "me")
41-
-v, --verbose show verbose output
41+
-v, --verbose show verbose output
4242
```
4343

4444
###SEE ALSO

‎docs/coder_envs_ls.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ coder envs ls [flags]
1515
```
1616
-h, --help help for ls
1717
-o, --output string human | json (default "human")
18+
--user string Specify the user whose resources to target (default "me")
1819
```
1920

2021
###Options inherited from parent commands
2122

2223
```
23-
--user string Specify the user whose resources to target (default "me")
24-
-v, --verbose show verbose output
24+
-v, --verbose show verbose output
2525
```
2626

2727
###SEE ALSO

‎docs/coder_envs_rebuild.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ coder envs rebuild backend-env --force
1616
###Options
1717

1818
```
19-
--follow follow build log after initiating rebuild
20-
--force force rebuild without showing a confirmation prompt
21-
-h, --help help for rebuild
19+
--follow follow build log after initiating rebuild
20+
--force force rebuild without showing a confirmation prompt
21+
-h, --help help for rebuild
22+
--user string Specify the user whose resources to target (default "me")
2223
```
2324

2425
###Options inherited from parent commands
2526

2627
```
27-
--user string Specify the user whose resources to target (default "me")
28-
-v, --verbose show verbose output
28+
-v, --verbose show verbose output
2929
```
3030

3131
###SEE ALSO

‎docs/coder_envs_rm.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ coder envs rm [...environment_names] [flags]
99
###Options
1010

1111
```
12-
-f, --force force remove the specified environments without prompting first
13-
-h, --help help for rm
12+
-f, --force force remove the specified environments without prompting first
13+
-h, --help help for rm
14+
--user string Specify the user whose resources to target (default "me")
1415
```
1516

1617
###Options inherited from parent commands
1718

1819
```
19-
--user string Specify the user whose resources to target (default "me")
20-
-v, --verbose show verbose output
20+
-v, --verbose show verbose output
2121
```
2222

2323
###SEE ALSO

‎docs/coder_envs_stop.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ coder envs --user charlie@coder.com ls -o json \
2828
###Options
2929

3030
```
31-
-h, --help help for stop
31+
-h, --help help for stop
32+
--user string Specify the user whose resources to target (default "me")
3233
```
3334

3435
###Options inherited from parent commands
3536

3637
```
37-
--user string Specify the user whose resources to target (default "me")
38-
-v, --verbose show verbose output
38+
-v, --verbose show verbose output
3939
```
4040

4141
###SEE ALSO

‎docs/coder_envs_watch-build.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ coder envs watch-build front-end-env
1515
###Options
1616

1717
```
18-
-h, --help help for watch-build
18+
-h, --help help for watch-build
19+
--user string Specify the user whose resources to target (default "me")
1920
```
2021

2122
###Options inherited from parent commands
2223

2324
```
24-
--user string Specify the user whose resources to target (default "me")
25-
-v, --verbose show verbose output
25+
-v, --verbose show verbose output
2626
```
2727

2828
###SEE ALSO

‎internal/cmd/envs.go

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,20 @@ import (
1818
constdefaultImgTag="latest"
1919

2020
funcenvsCmd()*cobra.Command {
21-
varuserstring
2221
cmd:=&cobra.Command{
2322
Use:"envs",
2423
Short:"Interact with Coder environments",
2524
Long:"Perform operations on the Coder environments owned by the active user.",
2625
}
27-
cmd.PersistentFlags().StringVar(&user,"user",coder.Me,"Specify the user whose resources to target")
2826

2927
cmd.AddCommand(
30-
lsEnvsCommand(&user),
31-
stopEnvsCmd(&user),
32-
rmEnvsCmd(&user),
33-
watchBuildLogCommand(&user),
34-
rebuildEnvCommand(&user),
35-
createEnvCmd(&user),
36-
editEnvCmd(&user),
28+
lsEnvsCommand(),
29+
stopEnvsCmd(),
30+
rmEnvsCmd(),
31+
watchBuildLogCommand(),
32+
rebuildEnvCommand(),
33+
createEnvCmd(),
34+
editEnvCmd(),
3735
)
3836
returncmd
3937
}
@@ -43,8 +41,11 @@ const (
4341
jsonOutput="json"
4442
)
4543

46-
funclsEnvsCommand(user*string)*cobra.Command {
47-
varoutputFmtstring
44+
funclsEnvsCommand()*cobra.Command {
45+
var (
46+
outputFmtstring
47+
userstring
48+
)
4849

4950
cmd:=&cobra.Command{
5051
Use:"ls",
@@ -56,7 +57,7 @@ func lsEnvsCommand(user *string) *cobra.Command {
5657
iferr!=nil {
5758
returnerr
5859
}
59-
envs,err:=getEnvs(ctx,client,*user)
60+
envs,err:=getEnvs(ctx,client,user)
6061
iferr!=nil {
6162
returnerr
6263
}
@@ -85,13 +86,15 @@ func lsEnvsCommand(user *string) *cobra.Command {
8586
},
8687
}
8788

89+
cmd.Flags().StringVar(&user,"user",coder.Me,"Specify the user whose resources to target")
8890
cmd.Flags().StringVarP(&outputFmt,"output","o",humanOutput,"human | json")
8991

9092
returncmd
9193
}
9294

93-
funcstopEnvsCmd(user*string)*cobra.Command {
94-
return&cobra.Command{
95+
funcstopEnvsCmd()*cobra.Command {
96+
varuserstring
97+
cmd:=&cobra.Command{
9598
Use:"stop [...environment_names]",
9699
Short:"stop Coder environments by name",
97100
Long:"Stop Coder environments by name",
@@ -117,7 +120,7 @@ coder envs --user charlie@coder.com ls -o json \
117120
for_,envName:=rangeargs {
118121
envName:=envName
119122
egroup.Go(func()error {
120-
env,err:=findEnv(ctx,client,envName,*user)
123+
env,err:=findEnv(ctx,client,envName,user)
121124
iferr!=nil {
122125
returnerr
123126
}
@@ -136,9 +139,11 @@ coder envs --user charlie@coder.com ls -o json \
136139
returnegroup.Wait()
137140
},
138141
}
142+
cmd.Flags().StringVar(&user,"user",coder.Me,"Specify the user whose resources to target")
143+
returncmd
139144
}
140145

141-
funccreateEnvCmd(user*string)*cobra.Command {
146+
funccreateEnvCmd()*cobra.Command {
142147
var (
143148
orgstring
144149
cpufloat32
@@ -170,7 +175,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
170175
returnerr
171176
}
172177

173-
multiOrgMember,err:=isMultiOrgMember(ctx,client,*user)
178+
multiOrgMember,err:=isMultiOrgMember(ctx,client,coder.Me)
174179
iferr!=nil {
175180
returnerr
176181
}
@@ -180,7 +185,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
180185
}
181186

182187
importedImg,err:=findImg(ctx,client,findImgConf{
183-
email:*user,
188+
email:coder.Me,
184189
imgName:img,
185190
orgName:org,
186191
})
@@ -245,7 +250,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
245250
returncmd
246251
}
247252

248-
funceditEnvCmd(user*string)*cobra.Command {
253+
funceditEnvCmd()*cobra.Command {
249254
var (
250255
orgstring
251256
imgstring
@@ -257,6 +262,7 @@ func editEnvCmd(user *string) *cobra.Command {
257262
followbool
258263
useCVMbool
259264
notCVMbool
265+
userstring
260266
)
261267

262268
cmd:=&cobra.Command{
@@ -276,12 +282,12 @@ coder envs edit back-end-env --disk 20`,
276282

277283
envName:=args[0]
278284

279-
env,err:=findEnv(ctx,client,envName,*user)
285+
env,err:=findEnv(ctx,client,envName,user)
280286
iferr!=nil {
281287
returnerr
282288
}
283289

284-
multiOrgMember,err:=isMultiOrgMember(ctx,client,*user)
290+
multiOrgMember,err:=isMultiOrgMember(ctx,client,user)
285291
iferr!=nil {
286292
returnerr
287293
}
@@ -337,11 +343,16 @@ coder envs edit back-end-env --disk 20`,
337343
cmd.Flags().BoolVar(&follow,"follow",false,"follow buildlog after initiating rebuild")
338344
cmd.Flags().BoolVar(&useCVM,"container-vm",false,"deploy the environment as a Container-based VM")
339345
cmd.Flags().BoolVar(&notCVM,"not-container-vm",false,"do not deploy the environment as a Container-based VM")
346+
cmd.Flags().StringVar(&user,"user",coder.Me,"Specify the user whose resources to target")
340347
returncmd
341348
}
342349

343-
funcrmEnvsCmd(user*string)*cobra.Command {
344-
varforcebool
350+
funcrmEnvsCmd()*cobra.Command {
351+
var (
352+
forcebool
353+
userstring
354+
)
355+
345356
cmd:=&cobra.Command{
346357
Use:"rm [...environment_names]",
347358
Short:"remove Coder environments by name",
@@ -369,7 +380,7 @@ func rmEnvsCmd(user *string) *cobra.Command {
369380
for_,envName:=rangeargs {
370381
envName:=envName
371382
egroup.Go(func()error {
372-
env,err:=findEnv(ctx,client,envName,*user)
383+
env,err:=findEnv(ctx,client,envName,user)
373384
iferr!=nil {
374385
returnerr
375386
}
@@ -387,6 +398,7 @@ func rmEnvsCmd(user *string) *cobra.Command {
387398
},
388399
}
389400
cmd.Flags().BoolVarP(&force,"force","f",false,"force remove the specified environments without prompting first")
401+
cmd.Flags().StringVar(&user,"user",coder.Me,"Specify the user whose resources to target")
390402
returncmd
391403
}
392404

@@ -396,7 +408,7 @@ type updateConf struct {
396408
diskGBint
397409
gpusint
398410
environment*coder.Environment
399-
user*string
411+
userstring
400412
imagestring
401413
imageTagstring
402414
orgNamestring
@@ -427,7 +439,7 @@ func buildUpdateReq(ctx context.Context, client *coder.Client, conf updateConf)
427439
// If this is not empty it means the user is requesting to change the environment image.
428440
ifconf.image!="" {
429441
importedImg,err:=findImg(ctx,client,findImgConf{
430-
email:*conf.user,
442+
email:conf.user,
431443
imgName:conf.image,
432444
orgName:conf.orgName,
433445
})

‎internal/cmd/rebuild.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ import (
1717
"golang.org/x/xerrors"
1818
)
1919

20-
funcrebuildEnvCommand(user*string)*cobra.Command {
20+
funcrebuildEnvCommand()*cobra.Command {
2121
varfollowbool
2222
varforcebool
23+
varuserstring
2324
cmd:=&cobra.Command{
2425
Use:"rebuild [environment_name]",
2526
Short:"rebuild a Coder environment",
@@ -32,7 +33,7 @@ coder envs rebuild backend-env --force`,
3233
iferr!=nil {
3334
returnerr
3435
}
35-
env,err:=findEnv(ctx,client,args[0],*user)
36+
env,err:=findEnv(ctx,client,args[0],user)
3637
iferr!=nil {
3738
returnerr
3839
}
@@ -67,6 +68,7 @@ coder envs rebuild backend-env --force`,
6768
},
6869
}
6970

71+
cmd.Flags().StringVar(&user,"user",coder.Me,"Specify the user whose resources to target")
7072
cmd.Flags().BoolVar(&follow,"follow",false,"follow build log after initiating rebuild")
7173
cmd.Flags().BoolVar(&force,"force",false,"force rebuild without showing a confirmation prompt")
7274
returncmd
@@ -136,7 +138,8 @@ func trailBuildLogs(ctx context.Context, client *coder.Client, envID string) err
136138
returnnil
137139
}
138140

139-
funcwatchBuildLogCommand(user*string)*cobra.Command {
141+
funcwatchBuildLogCommand()*cobra.Command {
142+
varuserstring
140143
cmd:=&cobra.Command{
141144
Use:"watch-build [environment_name]",
142145
Example:"coder envs watch-build front-end-env",
@@ -148,7 +151,7 @@ func watchBuildLogCommand(user *string) *cobra.Command {
148151
iferr!=nil {
149152
returnerr
150153
}
151-
env,err:=findEnv(ctx,client,args[0],*user)
154+
env,err:=findEnv(ctx,client,args[0],user)
152155
iferr!=nil {
153156
returnerr
154157
}
@@ -159,5 +162,6 @@ func watchBuildLogCommand(user *string) *cobra.Command {
159162
returnnil
160163
},
161164
}
165+
cmd.Flags().StringVar(&user,"user",coder.Me,"Specify the user whose resources to target")
162166
returncmd
163167
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp