@@ -141,10 +141,13 @@ func (b *Broker) Bind(u user.Info, instanceID, bindingID string, breq *api.BindR
141
141
return api .BadRequest (errs .ToAggregate ())
142
142
}
143
143
144
+ glog .Infof ("1" )
145
+
144
146
if len (breq .Parameters ) != 0 {
145
147
return api .BadRequest (errors .New ("parameters not supported on bind" ))
146
148
}
147
149
150
+ glog .Infof ("2" )
148
151
brokerTemplateInstance , err := b .templateclient .BrokerTemplateInstances ().Get (instanceID , metav1.GetOptions {})
149
152
if err != nil {
150
153
if kerrors .IsNotFound (err ) {
@@ -156,6 +159,8 @@ func (b *Broker) Bind(u user.Info, instanceID, bindingID string, breq *api.BindR
156
159
157
160
namespace := brokerTemplateInstance .Spec .TemplateInstance .Namespace
158
161
162
+ glog .Infof ("3" )
163
+
159
164
// end users are not expected to have access to BrokerTemplateInstance
160
165
// objects; SAR on the TemplateInstance instead.
161
166
if err := util .Authorize (b .kc .Authorization ().SubjectAccessReviews (), u , & authorizationv1.ResourceAttributes {
@@ -171,6 +176,8 @@ func (b *Broker) Bind(u user.Info, instanceID, bindingID string, breq *api.BindR
171
176
// since we can, cross-check breq.ServiceID and
172
177
// templateInstance.Spec.Template.UID.
173
178
179
+ glog .Infof ("4" )
180
+
174
181
templateInstance , err := b .templateclient .TemplateInstances (namespace ).Get (brokerTemplateInstance .Spec .TemplateInstance .Name , metav1.GetOptions {})
175
182
if err != nil {
176
183
return api .InternalServerError (err )
@@ -184,7 +191,11 @@ func (b *Broker) Bind(u user.Info, instanceID, bindingID string, breq *api.BindR
184
191
185
192
credentials := map [string ]interface {}{}
186
193
194
+ glog .Infof ("5" )
195
+
187
196
for _ , object := range templateInstance .Status .Objects {
197
+ glog .Infof ("6" )
198
+
188
199
switch object .Ref .GroupVersionKind ().GroupKind () {
189
200
case kapi .Kind ("ConfigMap" ),
190
201
kapi .Kind ("Secret" ),
@@ -195,11 +206,15 @@ func (b *Broker) Bind(u user.Info, instanceID, bindingID string, breq *api.BindR
195
206
continue
196
207
}
197
208
209
+ glog .Infof ("7" )
210
+
198
211
mapping , err := b .restmapper .RESTMapping (object .Ref .GroupVersionKind ().GroupKind ())
199
212
if err != nil {
200
213
return api .InternalServerError (err )
201
214
}
202
215
216
+ glog .Infof ("8" )
217
+
203
218
if err := util .Authorize (b .kc .Authorization ().SubjectAccessReviews (), u , & authorizationv1.ResourceAttributes {
204
219
Namespace : object .Ref .Namespace ,
205
220
Verb : "get" ,
@@ -215,6 +230,8 @@ func (b *Broker) Bind(u user.Info, instanceID, bindingID string, breq *api.BindR
215
230
return api .InternalServerError (err )
216
231
}
217
232
233
+ glog .Infof ("9" )
234
+
218
235
obj , err := cli .Get ().Resource (mapping .Resource ).NamespaceIfScoped (object .Ref .Namespace , mapping .Scope .Name () == meta .RESTScopeNameNamespace ).Name (object .Ref .Name ).Do ().Get ()
219
236
if err != nil {
220
237
return api .InternalServerError (err )
@@ -229,6 +246,8 @@ func (b *Broker) Bind(u user.Info, instanceID, bindingID string, breq *api.BindR
229
246
return api .InternalServerError (kerrors .NewNotFound (schema.GroupResource {Group : mapping .GroupVersionKind .Group , Resource : mapping .Resource }, object .Ref .Name ))
230
247
}
231
248
249
+ glog .Infof ("10" )
250
+
232
251
err = updateCredentialsForObject (credentials , obj )
233
252
if err != nil {
234
253
return api .InternalServerError (err )
@@ -249,6 +268,8 @@ func (b *Broker) Bind(u user.Info, instanceID, bindingID string, breq *api.BindR
249
268
if status == http .StatusCreated { // binding not found; create it
250
269
// end users are not expected to have access to BrokerTemplateInstance
251
270
// objects; SAR on the TemplateInstance instead.
271
+ glog .Infof ("11" )
272
+
252
273
if err := util .Authorize (b .kc .Authorization ().SubjectAccessReviews (), u , & authorizationv1.ResourceAttributes {
253
274
Namespace : namespace ,
254
275
Verb : "update" ,
@@ -260,11 +281,14 @@ func (b *Broker) Bind(u user.Info, instanceID, bindingID string, breq *api.BindR
260
281
}
261
282
262
283
brokerTemplateInstance .Spec .BindingIDs = append (brokerTemplateInstance .Spec .BindingIDs , bindingID )
284
+ glog .Infof ("12" )
285
+
263
286
brokerTemplateInstance , err = b .templateclient .BrokerTemplateInstances ().Update (brokerTemplateInstance )
264
287
if err != nil {
265
288
return api .InternalServerError (err )
266
289
}
267
290
}
291
+ glog .Infof ("13" )
268
292
269
293
return api .NewResponse (status , & api.BindResponse {Credentials : credentials }, nil )
270
294
}
0 commit comments