Browse Source

Extract get_env_files()

Signed-off-by: Aanand Prasad <[email protected]>
Aanand Prasad 10 năm trước cách đây
mục cha
commit
dfc6206d0d
1 tập tin đã thay đổi với 9 bổ sung6 xóa
  1. 9 6
      compose/service.py

+ 9 - 6
compose/service.py

@@ -617,15 +617,18 @@ def split_port(port):
     return internal_port, (external_ip, external_port or None)
 
 
+def get_env_files(options):
+    env_files = options.get('env_file', [])
+    if not isinstance(env_files, list):
+        env_files = [env_files]
+    return env_files
+
+
 def merge_environment(options):
     env = {}
 
-    if 'env_file' in options:
-        if isinstance(options['env_file'], list):
-            for f in options['env_file']:
-                env.update(env_vars_from_file(f))
-        else:
-            env.update(env_vars_from_file(options['env_file']))
+    for f in get_env_files(options):
+        env.update(env_vars_from_file(f))
 
     if 'environment' in options:
         if isinstance(options['environment'], list):