From: Daan De Meyer Date: Fri, 25 Aug 2023 09:33:12 +0000 (+0200) Subject: Move all environment handling into load_environment() X-Git-Tag: v16~33^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e424f14f820fd7ed73f9b3e17f9ef0d7c439da97;p=thirdparty%2Fmkosi.git Move all environment handling into load_environment() --- diff --git a/mkosi/config.py b/mkosi/config.py index 95e87f92c..8cebb6e23 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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)