Browse Source

Merge pull request #910 from kinyat/feat/crds-create-flags

add create flags to each CRDs resources for a more fine-grained control
paul-the-alien[bot] 4 years ago
parent
commit
b3f7b7ac94
3 changed files with 23 additions and 6 deletions
  1. 15 6
      Makefile
  2. 2 0
      deploy/charts/external-secrets/README.md
  3. 6 0
      deploy/charts/external-secrets/values.yaml

+ 15 - 6
Makefile

@@ -174,15 +174,24 @@ helm.build: helm.generate ## Build helm chart
 	@mv $(OUTPUT_DIR)/chart/external-secrets-$(HELM_VERSION).tgz $(OUTPUT_DIR)/chart/external-secrets.tgz
 	@$(OK) helm package
 
-helm.generate: helm.docs ## Copy crds to helm chart directory
-	@cp $(BUNDLE_DIR)/*.yaml $(HELM_DIR)/templates/crds/
+helm.generate:
+# Split the generated bundle yaml file to inject control flags
+	@for i in $(BUNDLE_DIR)/*.yaml; do \
+		yq -Ns '"$(HELM_DIR)/templates/crds/" + .spec.names.singular' "$$i"; \
+	done
 # Add helm if statement for controlling the install of CRDs
-	@for i in $(HELM_DIR)/templates/crds/*.yaml; do \
-		cp "$$i" "$$i.bkp" && \
-		echo "{{- if .Values.installCRDs }}" > "$$i" && \
+	@for i in $(HELM_DIR)/templates/crds/*.yml; do \
+		export CRDS_FLAG_NAME="create$$(yq '.spec.names.kind' $$i)"; \
+		cp "$$i" "$$i.bkp"; \
+		if [[ "$$CRDS_FLAG_NAME" == *"Cluster"* ]]; then \
+			echo "{{- if and (.Values.installCRDs) (.Values.crds.$$CRDS_FLAG_NAME) }}" > "$$i"; \
+		else \
+			echo "{{- if .Values.installCRDs }}" > "$$i"; \
+		fi; \
 		cat "$$i.bkp" >> "$$i" && \
 		echo "{{- end }}" >> "$$i" && \
-		rm "$$i.bkp"; \
+		rm "$$i.bkp" && \
+		mv "$$i" "$${i%.yml}.yaml"; \
 	done
 	@$(OK) Finished generating helm chart files
 

+ 2 - 0
deploy/charts/external-secrets/README.md

@@ -63,6 +63,8 @@ The command removes all the Kubernetes components associated with the chart and
 | certController.tolerations | list | `[]` |  |
 | concurrent | int | `1` | Specifies the number of concurrent ExternalSecret Reconciles external-secret executes at a time. |
 | controllerClass | string | `""` | If set external secrets will filter matching Secret Stores with the appropriate controller values. |
+| crds.createClusterExternalSecret | bool | `true` | If true, create CRDs for Cluster External Secret. |
+| crds.createClusterSecretStore | bool | `true` | If true, create CRDs for Cluster Secret Store. |
 | createOperator | bool | `true` | Specifies whether an external secret operator deployment be created. |
 | deploymentAnnotations | object | `{}` | Annotations to add to Deployment |
 | extraArgs | object | `{}` |  |

+ 6 - 0
deploy/charts/external-secrets/values.yaml

@@ -9,6 +9,12 @@ image:
 # -- If set, install and upgrade CRDs through helm chart.
 installCRDs: true
 
+crds:
+  # -- If true, create CRDs for Cluster External Secret.
+  createClusterExternalSecret: true
+  # -- If true, create CRDs for Cluster Secret Store.
+  createClusterSecretStore: true
+
 imagePullSecrets: []
 nameOverride: ""
 fullnameOverride: ""