@@ -91,7 +91,13 @@ func findImg(ctx context.Context, client *coder.Client, email, imgName, orgName
91
91
return nil ,xerrors .New ("image name unset" )
92
92
}
93
93
94
- imgs ,err := getImgs (ctx ,client ,email ,orgName )
94
+ imgs ,err := getImgs (ctx ,
95
+ getImgsConf {
96
+ client :client ,
97
+ email :email ,
98
+ orgName :orgName ,
99
+ },
100
+ )
95
101
if err != nil {
96
102
return nil ,err
97
103
}
@@ -127,36 +133,42 @@ func findImg(ctx context.Context, client *coder.Client, email, imgName, orgName
127
133
)
128
134
}
129
135
130
- func getImgs (ctx context.Context ,client * coder.Client ,email ,orgName string ) ([]coder.Image ,error ) {
131
- u ,err := client .UserByEmail (ctx ,email )
136
+ type getImgsConf struct {
137
+ client * coder.Client
138
+ email string
139
+ orgName string
140
+ }
141
+
142
+ func getImgs (ctx context.Context ,conf getImgsConf ) ([]coder.Image ,error ) {
143
+ u ,err := conf .client .UserByEmail (ctx ,conf .email )
132
144
if err != nil {
133
145
return nil ,err
134
146
}
135
147
136
- orgs ,err := client .Organizations (ctx )
148
+ orgs ,err := conf . client .Organizations (ctx )
137
149
if err != nil {
138
150
return nil ,err
139
151
}
140
152
141
153
orgs = lookupUserOrgs (u ,orgs )
142
154
143
155
for _ ,org := range orgs {
144
- imgs ,err := client .GetOrganizationImages (ctx ,org .ID )
156
+ imgs ,err := conf . client .GetOrganizationImages (ctx ,org .ID )
145
157
if err != nil {
146
158
return nil ,err
147
159
}
148
160
// If orgName is set we know the user is a multi-org member
149
161
// so we should only return the imported images that beong to the org they specified.
150
- if orgName != "" && orgName == org .Name {
162
+ if conf . orgName != "" && conf . orgName == org .Name {
151
163
return imgs ,nil
152
164
}
153
165
154
- if orgName == "" {
166
+ if conf . orgName == "" {
155
167
// if orgName is unset we know the user is only part of one org.
156
168
return imgs ,nil
157
169
}
158
170
}
159
- return nil ,xerrors .Errorf ("org name %q not found" ,orgName )
171
+ return nil ,xerrors .Errorf ("org name %q not found" ,conf . orgName )
160
172
}
161
173
162
174
func isMultiOrgMember (ctx context.Context ,email string ) (* bool ,error ) {