]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Move all environment handling into load_environment()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 25 Aug 2023 09:33:12 +0000 (11:33 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 25 Aug 2023 13:37:57 +0000 (15:37 +0200)
mkosi/config.py

index 95e87f92c3879be1b7e23ecc2f18d838e169494a..8cebb6e23552dcac5c42ef01989fa199a7eaf294 100644 (file)
@@ -2032,8 +2032,12 @@ def load_environment(args: argparse.Namespace) -> dict[str, str]:
     if (proxy := os.environ.get("https_proxy")):
         env["https_proxy"] = proxy
 
-    # Mypy doesn't like | here.
-    return {**env, **args.environment}
+    for s in args.environment:
+        key, sep, value = s.partition("=")
+        value = value if sep else os.getenv(key, "")
+        env[key] = value
+
+    return env
 
 
 def load_args(args: argparse.Namespace) -> MkosiArgs:
@@ -2066,16 +2070,6 @@ def load_config(args: argparse.Namespace) -> MkosiConfig:
     if args.output is None:
         args.output = args.image_id or args.preset or "image"
 
-    if args.environment:
-        env = {}
-        for s in args.environment:
-            key, sep, value = s.partition("=")
-            value = value if sep else os.getenv(key, "")
-            env[key] = value
-        args.environment = env
-    else:
-        args.environment = {}
-
     args.credentials = load_credentials(args)
     args.kernel_command_line_extra = load_kernel_command_line_extra(args)
     args.environment = load_environment(args)