forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
templateservicebroker.go
44 lines (37 loc) · 1.43 KB
/
templateservicebroker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package openshift
import (
"encoding/base64"
"io/ioutil"
"path/filepath"
"github.com/golang/glog"
"github.com/openshift/origin/pkg/oc/bootstrap"
"github.com/openshift/origin/pkg/oc/bootstrap/clusteradd/componentinstall"
"github.com/openshift/origin/pkg/oc/bootstrap/docker/errors"
)
const (
tsbNamespace = "openshift-template-service-broker"
)
// TODO this should be a controller based on the actual cluster state
// RegisterTemplateServiceBroker registers the TSB with the SC by creating the broker resource
func (h *Helper) RegisterTemplateServiceBroker(baseDir, configDir string, logdir string) error {
// Register the template broker with the service catalog
glog.V(2).Infof("registering the template broker with the service catalog")
serviceCABytes, err := ioutil.ReadFile(filepath.Join(configDir, "service-signer.crt"))
serviceCAString := base64.StdEncoding.EncodeToString(serviceCABytes)
if err != nil {
return errors.NewError("unable to read service signer cert").WithCause(err)
}
params := map[string]string{
"TSB_NAMESPACE": tsbNamespace,
"CA_BUNDLE": serviceCAString,
}
component := componentinstall.Template{
Name: "tsb-registration",
Namespace: tsbNamespace,
InstallTemplate: bootstrap.MustAsset("install/service-catalog-broker-resources/template-service-broker-registration.yaml"),
}
return component.MakeReady(
h.image,
baseDir,
params).Install(h.dockerHelper.Client(), logdir)
}