Skip to content

Commit 6612d3b

Browse files
committed
WIP: Initial moving of generated files to helm
Signed-off-by: Todd Short <[email protected]>
1 parent 142e1f3 commit 6612d3b

File tree

13 files changed

+2464
-9
lines changed

13 files changed

+2464
-9
lines changed

Makefile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,19 @@ tidy:
141141
go mod tidy
142142

143143
.PHONY: manifests
144-
KUSTOMIZE_CATD_RBAC_DIR := config/base/catalogd/rbac
145-
KUSTOMIZE_CATD_WEBHOOKS_DIR := config/base/catalogd/webhook
146-
KUSTOMIZE_OPCON_RBAC_DIR := config/base/operator-controller/rbac
147-
BASE_COPY := helm/olmv1/base
144+
KUSTOMIZE_CATD_RBAC_DIR := helm/olmv1/base/catalogd/rbac
145+
KUSTOMIZE_CATD_WEBHOOKS_DIR := helm/olmv1/base/catalogd/webhook
146+
KUSTOMIZE_OPCON_RBAC_DIR := helm/olmv1/base/operator-controller/rbac
148147
# Due to https://github.com/kubernetes-sigs/controller-tools/issues/837 we can't specify individual files
149148
# So we have to generate them together and then move them into place
150149
manifests: $(CONTROLLER_GEN) $(KUSTOMIZE) #EXHELP Generate WebhookConfiguration, ClusterRole, and CustomResourceDefinition objects.
150+
mkdir -p helm/olmv1/base/catalogd/rbac
151+
mkdir -p helm/olmv1/base/catalogd/crd/standard
152+
mkdir -p helm/olmv1/base/catalogd/crd/experimental
153+
mkdir -p helm/olmv1/base/catalogd/webhook
154+
mkdir -p helm/olmv1/base/operator-controller/rbac
155+
mkdir -p helm/olmv1/base/operator-controller/crd/standard
156+
mkdir -p helm/olmv1/base/operator-controller/crd/experimental
151157
# Generate CRDs via our own generator
152158
hack/tools/update-crds.sh
153159
# Generate the remaining operator-controller standard manifests
@@ -160,16 +166,14 @@ manifests: $(CONTROLLER_GEN) $(KUSTOMIZE) #EXHELP Generate WebhookConfiguration,
160166
# Generate the remaining catalogd experimental manifests
161167
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) rbac:roleName=manager-role paths="./internal/catalogd/..." output:rbac:artifacts:config=$(KUSTOMIZE_CATD_RBAC_DIR)/experimental
162168
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) webhook paths="./internal/catalogd/..." output:webhook:artifacts:config=$(KUSTOMIZE_CATD_WEBHOOKS_DIR)/experimental
169+
# Update base config to include helm templates
170+
./hack/tools/update-yaml-labels-annotations.sh
163171
# Generate manifests stored in source-control
164172
mkdir -p $(MANIFEST_HOME)
165-
rm -rf $(BASE_COPY)
166-
mkdir -p $(BASE_COPY)
167-
cp -r config/base/* $(BASE_COPY)
168173
helm template olmv1 helm/olmv1 --values helm/standard.yaml > $(STANDARD_MANIFEST)
169174
helm template olmv1 helm/olmv1 --values helm/standard-e2e.yaml > $(STANDARD_E2E_MANIFEST)
170175
helm template olmv1 helm/olmv1 --values helm/experimental.yaml > $(EXPERIMENTAL_MANIFEST)
171176
helm template olmv1 helm/olmv1 --values helm/experimental-e2e.yaml > $(EXPERIMENTAL_E2E_MANIFEST)
172-
rm -rf $(BASE_COPY)
173177

174178
.PHONY: generate
175179
generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.

hack/tools/update-crds.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ for b in ${!modules[@]}; do
4242
# will not be generated for the standard channel - so we check the expected generated
4343
# file exists before copying it.
4444
FILE="${CRD_TMP}/${c}/${crds[${b}]}"
45-
[[ -e "${FILE}" ]] && cp "${FILE}" config/base/${modules[${b}]}/crd/${c}
45+
[[ -e "${FILE}" ]] && cp "${FILE}" helm/olmv1/base/${modules[${b}]}/crd/${c}
4646
done
4747
done
4848

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
filelist=(
6+
helm/olmv1/base/catalogd/rbac/experimental/*.yaml
7+
helm/olmv1/base/catalogd/rbac/standard/*.yaml
8+
helm/olmv1/base/catalogd/webhook/experimental/*.yaml
9+
helm/olmv1/base/catalogd/webhook/standard/*.yaml
10+
helm/olmv1/base/operator-controller/rbac/experimental/*.yaml
11+
helm/olmv1/base/operator-controller/rbac/standard/*.yaml
12+
)
13+
14+
for f in "${filelist[@]}"; do
15+
# Put in the temporary items
16+
yq -i '.metadata.annotations.replaceMe = "annotations"' "${f}"
17+
yq -i '.metadata.labels.replaceMe = "labels"' "${f}"
18+
# Replace with helm template - must be done last or yq will complain about the file format
19+
sed -i.bak 's/replaceMe: annotations/{{- include "olmv1.annoations" | nindent 4 }}/g' "${f}"
20+
sed -i.bak 's/replaceMe: labels/{{- include "olmv1.labels" | nindent 4 }}/g' "${f}"
21+
# Delete sed's backup file
22+
rm "${f}.bak"
23+
done

helm/olmv1/base/catalogd/crd/experimental/olm.operatorframework.io_clustercatalogs.yaml

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.

helm/olmv1/base/catalogd/crd/standard/olm.operatorframework.io_clustercatalogs.yaml

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: manager-role
6+
annotations:
7+
{{- include "olmv1.annoations" | nindent 4 }}
8+
labels:
9+
{{- include "olmv1.labels" | nindent 4 }}
10+
rules:
11+
- apiGroups:
12+
- olm.operatorframework.io
13+
resources:
14+
- clustercatalogs
15+
verbs:
16+
- create
17+
- delete
18+
- get
19+
- list
20+
- patch
21+
- update
22+
- watch
23+
- apiGroups:
24+
- olm.operatorframework.io
25+
resources:
26+
- clustercatalogs/finalizers
27+
verbs:
28+
- update
29+
- apiGroups:
30+
- olm.operatorframework.io
31+
resources:
32+
- clustercatalogs/status
33+
verbs:
34+
- get
35+
- patch
36+
- update
37+
---
38+
apiVersion: rbac.authorization.k8s.io/v1
39+
kind: Role
40+
metadata:
41+
name: manager-role
42+
namespace: olmv1-system
43+
annotations:
44+
{{- include "olmv1.annoations" | nindent 4 }}
45+
labels:
46+
{{- include "olmv1.labels" | nindent 4 }}
47+
rules:
48+
- apiGroups:
49+
- ""
50+
resources:
51+
- secrets
52+
- serviceaccounts
53+
verbs:
54+
- get
55+
- list
56+
- watch
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: manager-role
6+
annotations:
7+
{{- include "olmv1.annoations" | nindent 4 }}
8+
labels:
9+
{{- include "olmv1.labels" | nindent 4 }}
10+
rules:
11+
- apiGroups:
12+
- olm.operatorframework.io
13+
resources:
14+
- clustercatalogs
15+
verbs:
16+
- create
17+
- delete
18+
- get
19+
- list
20+
- patch
21+
- update
22+
- watch
23+
- apiGroups:
24+
- olm.operatorframework.io
25+
resources:
26+
- clustercatalogs/finalizers
27+
verbs:
28+
- update
29+
- apiGroups:
30+
- olm.operatorframework.io
31+
resources:
32+
- clustercatalogs/status
33+
verbs:
34+
- get
35+
- patch
36+
- update
37+
---
38+
apiVersion: rbac.authorization.k8s.io/v1
39+
kind: Role
40+
metadata:
41+
name: manager-role
42+
namespace: olmv1-system
43+
annotations:
44+
{{- include "olmv1.annoations" | nindent 4 }}
45+
labels:
46+
{{- include "olmv1.labels" | nindent 4 }}
47+
rules:
48+
- apiGroups:
49+
- ""
50+
resources:
51+
- secrets
52+
- serviceaccounts
53+
verbs:
54+
- get
55+
- list
56+
- watch
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
apiVersion: admissionregistration.k8s.io/v1
3+
kind: MutatingWebhookConfiguration
4+
metadata:
5+
name: mutating-webhook-configuration
6+
annotations:
7+
{{- include "olmv1.annoations" | nindent 4 }}
8+
labels:
9+
{{- include "olmv1.labels" | nindent 4 }}
10+
webhooks:
11+
- admissionReviewVersions:
12+
- v1
13+
clientConfig:
14+
service:
15+
name: webhook-service
16+
namespace: system
17+
path: /mutate-olm-operatorframework-io-v1-clustercatalog
18+
failurePolicy: Fail
19+
name: inject-metadata-name.olm.operatorframework.io
20+
rules:
21+
- apiGroups:
22+
- olm.operatorframework.io
23+
apiVersions:
24+
- v1
25+
operations:
26+
- CREATE
27+
- UPDATE
28+
resources:
29+
- clustercatalogs
30+
sideEffects: None
31+
timeoutSeconds: 10
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
apiVersion: admissionregistration.k8s.io/v1
3+
kind: MutatingWebhookConfiguration
4+
metadata:
5+
name: mutating-webhook-configuration
6+
annotations:
7+
{{- include "olmv1.annoations" | nindent 4 }}
8+
labels:
9+
{{- include "olmv1.labels" | nindent 4 }}
10+
webhooks:
11+
- admissionReviewVersions:
12+
- v1
13+
clientConfig:
14+
service:
15+
name: webhook-service
16+
namespace: system
17+
path: /mutate-olm-operatorframework-io-v1-clustercatalog
18+
failurePolicy: Fail
19+
name: inject-metadata-name.olm.operatorframework.io
20+
rules:
21+
- apiGroups:
22+
- olm.operatorframework.io
23+
apiVersions:
24+
- v1
25+
operations:
26+
- CREATE
27+
- UPDATE
28+
resources:
29+
- clustercatalogs
30+
sideEffects: None
31+
timeoutSeconds: 10

0 commit comments

Comments
 (0)