@@ -83,19 +83,26 @@ func findEnv(ctx context.Context, client *coder.Client, envName, userEmail strin
83
83
)
84
84
}
85
85
86
- func findImg (ctx context.Context , client * coder.Client , email , imgName , orgName string ) (* coder.Image , error ) {
86
+ type findImgConf struct {
87
+ client * coder.Client
88
+ email string
89
+ imgName string
90
+ orgName string
91
+ }
92
+
93
+ func findImg (ctx context.Context , conf findImgConf ) (* coder.Image , error ) {
87
94
switch {
88
- case email == "" :
95
+ case conf . email == "" :
89
96
return nil , xerrors .New ("user email unset" )
90
- case imgName == "" :
97
+ case conf . imgName == "" :
91
98
return nil , xerrors .New ("image name unset" )
92
99
}
93
100
94
101
imgs , err := getImgs (ctx ,
95
102
getImgsConf {
96
- client : client ,
97
- email : email ,
98
- orgName : orgName ,
103
+ client : conf . client ,
104
+ email : conf . email ,
105
+ orgName : conf . orgName ,
99
106
},
100
107
)
101
108
if err != nil {
@@ -110,10 +117,10 @@ func findImg(ctx context.Context, client *coder.Client, email, imgName, orgName
110
117
// the user provided image flag value as a substring.
111
118
for _ , img := range imgs {
112
119
// If it's an exact match we can just return and exit.
113
- if img .Repository == imgName {
120
+ if img .Repository == conf . imgName {
114
121
return & img , nil
115
122
}
116
- if strings .Contains (img .Repository , imgName ) {
123
+ if strings .Contains (img .Repository , conf . imgName ) {
117
124
possibleMatches = append (possibleMatches , img )
118
125
}
119
126
}
@@ -128,7 +135,7 @@ func findImg(ctx context.Context, client *coder.Client, email, imgName, orgName
128
135
lines = append (lines , img .Repository )
129
136
}
130
137
return nil , 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 ),
132
139
lines ... ,
133
140
)
134
141
}
0 commit comments