From 388e36739294874e024018e78c67aa624f87d3cc Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 16 Apr 2024 18:52:35 +0200 Subject: [PATCH] stages: add support for `--target-imgref` to bootc install to-filesystem We currently do not set the `--target-imgref` and do not allow to override it. This means that on a fresh deploy it is set to an incorrect value. This commit allows to set it via the org.osbuild.bootc.install-to-filesystem stage. --- stages/org.osbuild.bootc.install-to-filesystem | 3 +++ stages/org.osbuild.bootc.install-to-filesystem.meta.json | 4 ++++ stages/test/test_bootc_install_to_fs.py | 8 ++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/stages/org.osbuild.bootc.install-to-filesystem b/stages/org.osbuild.bootc.install-to-filesystem index fde611d3..6edcbf8f 100755 --- a/stages/org.osbuild.bootc.install-to-filesystem +++ b/stages/org.osbuild.bootc.install-to-filesystem @@ -40,6 +40,9 @@ def main(options, inputs, paths): # customize kernel-args for karg in options.get("kernel-args", []): pargs.extend(["--karg", karg]) + target_imgref = options.get("target-imgref") + if target_imgref: + pargs.extend(["--target-imgref", target_imgref]) # add target and go pargs.append(dst) subprocess.run(pargs, env=env, check=True) diff --git a/stages/org.osbuild.bootc.install-to-filesystem.meta.json b/stages/org.osbuild.bootc.install-to-filesystem.meta.json index db29e35d..f2367b52 100644 --- a/stages/org.osbuild.bootc.install-to-filesystem.meta.json +++ b/stages/org.osbuild.bootc.install-to-filesystem.meta.json @@ -40,6 +40,10 @@ "items": { "type": "string" } + }, + "target-imgref": { + "description": "Specify the image to fetch for subsequent updates", + "type": "string" } } }, diff --git a/stages/test/test_bootc_install_to_fs.py b/stages/test/test_bootc_install_to_fs.py index 36c53975..f31dc03e 100644 --- a/stages/test/test_bootc_install_to_fs.py +++ b/stages/test/test_bootc_install_to_fs.py @@ -53,9 +53,13 @@ FAKE_INPUTS = { ({"kernel-args": ["arg1", "arg2"]}, ["--karg", "arg1", "--karg", "arg2"]), # all ({"root-ssh-authorized-keys": ["key1", "key2"], - "kernel-args": ["arg1", "arg2"]}, + "kernel-args": ["arg1", "arg2"], + "target-imgref": "quay.io/img/ref", + }, ["--root-ssh-authorized-keys", "/tmp/fake-named-tmpfile-name", - "--karg", "arg1", "--karg", "arg2"], + "--karg", "arg1", "--karg", "arg2", + "--target-imgref", "quay.io/img/ref", + ], ), ]) @patch("subprocess.run")