diff --git a/charts/dotnet-core/Chart.yaml b/charts/dotnet-core/Chart.yaml index 8c8ac37..8a6df19 100644 --- a/charts/dotnet-core/Chart.yaml +++ b/charts/dotnet-core/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 description: EcoVadis Helm chart for .Net Core app name: charts-dotnet-core type: application -version: 4.9.0 +version: 4.10.0 dependencies: - name: charts-core version: "2.8.0" diff --git a/charts/dotnet-core/templates/deployment.yaml b/charts/dotnet-core/templates/deployment.yaml index 1f5b2f7..3ea87b0 100644 --- a/charts/dotnet-core/templates/deployment.yaml +++ b/charts/dotnet-core/templates/deployment.yaml @@ -173,7 +173,7 @@ spec: {{- end }} {{- end }} - {{- if or .Values.global.envVarsEnabled .Values.global.secEnvVarsEnabled }} + {{- if or .Values.global.envVarsEnabled .Values.global.secEnvVarsEnabled .Values.global.extraEnvFrom }} envFrom: {{- if .Values.global.envVarsEnabled }} - configMapRef: @@ -183,6 +183,9 @@ spec: - secretRef: name: "{{ include "charts-dotnet-core.fullname" . }}-secure" {{- end }} + {{- if .Values.global.extraEnvFrom }} + {{- toYaml .Values.global.extraEnvFrom | nindent 12 }} + {{- end }} {{- end }} env: - name: POD_NAME diff --git a/charts/dotnet-core/templates/tests/deployment_test.py b/charts/dotnet-core/templates/tests/deployment_test.py index 14c38f3..b58a401 100644 --- a/charts/dotnet-core/templates/tests/deployment_test.py +++ b/charts/dotnet-core/templates/tests/deployment_test.py @@ -648,6 +648,88 @@ def test_topology_spread_constraint_overwritten(self): ], jmespath.search("spec.template.spec.topologySpreadConstraints", docs[0])) + def test_should_add_extra_env_from_with_secret_ref(self): + docs = render_chart( + values={ + "global": { + "envVarsEnabled": False, + "secEnvVarsEnabled": False, + "extraEnvFrom": [ + { + "secretRef": { + "name": "my-existing-secret" + } + } + ] + } + }, + name=".", + show_only=["templates/deployment.yaml"] + ) + self.assertEqual( + "my-existing-secret", + jmespath.search( + "spec.template.spec.containers[0].envFrom[0].secretRef.name", docs[0]) + ) + + def test_should_add_extra_env_from_with_config_map_ref(self): + docs = render_chart( + values={ + "global": { + "envVarsEnabled": False, + "secEnvVarsEnabled": False, + "extraEnvFrom": [ + { + "configMapRef": { + "name": "my-existing-configmap" + } + } + ] + } + }, + name=".", + show_only=["templates/deployment.yaml"] + ) + self.assertEqual( + "my-existing-configmap", + jmespath.search( + "spec.template.spec.containers[0].envFrom[0].configMapRef.name", docs[0]) + ) + + def test_should_add_extra_env_from_alongside_existing_refs(self): + docs = render_chart( + values={ + "global": { + "envVarsEnabled": True, + "secEnvVarsEnabled": True, + "extraEnvFrom": [ + { + "secretRef": { + "name": "my-existing-secret" + } + } + ] + } + }, + name=".", + show_only=["templates/deployment.yaml"] + ) + self.assertEqual( + "RELEASE-NAME-charts-dotnet-core", + jmespath.search( + "spec.template.spec.containers[0].envFrom[0].configMapRef.name", docs[0]) + ) + self.assertEqual( + "RELEASE-NAME-charts-dotnet-core-secure", + jmespath.search( + "spec.template.spec.containers[0].envFrom[1].secretRef.name", docs[0]) + ) + self.assertEqual( + "my-existing-secret", + jmespath.search( + "spec.template.spec.containers[0].envFrom[2].secretRef.name", docs[0]) + ) + def test_fileshare_mount(self): share_name = "files" diff --git a/charts/dotnet-core/values.yaml b/charts/dotnet-core/values.yaml index 6fda5cd..51e5058 100644 --- a/charts/dotnet-core/values.yaml +++ b/charts/dotnet-core/values.yaml @@ -169,6 +169,12 @@ global: secEnvVarsEnabled: true secEnvVars: {} + extraEnvFrom: [] + # - secretRef: + # name: my-existing-secret + # - configMapRef: + # name: my-existing-configmap + appConfigFilesEnabled: true appConfigFiles: globPattern: "**.json"