-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathmanifest.go
75 lines (67 loc) · 1.89 KB
/
manifest.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package lso
import (
"bytes"
"text/template"
)
func lsoSubscription() ([]byte, error) {
data := map[string]string{
"OPERATOR_NAMESPACE": Operator.Namespace,
"OPERATOR_SUBSCRIPTION_NAME": Operator.SubscriptionName,
}
const lsoSubscription = `apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: "{{.OPERATOR_SUBSCRIPTION_NAME}}"
namespace: "{{.OPERATOR_NAMESPACE}}"
spec:
installPlanApproval: Automatic
name: local-storage-operator
source: redhat-operators
sourceNamespace: openshift-marketplace`
tmpl, err := template.New("lsoSubscription").Parse(lsoSubscription)
if err != nil {
return nil, err
}
buf := &bytes.Buffer{}
err = tmpl.Execute(buf, data)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func Manifests() (map[string][]byte, []byte, error) {
lsoSubs, err := lsoSubscription()
if err != nil {
return nil, nil, err
}
openshiftManifests := make(map[string][]byte)
openshiftManifests["50_openshift-lso_ns.yaml"] = []byte(localStorageNamespace)
openshiftManifests["50_openshift-lso_operator_group.yaml"] = []byte(lsoOperatorGroup)
openshiftManifests["50_openshift-lso_subscription.yaml"] = lsoSubs
return openshiftManifests, []byte(localVolumeSet), nil
}
const lsoOperatorGroup = `apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
annotations:
olm.providedAPIs: LocalVolume.v1.local.storage.openshift.io
name: local-storage
namespace: openshift-local-storage
spec:
targetNamespaces:
- openshift-local-storage`
const localStorageNamespace = `apiVersion: v1
kind: Namespace
metadata:
name: openshift-local-storage`
const localVolumeSet = `apiVersion: "local.storage.openshift.io/v1alpha1"
kind: "LocalVolumeSet"
metadata:
name: "local-disks"
namespace: "openshift-local-storage"
spec:
storageClassName: "localblock-sc"
volumeMode: Block
deviceInclusionSpec:
deviceTypes:
- "disk"`