From f92192ff81d4572c89a207b0cb2d19fe7b9ebf23 Mon Sep 17 00:00:00 2001 From: Jim Minter Date: Tue, 7 Nov 2017 08:11:15 -0600 Subject: [PATCH] add template.openshift.io/bindable annotation, default is true --- pkg/template/apis/template/constants.go | 4 ++++ pkg/templateservicebroker/servicebroker/catalog.go | 6 ++++-- pkg/templateservicebroker/servicebroker/catalog_test.go | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/template/apis/template/constants.go b/pkg/template/apis/template/constants.go index 42012137a173..9445d2b11259 100644 --- a/pkg/template/apis/template/constants.go +++ b/pkg/template/apis/template/constants.go @@ -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" ) diff --git a/pkg/templateservicebroker/servicebroker/catalog.go b/pkg/templateservicebroker/servicebroker/catalog.go index 1cd19d0e722a..7bcd16a980f8 100644 --- a/pkg/templateservicebroker/servicebroker/catalog.go +++ b/pkg/templateservicebroker/servicebroker/catalog.go @@ -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{ @@ -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}, } diff --git a/pkg/templateservicebroker/servicebroker/catalog_test.go b/pkg/templateservicebroker/servicebroker/catalog_test.go index db7dd8675c8b..54d8997ea89e 100644 --- a/pkg/templateservicebroker/servicebroker/catalog_test.go +++ b/pkg/templateservicebroker/servicebroker/catalog_test.go @@ -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") + } }