@@ -84,27 +84,23 @@ func findEnv(ctx context.Context, client *coder.Client, envName, userEmail strin
84
84
}
85
85
86
86
type findImgConf struct {
87
- client * coder.Client
88
87
email string
89
88
imgName string
90
89
orgName string
91
90
}
92
91
93
- func findImg (ctx context.Context , conf findImgConf ) (* coder.Image , error ) {
92
+ func findImg (ctx context.Context , client * coder. Client , conf findImgConf ) (* coder.Image , error ) {
94
93
switch {
95
94
case conf .email == "" :
96
95
return nil , xerrors .New ("user email unset" )
97
96
case conf .imgName == "" :
98
97
return nil , xerrors .New ("image name unset" )
99
98
}
100
99
101
- imgs , err := getImgs (ctx ,
102
- getImgsConf {
103
- client : conf .client ,
104
- email : conf .email ,
105
- orgName : conf .orgName ,
106
- },
107
- )
100
+ imgs , err := getImgs (ctx , client , getImgsConf {
101
+ email : conf .email ,
102
+ orgName : conf .orgName ,
103
+ })
108
104
if err != nil {
109
105
return nil , err
110
106
}
@@ -129,38 +125,37 @@ func findImg(ctx context.Context, conf findImgConf) (*coder.Image, error) {
129
125
return nil , xerrors .New ("image not found - did you forget to import this image?" )
130
126
}
131
127
132
- lines := []string {clog .Tipf ("Did you mean?" )}
128
+ lines := []string {clog .Hintf ("Did you mean?" )}
133
129
134
130
for _ , img := range possibleMatches {
135
- lines = append (lines , img .Repository )
131
+ lines = append (lines , fmt . Sprintf ( " %s" , img .Repository ) )
136
132
}
137
133
return nil , clog .Fatal (
138
- fmt .Sprintf ("Found %d possible matches for %q." , len ( possibleMatches ) , conf .imgName ),
134
+ fmt .Sprintf ("image %s not found" , conf .imgName ),
139
135
lines ... ,
140
136
)
141
137
}
142
138
143
139
type getImgsConf struct {
144
- client * coder.Client
145
140
email string
146
141
orgName string
147
142
}
148
143
149
- func getImgs (ctx context.Context , conf getImgsConf ) ([]coder.Image , error ) {
150
- u , err := conf . client .UserByEmail (ctx , conf .email )
144
+ func getImgs (ctx context.Context , client * coder. Client , conf getImgsConf ) ([]coder.Image , error ) {
145
+ u , err := client .UserByEmail (ctx , conf .email )
151
146
if err != nil {
152
147
return nil , err
153
148
}
154
149
155
- orgs , err := conf . client .Organizations (ctx )
150
+ orgs , err := client .Organizations (ctx )
156
151
if err != nil {
157
152
return nil , err
158
153
}
159
154
160
155
orgs = lookupUserOrgs (u , orgs )
161
156
162
157
for _ , org := range orgs {
163
- imgs , err := conf . client .OrganizationImages (ctx , org .ID )
158
+ imgs , err := client .OrganizationImages (ctx , org .ID )
164
159
if err != nil {
165
160
return nil , err
166
161
}
0 commit comments