You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/10/12 08:35:27 UTC

[GitHub] [airflow] sshivprasad commented on a diff in pull request #26951: Add env-file parameter to Docker Operator

sshivprasad commented on code in PR #26951:
URL: https://github.com/apache/airflow/pull/26951#discussion_r993157721


##########
airflow/providers/docker/operators/docker.py:
##########
@@ -304,10 +311,13 @@ def _run_image_with_mounts(self, target_mounts, add_tmp_variable: bool) -> list[
             docker_log_config['max-size'] = self.log_opts_max_size
         if self.log_opts_max_file is not None:
             docker_log_config['max-file'] = self.log_opts_max_file
+        env_file_vars = {}
+        if self.env_file is not None:
+            env_file_vars = self.unpack_environment_variables(self.env_file)
         self.container = self.cli.create_container(
             command=self.format_command(self.command),
             name=self.container_name,
-            environment={**self.environment, **self._private_environment},
+            environment={**self.environment, **self._private_environment, **env_file_vars},

Review Comment:
   Thank you @uranusjr
   Didn't think about the overriding.
   I am assuming that either environment or env-file would be used and not both at once since instead of setting in environment, it can as well be mentioned in the env-file with the rest of the variables, but of course that's just an assumption. I am unsure of what the prescribed norms are. If it is that environment has to override the env-file and private-environment overrides the rest, then I will change the order to `environment={**env_file_vars, **self.environment, **self._private_environment}`, mention the overriding bit in the docstring, and add a test case for that, if you think that's the right way to go? 



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org