Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f92192f

Browse files
author
Jim Minter
committedNov 7, 2017
add template.openshift.io/bindable annotation, default is true
1 parent a604dc4 commit f92192f

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed
 

‎pkg/template/apis/template/constants.go

+4
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ const (
3535
// should wait for the object to be ready before reporting the template
3636
// instantiation complete.
3737
WaitForReadyAnnotation = "template.alpha.openshift.io/wait-for-ready"
38+
39+
// BindableAnnotation indicates whether the template service broker should
40+
// advertise the template as being bindable (default is true)
41+
BindableAnnotation = "template.openshift.io/bindable"
3842
)

‎pkg/templateservicebroker/servicebroker/catalog.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ func serviceFromTemplate(template *templateapi.Template) *api.Service {
5555
paramOrdering = append(paramOrdering, param.Name)
5656
}
5757

58+
bindable := strings.ToLower(template.Annotations[templateapi.BindableAnnotation]) != "false"
59+
5860
plan := api.Plan{
5961
ID: string(template.UID), // TODO: this should be a unique value
6062
Name: "default",
6163
Description: "Default plan",
6264
Free: true,
63-
Bindable: true,
65+
Bindable: bindable,
6466
Schemas: api.Schema{
6567
ServiceInstance: api.ServiceInstances{
6668
Create: map[string]*jsschema.Schema{
@@ -106,7 +108,7 @@ func serviceFromTemplate(template *templateapi.Template) *api.Service {
106108
ID: string(template.UID),
107109
Description: description,
108110
Tags: strings.Split(template.Annotations["tags"], ","),
109-
Bindable: true,
111+
Bindable: bindable,
110112
Metadata: metadata,
111113
Plans: []api.Plan{plan},
112114
}

‎pkg/templateservicebroker/servicebroker/catalog_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,15 @@ func TestServiceFromTemplate(t *testing.T) {
135135
}
136136

137137
template.Annotations["description"] = ""
138+
template.Annotations[templateapi.BindableAnnotation] = "False"
138139
service = serviceFromTemplate(template)
139140
if service.Description != noDescriptionProvided {
140141
t.Errorf("service.Description incorrectly set to %q", service.Description)
141142
}
143+
if service.Bindable {
144+
t.Errorf("service.Bindable incorrectly set")
145+
}
146+
if service.Plans[0].Bindable {
147+
t.Errorf("service.Plans[0].Bindable incorrectly set")
148+
}
142149
}

0 commit comments

Comments
 (0)
Please sign in to comment.