]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Only query credentials when they're needed
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 15 Dec 2023 09:53:11 +0000 (10:53 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 16 Dec 2023 17:59:15 +0000 (18:59 +0100)
We might run commands that potentially need some time to complete so
let's only run them when needed.

mkosi/config.py

index 608e1b25bc20a15f541c84fe0ae4bad065e85cbb..320f770b55a1bb7c779318d66424d05042fce3eb 100644 (file)
@@ -87,6 +87,9 @@ class Verb(StrEnum):
     def needs_root(self) -> bool:
         return self in (Verb.shell, Verb.boot, Verb.burn)
 
+    def needs_credentials(self) -> bool:
+        return self in (Verb.summary, Verb.qemu, Verb.boot, Verb.shell)
+
 
 class ConfigFeature(StrEnum):
     auto     = enum.auto()
@@ -2794,6 +2797,9 @@ def parse_config(argv: Sequence[str] = ()) -> tuple[MkosiArgs, tuple[MkosiConfig
 
 
 def load_credentials(args: argparse.Namespace) -> dict[str, str]:
+    if not args.verb.needs_credentials():
+        return {}
+
     creds = {
         "agetty.autologin": "root",
         "login.noauth": "yes",