The --engine flag was being added to positional_args before the "run"
subcommand, which resulted in incorrect lcitool invocations:

  lcitool container --engine podman run ...  (wrong)

This caused "invalid choice: 'podman'" errors because lcitool expected
a COMMAND argument at that position.

Fix by moving the --engine flag to opts array, which is added after
the "run" subcommand, resulting in the correct command structure:

  lcitool container run --engine podman ...  (correct)

Example:

 $ ./ci/helper run fedora-44 --job codestyle --engine podman
  usage: lcitool container [-h] COMMAND ...
 lcitool container: error: argument COMMAND: invalid choice: 'podman' (choose 
from engines, build, run, shell)

The same error happens if "--engine" option is set to different
than "auto" value.

Signed-off-by: Radoslaw Smigielski <[email protected]>
---
 ci/helper | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/ci/helper b/ci/helper
index 93508515cac8..c13ecd8c8404 100755
--- a/ci/helper
+++ b/ci/helper
@@ -173,9 +173,6 @@ class Application:
                 "website": "run_website_build",
             }
 
-            if self._args.engine != "auto":
-                positional_args.extend(["--engine", self._args.engine])
-
             with open(Path(tmpdir.name, "script"), "w") as f:
                 script_path = f.name
                 contents = textwrap.dedent(f"""\
@@ -190,6 +187,8 @@ class Application:
                 f.write(contents)
 
             positional_args.append("run")
+            if self._args.engine != "auto":
+                opts.extend(["--engine", self._args.engine])
             opts.extend(["--script", script_path])
 
         
opts.append(f"{self._args.image_prefix}{self._args.target}:{self._args.image_tag}")
-- 
2.54.0

Reply via email to