jedcunningham commented on a change in pull request #18974:
URL: https://github.com/apache/airflow/pull/18974#discussion_r770007816



##########
File path: chart/tests/test_airflow_common.py
##########
@@ -130,3 +130,78 @@ def test_should_set_correct_helm_hooks_weight(self):
         )
         annotations = jmespath.search("metadata.annotations", docs[0])
         assert annotations["helm.sh/hook-weight"] == "0"
+
+    def test_should_disable_some_variables(self):
+        docs = render_chart(
+            values={
+                "enableBuiltInSecretVariables": {
+                    "AIRFLOW_CORE_FERNET_KEY": True,

Review comment:
       ```suggestion
                       "AIRFLOW__CORE__FERNET_KEY": True,
   ```

##########
File path: chart/templates/_helpers.yaml
##########
@@ -37,56 +37,74 @@ If release name contains chart name it will be used as a 
full name.
 {{/* Standard Airflow environment variables */}}
 {{- define "standard_airflow_environment" }}
   # Hard Coded Airflow Envs
+  {{- if .Values.enableBuiltInSecretVariables.AIRFLOW_CORE_FERNET_KEY }}

Review comment:
       ```suggestion
     {{- if .Values.enableBuiltInSecretVariables.AIRFLOW__CORE__FERNET_KEY }}
   ```

##########
File path: chart/tests/test_airflow_common.py
##########
@@ -130,3 +130,78 @@ def test_should_set_correct_helm_hooks_weight(self):
         )
         annotations = jmespath.search("metadata.annotations", docs[0])
         assert annotations["helm.sh/hook-weight"] == "0"
+
+    def test_should_disable_some_variables(self):
+        docs = render_chart(
+            values={
+                "enableBuiltInSecretVariables": {
+                    "AIRFLOW_CORE_FERNET_KEY": True,
+                    "AIRFLOW__CORE__SQL_ALCHEMY_CONN": False,
+                    "AIRFLOW_CONN_AIRFLOW_DB": True,
+                    "AIRFLOW__WEBSERVER__SECRET_KEY": False,
+                    "AIRFLOW__CELERY__CELERY_RESULT_BACKEND": True,
+                    "AIRFLOW__CELERY__RESULT_BACKEND": False,
+                    "AIRFLOW__CELERY__BROKER_URL": True,
+                    "AIRFLOW__ELASTICSEARCH__HOST": False,
+                    "AIRFLOW__ELASTICSEARCH__ELASTICSEARCH_HOST": True,
+                },
+            },
+            show_only=[
+                "templates/scheduler/scheduler-deployment.yaml",
+                "templates/workers/worker-deployment.yaml",
+                "templates/webserver/webserver-deployment.yaml",
+                "templates/triggerer/triggerer-deployment.yaml",
+            ],
+        )
+        expected_vars = [
+            'AIRFLOW__CORE__FERNET_KEY',
+            'AIRFLOW_CONN_AIRFLOW_DB',
+            'AIRFLOW__CELERY__CELERY_RESULT_BACKEND',
+            'AIRFLOW__CELERY__BROKER_URL',
+        ]
+        expected_vars_in_worker = ['DUMB_INIT_SETSID'] + expected_vars
+        for doc in docs:
+            component = doc['metadata']['labels']['component']
+            variables = expected_vars_in_worker if component == 'worker' else 
expected_vars
+            assert variables == jmespath.search(
+                "spec.template.spec.containers[0].env[*].name", doc
+            ), f"Wrong vars in {component}"
+
+    def test_have_all_variables(self):
+        docs = render_chart(
+            values={
+                "enableBuiltInSecretVariables": {
+                    "AIRFLOW_CORE_FERNET_KEY": True,

Review comment:
       ```suggestion
                       "AIRFLOW__CORE__FERNET_KEY": True,
   ```

##########
File path: chart/values.yaml
##########
@@ -220,6 +220,21 @@ secret: []
 #   secretName: ""
 #   secretKey: ""
 
+# Enables selected built-in secrets that are set via environment variables by 
default.
+# Those secrets are provided by the Helm Chart secrets by default but in some 
cases you
+# might want to provide some of those variables with _CMD or _SECRET variable, 
and you should
+# in this case disable setting of those variables by setting the relevant 
configuration to false.
+enableBuiltInSecretVariables:
+  AIRFLOW_CORE_FERNET_KEY: true

Review comment:
       ```suggestion
     AIRFLOW__CORE__FERNET_KEY: true
   ```

##########
File path: chart/values.yaml
##########
@@ -220,6 +220,21 @@ secret: []
 #   secretName: ""
 #   secretKey: ""
 
+# Enables selected built-in secrets that are set via environment variables by 
default.
+# Those secrets are provided by the Helm Chart secrets by default but in some 
cases you
+# might want to provide some of those variables with _CMD or _SECRET variable, 
and you should
+# in this case disable setting of those variables by setting the relevant 
configuration to false.
+enableBuiltInSecretVariables:

Review comment:
       ```suggestion
   enableBuiltInSecretEnvVars:
   ```
   
   Still on the fence with this name. I'll see if I can come up with something 
better.

##########
File path: chart/tests/test_airflow_common.py
##########
@@ -130,3 +130,78 @@ def test_should_set_correct_helm_hooks_weight(self):
         )
         annotations = jmespath.search("metadata.annotations", docs[0])
         assert annotations["helm.sh/hook-weight"] == "0"
+
+    def test_should_disable_some_variables(self):
+        docs = render_chart(
+            values={
+                "enableBuiltInSecretVariables": {
+                    "AIRFLOW_CORE_FERNET_KEY": True,
+                    "AIRFLOW__CORE__SQL_ALCHEMY_CONN": False,
+                    "AIRFLOW_CONN_AIRFLOW_DB": True,
+                    "AIRFLOW__WEBSERVER__SECRET_KEY": False,
+                    "AIRFLOW__CELERY__CELERY_RESULT_BACKEND": True,
+                    "AIRFLOW__CELERY__RESULT_BACKEND": False,
+                    "AIRFLOW__CELERY__BROKER_URL": True,
+                    "AIRFLOW__ELASTICSEARCH__HOST": False,
+                    "AIRFLOW__ELASTICSEARCH__ELASTICSEARCH_HOST": True,
+                },
+            },
+            show_only=[
+                "templates/scheduler/scheduler-deployment.yaml",
+                "templates/workers/worker-deployment.yaml",
+                "templates/webserver/webserver-deployment.yaml",
+                "templates/triggerer/triggerer-deployment.yaml",
+            ],
+        )
+        expected_vars = [
+            'AIRFLOW__CORE__FERNET_KEY',
+            'AIRFLOW_CONN_AIRFLOW_DB',
+            'AIRFLOW__CELERY__CELERY_RESULT_BACKEND',
+            'AIRFLOW__CELERY__BROKER_URL',
+        ]
+        expected_vars_in_worker = ['DUMB_INIT_SETSID'] + expected_vars
+        for doc in docs:
+            component = doc['metadata']['labels']['component']
+            variables = expected_vars_in_worker if component == 'worker' else 
expected_vars
+            assert variables == jmespath.search(
+                "spec.template.spec.containers[0].env[*].name", doc
+            ), f"Wrong vars in {component}"
+
+    def test_have_all_variables(self):
+        docs = render_chart(
+            values={
+                "enableBuiltInSecretVariables": {

Review comment:
       Since these are all true by default, do we really need to set them 
explicitly here?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to