@@ -48,11 +48,34 @@ help: ## Display this help.
4848manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
4949 $(CONTROLLER_GEN ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
5050 @echo " Syncing CRDs to Helm chart..."
51- @mkdir -p charts/homer-operator/crds
52- @cp config/crd/bases/homer.rajsingh.info_dashboards.yaml charts/homer-operator/crds/
53- @if [ -f charts/homer-operator/templates/crd.yaml ]; then \
54- echo " Removing old CRD template from charts/homer-operator/templates/crd.yaml" ; \
55- rm charts/homer-operator/templates/crd.yaml; \
51+ @mkdir -p charts/homer-operator/templates
52+ @cp scripts/sync-crd-to-helm.sh /tmp/sync-crd-to-helm.sh 2> /dev/null || true
53+ @if [ ! -f /tmp/sync-crd-to-helm.sh ]; then \
54+ echo ' #!/bin/bash' > /tmp/sync-crd-to-helm.sh; \
55+ echo ' cat <<EOF' >> /tmp/sync-crd-to-helm.sh; \
56+ echo ' {{- if .Values.crd.create }}' >> /tmp/sync-crd-to-helm.sh; \
57+ echo ' ---' >> /tmp/sync-crd-to-helm.sh; \
58+ echo ' apiVersion: apiextensions.k8s.io/v1' >> /tmp/sync-crd-to-helm.sh; \
59+ echo ' kind: CustomResourceDefinition' >> /tmp/sync-crd-to-helm.sh; \
60+ echo ' metadata:' >> /tmp/sync-crd-to-helm.sh; \
61+ echo ' name: dashboards.homer.rajsingh.info' >> /tmp/sync-crd-to-helm.sh; \
62+ echo ' labels:' >> /tmp/sync-crd-to-helm.sh; \
63+ echo ' {{- include "homer-operator.labels" . | nindent 4 }}' >> /tmp/sync-crd-to-helm.sh; \
64+ echo ' annotations:' >> /tmp/sync-crd-to-helm.sh; \
65+ echo ' controller-gen.kubebuilder.io/version: v0.14.0' >> /tmp/sync-crd-to-helm.sh; \
66+ echo ' {{- with .Values.crd.annotations }}' >> /tmp/sync-crd-to-helm.sh; \
67+ echo ' {{- toYaml . | nindent 4 }}' >> /tmp/sync-crd-to-helm.sh; \
68+ echo ' {{- end }}' >> /tmp/sync-crd-to-helm.sh; \
69+ echo ' spec:' >> /tmp/sync-crd-to-helm.sh; \
70+ echo ' EOF' >> /tmp/sync-crd-to-helm.sh; \
71+ echo ' tail -n +9 $$1 | head -n -1' >> /tmp/sync-crd-to-helm.sh; \
72+ echo ' echo "{{- end }}"' >> /tmp/sync-crd-to-helm.sh; \
73+ chmod +x /tmp/sync-crd-to-helm.sh; \
74+ fi
75+ @/tmp/sync-crd-to-helm.sh config/crd/bases/homer.rajsingh.info_dashboards.yaml > charts/homer-operator/templates/crd.yaml
76+ @if [ -d charts/homer-operator/crds ]; then \
77+ echo " Removing crds directory to use templates approach" ; \
78+ rm -rf charts/homer-operator/crds; \
5679 fi
5780
5881.PHONY : generate
0 commit comments