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

Commite6daf5c

Browse files
author
Faris Huskovic
committed
collect find img params in struct
1 parent58b4d42 commite6daf5c

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

‎internal/cmd/ceapi.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,26 @@ func findEnv(ctx context.Context, client *coder.Client, envName, userEmail strin
8383
)
8484
}
8585

86-
funcfindImg(ctx context.Context,client*coder.Client,email,imgName,orgNamestring) (*coder.Image,error) {
86+
typefindImgConfstruct {
87+
client*coder.Client
88+
emailstring
89+
imgNamestring
90+
orgNamestring
91+
}
92+
93+
funcfindImg(ctx context.Context,conffindImgConf) (*coder.Image,error) {
8794
switch {
88-
caseemail=="":
95+
caseconf.email=="":
8996
returnnil,xerrors.New("user email unset")
90-
caseimgName=="":
97+
caseconf.imgName=="":
9198
returnnil,xerrors.New("image name unset")
9299
}
93100

94101
imgs,err:=getImgs(ctx,
95102
getImgsConf{
96-
client:client,
97-
email:email,
98-
orgName:orgName,
103+
client:conf.client,
104+
email:conf.email,
105+
orgName:conf.orgName,
99106
},
100107
)
101108
iferr!=nil {
@@ -110,10 +117,10 @@ func findImg(ctx context.Context, client *coder.Client, email, imgName, orgName
110117
// the user provided image flag value as a substring.
111118
for_,img:=rangeimgs {
112119
// If it's an exact match we can just return and exit.
113-
ifimg.Repository==imgName {
120+
ifimg.Repository==conf.imgName {
114121
return&img,nil
115122
}
116-
ifstrings.Contains(img.Repository,imgName) {
123+
ifstrings.Contains(img.Repository,conf.imgName) {
117124
possibleMatches=append(possibleMatches,img)
118125
}
119126
}
@@ -128,7 +135,7 @@ func findImg(ctx context.Context, client *coder.Client, email, imgName, orgName
128135
lines=append(lines,img.Repository)
129136
}
130137
returnnil,clog.Fatal(
131-
fmt.Sprintf("Found %d possible matches for %q.",len(possibleMatches),imgName),
138+
fmt.Sprintf("Found %d possible matches for %q.",len(possibleMatches),conf.imgName),
132139
lines...,
133140
)
134141
}

‎internal/cmd/envs.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,14 @@ coder envs create --cpu 4 --disk 100 --memory 8 --image 5f443b16-30652892427b955
181181
returnerr
182182
}
183183

184-
importedImg,err:=findImg(cmd.Context(),client,*user,img,org)
184+
importedImg,err:=findImg(cmd.Context(),
185+
findImgConf{
186+
client:client,
187+
email:*user,
188+
imgName:img,
189+
orgName:org,
190+
},
191+
)
185192
iferr!=nil {
186193
returnerr
187194
}
@@ -422,10 +429,12 @@ func buildUpdateReq(ctx context.Context, conf updateConf) (*coder.UpdateEnvironm
422429
// If this is not empty it means the user is requesting to change the environment image.
423430
ifconf.image!="" {
424431
importedImg,err:=findImg(ctx,
425-
conf.client,
426-
*conf.user,
427-
conf.image,
428-
conf.orgName,
432+
findImgConf{
433+
client:conf.client,
434+
email:*conf.user,
435+
imgName:conf.image,
436+
orgName:conf.orgName,
437+
},
429438
)
430439
iferr!=nil {
431440
returnnil,err

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp