Skip to content

Commit

Permalink
add template.openshift.io/bindable annotation, default is true
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Minter committed Nov 7, 2017
1 parent a604dc4 commit f92192f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/template/apis/template/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ const (
// should wait for the object to be ready before reporting the template
// instantiation complete.
WaitForReadyAnnotation = "template.alpha.openshift.io/wait-for-ready"

// BindableAnnotation indicates whether the template service broker should
// advertise the template as being bindable (default is true)
BindableAnnotation = "template.openshift.io/bindable"
)
6 changes: 4 additions & 2 deletions pkg/templateservicebroker/servicebroker/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ func serviceFromTemplate(template *templateapi.Template) *api.Service {
paramOrdering = append(paramOrdering, param.Name)
}

bindable := strings.ToLower(template.Annotations[templateapi.BindableAnnotation]) != "false"

plan := api.Plan{
ID: string(template.UID), // TODO: this should be a unique value
Name: "default",
Description: "Default plan",
Free: true,
Bindable: true,
Bindable: bindable,
Schemas: api.Schema{
ServiceInstance: api.ServiceInstances{
Create: map[string]*jsschema.Schema{
Expand Down Expand Up @@ -106,7 +108,7 @@ func serviceFromTemplate(template *templateapi.Template) *api.Service {
ID: string(template.UID),
Description: description,
Tags: strings.Split(template.Annotations["tags"], ","),
Bindable: true,
Bindable: bindable,
Metadata: metadata,
Plans: []api.Plan{plan},
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/templateservicebroker/servicebroker/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,15 @@ func TestServiceFromTemplate(t *testing.T) {
}

template.Annotations["description"] = ""
template.Annotations[templateapi.BindableAnnotation] = "False"
service = serviceFromTemplate(template)
if service.Description != noDescriptionProvided {
t.Errorf("service.Description incorrectly set to %q", service.Description)
}
if service.Bindable {
t.Errorf("service.Bindable incorrectly set")
}
if service.Plans[0].Bindable {
t.Errorf("service.Plans[0].Bindable incorrectly set")
}
}

0 comments on commit f92192f

Please sign in to comment.