forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
register_tsb.go
46 lines (38 loc) · 1.53 KB
/
register_tsb.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
45
46
package register_template_service_broker
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/dockerhelper"
"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 RegisterTemplateServiceBroker(dockerClient dockerhelper.Interface, ocImage, baseDir, configDir, 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(
ocImage,
baseDir,
params).Install(dockerClient, logDir)
}