@@ -43,19 +43,21 @@ func (b *Broker) Unbind(u user.Info, instanceID, bindingID string) *api.Response
43
43
return api .Forbidden (err )
44
44
}
45
45
46
+ status := http .StatusGone
46
47
templateInstance , err := b .templateclient .TemplateInstances (namespace ).Get (brokerTemplateInstance .Spec .TemplateInstance .Name , metav1.GetOptions {})
47
48
if err != nil {
48
- return api .InternalServerError (err )
49
+ if ! kerrors .IsNotFound (err ) {
50
+ return api .InternalServerError (err )
51
+ }
49
52
}
50
- if strings .ToLower (templateInstance .Spec .Template .Annotations [templateapi .BindableAnnotation ]) == "false" {
53
+ if templateInstance != nil && strings .ToLower (templateInstance .Spec .Template .Annotations [templateapi .BindableAnnotation ]) == "false" {
51
54
return api .BadRequest (errors .New ("provisioned service is not bindable" ))
52
55
}
53
56
54
57
// The OSB API requires this function to be idempotent (restartable). If
55
58
// any actual change was made, per the spec, StatusOK is returned, else
56
59
// StatusGone.
57
60
58
- status := http .StatusGone
59
61
for i := 0 ; i < len (brokerTemplateInstance .Spec .BindingIDs ); i ++ {
60
62
for i < len (brokerTemplateInstance .Spec .BindingIDs ) && brokerTemplateInstance .Spec .BindingIDs [i ] == bindingID {
61
63
brokerTemplateInstance .Spec .BindingIDs = append (brokerTemplateInstance .Spec .BindingIDs [:i ], brokerTemplateInstance .Spec .BindingIDs [i + 1 :]... )
@@ -65,6 +67,8 @@ func (b *Broker) Unbind(u user.Info, instanceID, bindingID string) *api.Response
65
67
if status == http .StatusOK { // binding found; remove it
66
68
// end users are not expected to have access to BrokerTemplateInstance
67
69
// objects; SAR on the TemplateInstance instead.
70
+ // Note that this specific templateinstance object might not actually exist anymore, but the SAR check
71
+ // is still valid to confirm the user can update templateinstances in this namespace.
68
72
if err := util .Authorize (b .kc .Authorization ().SubjectAccessReviews (), u , & authorizationv1.ResourceAttributes {
69
73
Namespace : namespace ,
70
74
Verb : "update" ,
0 commit comments