Skip to content

Commit

Permalink
feat(deploy): use sed for hacking generate helm manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
weixiao-huang authored and huangweixiao committed Sep 1, 2022
1 parent 031daf9 commit de2a44e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
41 changes: 22 additions & 19 deletions deploy/helm/virtink/templates/virt-controller/manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: {{ include "virtink.fullname" . }}
creationTimestamp: null
name: virt-controller
annotations:
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ .Values.virtController.name }}-cert
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/virt-controller-cert
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: {{ .Values.virtController.name }}
name: virt-controller
namespace: {{ .Release.Namespace }}
path: /mutate-v1alpha1-virtualmachine
failurePolicy: Fail
Expand All @@ -30,16 +32,17 @@ webhooks:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: {{ include "virtink.fullname" . }}
creationTimestamp: null
name: virt-controller
annotations:
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ .Values.virtController.name }}-cert
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/virt-controller-cert
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: {{ .Values.virtController.name }}
name: virt-controller
namespace: {{ .Release.Namespace }}
path: /validate-v1alpha1-virtualmachine
failurePolicy: Fail
Expand All @@ -56,23 +59,23 @@ webhooks:
- virtualmachines
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
- v1
- v1beta1
clientConfig:
service:
name: {{ .Values.virtController.name }}
name: virt-controller
namespace: {{ .Release.Namespace }}
path: /validate-v1alpha1-virtualmachinemigration
failurePolicy: Fail
name: validate.virtualmachinemigration.v1alpha1.virt.virtink.smartx.com
rules:
- apiGroups:
- virt.virtink.smartx.com
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- virtualmachinemigrations
sideEffects: None
- apiGroups:
- virt.virtink.smartx.com
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- virtualmachinemigrations
sideEffects: None
13 changes: 13 additions & 0 deletions hack/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,17 @@ controller-gen paths=./cmd/virt-controller/... paths=./pkg/controller/... rbac:r
controller-gen paths=./cmd/virt-daemon/... paths=./pkg/daemon/... rbac:roleName=virt-daemon \
output:rbac:artifacts:config="$dir"/virt-daemon

# TODO: should use a more elegant way for editing generated manifests.yaml
replace=" name: virt-controller
annotations:
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/virt-controller-cert"

# Replace newlines with literal \n, replace \ -> \/ for sed replace below
replace="$(echo "${replace//$'\n'/\\n}" | sed "s/\//\\\\\//g")"

sed -i "s/ name: mutating-webhook-configuration/$replace/g;
s/ name: validating-webhook-configuration/$replace/g;
s/name: webhook-service/name: virt-controller/g;
s/namespace: system/namespace: {{ .Release.Namespace }}/g" "$dir"/virt-controller/manifests.yaml

go generate ./...

0 comments on commit de2a44e

Please sign in to comment.