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

Commit1b2e46d

Browse files
committed
Style cleanup
1 parent9ead247 commit1b2e46d

File tree

2 files changed

+35
-50
lines changed

2 files changed

+35
-50
lines changed

‎internal/cmd/ceapi.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,23 @@ func findEnv(ctx context.Context, client *coder.Client, envName, userEmail strin
8484
}
8585

8686
typefindImgConfstruct {
87-
client*coder.Client
8887
emailstring
8988
imgNamestring
9089
orgNamestring
9190
}
9291

93-
funcfindImg(ctx context.Context,conffindImgConf) (*coder.Image,error) {
92+
funcfindImg(ctx context.Context,client*coder.Client,conffindImgConf) (*coder.Image,error) {
9493
switch {
9594
caseconf.email=="":
9695
returnnil,xerrors.New("user email unset")
9796
caseconf.imgName=="":
9897
returnnil,xerrors.New("image name unset")
9998
}
10099

101-
imgs,err:=getImgs(ctx,
102-
getImgsConf{
103-
client:conf.client,
100+
imgs,err:=getImgs(ctx,client,getImgsConf{
104101
email:conf.email,
105102
orgName:conf.orgName,
106-
},
107-
)
103+
})
108104
iferr!=nil {
109105
returnnil,err
110106
}
@@ -129,38 +125,37 @@ func findImg(ctx context.Context, conf findImgConf) (*coder.Image, error) {
129125
returnnil,xerrors.New("image not found - did you forget to import this image?")
130126
}
131127

132-
lines:= []string{clog.Tipf("Did you mean?")}
128+
lines:= []string{clog.Hintf("Did you mean?")}
133129

134130
for_,img:=rangepossibleMatches {
135-
lines=append(lines,img.Repository)
131+
lines=append(lines,fmt.Sprintf(" %s",img.Repository))
136132
}
137133
returnnil,clog.Fatal(
138-
fmt.Sprintf("Found %d possible matches for %q.",len(possibleMatches),conf.imgName),
134+
fmt.Sprintf("image %s not found",conf.imgName),
139135
lines...,
140136
)
141137
}
142138

143139
typegetImgsConfstruct {
144-
client*coder.Client
145140
emailstring
146141
orgNamestring
147142
}
148143

149-
funcgetImgs(ctx context.Context,confgetImgsConf) ([]coder.Image,error) {
150-
u,err:=conf.client.UserByEmail(ctx,conf.email)
144+
funcgetImgs(ctx context.Context,client*coder.Client,confgetImgsConf) ([]coder.Image,error) {
145+
u,err:=client.UserByEmail(ctx,conf.email)
151146
iferr!=nil {
152147
returnnil,err
153148
}
154149

155-
orgs,err:=conf.client.Organizations(ctx)
150+
orgs,err:=client.Organizations(ctx)
156151
iferr!=nil {
157152
returnnil,err
158153
}
159154

160155
orgs=lookupUserOrgs(u,orgs)
161156

162157
for_,org:=rangeorgs {
163-
imgs,err:=conf.client.OrganizationImages(ctx,org.ID)
158+
imgs,err:=client.OrganizationImages(ctx,org.ID)
164159
iferr!=nil {
165160
returnnil,err
166161
}

‎internal/cmd/envs.go

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,11 @@ coder envs create --cpu 4 --disk 100 --memory 8 --image 5f443b16-30652892427b955
173173
returnxerrors.New("org is required for multi-org members")
174174
}
175175

176-
importedImg,err:=findImg(ctx,
177-
findImgConf{
178-
client:client,
179-
email:*user,
180-
imgName:img,
181-
orgName:org,
182-
},
183-
)
176+
importedImg,err:=findImg(ctx,client,findImgConf{
177+
email:*user,
178+
imgName:img,
179+
orgName:org,
180+
})
184181
iferr!=nil {
185182
returnerr
186183
}
@@ -225,7 +222,7 @@ coder envs create --cpu 4 --disk 100 --memory 8 --image 5f443b16-30652892427b955
225222

226223
clog.LogSuccess("creating environment...",
227224
clog.BlankLine,
228-
clog.Tipf(`run "coder envs watch-build %q" to trail the build logs`,env.Name),
225+
clog.Tipf(`run "coder envs watch-build %s" to trail the build logs`,env.Name),
229226
)
230227
returnnil
231228
},
@@ -292,20 +289,17 @@ coder envs edit back-end-env --disk 20`,
292289
diskGB,_=cmd.Flags().GetInt("disk")
293290
gpus,_=cmd.Flags().GetInt("gpus")
294291

295-
req,err:=buildUpdateReq(ctx,
296-
updateConf{
297-
cpu:cpuCores,
298-
memGB:memGB,
299-
diskGB:diskGB,
300-
gpus:gpus,
301-
client:client,
302-
environment:env,
303-
user:user,
304-
image:img,
305-
imageTag:tag,
306-
orgName:org,
307-
},
308-
)
292+
req,err:=buildUpdateReq(ctx,client,updateConf{
293+
cpu:cpuCores,
294+
memGB:memGB,
295+
diskGB:diskGB,
296+
gpus:gpus,
297+
environment:env,
298+
user:user,
299+
image:img,
300+
imageTag:tag,
301+
orgName:org,
302+
})
309303
iferr!=nil {
310304
returnerr
311305
}
@@ -324,7 +318,7 @@ coder envs edit back-end-env --disk 20`,
324318

325319
clog.LogSuccess("applied changes to the environment, rebuilding...",
326320
clog.BlankLine,
327-
clog.Tipf(`run "coder envs watch-build %q" to trail the build logs`,envName),
321+
clog.Tipf(`run "coder envs watch-build %s" to trail the build logs`,envName),
328322
)
329323
returnnil
330324
},
@@ -359,7 +353,7 @@ func rmEnvsCmd(user *string) *cobra.Command {
359353
}
360354
if_,err:=confirm.Run();err!=nil {
361355
returnclog.Fatal(
362-
"failed to confirmprompt",clog.BlankLine,
356+
"failed to confirmdeletion",clog.BlankLine,
363357
clog.Tipf(`use "--force" to rebuild without a confirmation prompt`),
364358
)
365359
}
@@ -395,15 +389,14 @@ type updateConf struct {
395389
memGBfloat32
396390
diskGBint
397391
gpusint
398-
client*coder.Client
399392
environment*coder.Environment
400393
user*string
401394
imagestring
402395
imageTagstring
403396
orgNamestring
404397
}
405398

406-
funcbuildUpdateReq(ctx context.Context,confupdateConf) (*coder.UpdateEnvironmentReq,error) {
399+
funcbuildUpdateReq(ctx context.Context,client*coder.Client,confupdateConf) (*coder.UpdateEnvironmentReq,error) {
407400
var (
408401
updateReq coder.UpdateEnvironmentReq
409402
defaultCPUCoresfloat32
@@ -413,14 +406,11 @@ func buildUpdateReq(ctx context.Context, conf updateConf) (*coder.UpdateEnvironm
413406

414407
// If this is not empty it means the user is requesting to change the environment image.
415408
ifconf.image!="" {
416-
importedImg,err:=findImg(ctx,
417-
findImgConf{
418-
client:conf.client,
419-
email:*conf.user,
420-
imgName:conf.image,
421-
orgName:conf.orgName,
422-
},
423-
)
409+
importedImg,err:=findImg(ctx,client,findImgConf{
410+
email:*conf.user,
411+
imgName:conf.image,
412+
orgName:conf.orgName,
413+
})
424414
iferr!=nil {
425415
returnnil,err
426416
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp