dimberman commented on a change in pull request #4772: [AIRFLOW-3937]
KubernetesPodOperator support for envFrom configMapRef…
URL: https://github.com/apache/airflow/pull/4772#discussion_r266543286
##########
File path:
airflow/contrib/kubernetes/kubernetes_request_factory/kubernetes_request_factory.py
##########
@@ -131,15 +131,44 @@ def extract_volume_secrets(pod, req):
@staticmethod
def extract_env_and_secrets(pod, req):
- env_secrets = [s for s in pod.secrets if s.deploy_type == 'env']
- if len(pod.envs) > 0 or len(env_secrets) > 0:
+ envs_from_key_secrets = [
+ env for env in pod.secrets if env.deploy_type == 'env' and
hasattr(env, 'key')
+ ]
+
+ envs_from_secrets = [
+ env for env in pod.secrets if env.deploy_type == 'env' and not
hasattr(env, 'key')
+ ]
+
+ if pod.envs_from_configmaps or envs_from_secrets:
+ req['spec']['containers'][0]['envFrom'] = []
+
+ if len(pod.envs) > 0 or len(envs_from_key_secrets) > 0:
env = []
for k in pod.envs.keys():
env.append({'name': k, 'value': pod.envs[k]})
- for secret in env_secrets:
+ for secret in envs_from_key_secrets:
KubernetesRequestFactory.add_secret_to_env(env, secret)
+
req['spec']['containers'][0]['env'] = env
+ for secret in envs_from_secrets:
Review comment:
@ashb any thoughts on this? Perhaps we could move it into helper functions
but keep it in the same class?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services