Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --build-disk-image-only option to bootc plugin #3567

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tmt/schemas/provision/bootc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,8 @@ properties:
- xfs
- btrfs

build-disk-image-only:
type: boolean

required:
- how
27 changes: 27 additions & 0 deletions tmt/steps/provision/bootc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
from typing import TYPE_CHECKING, Optional, cast

import click

import tmt
import tmt.base
import tmt.hardware
Expand Down Expand Up @@ -152,6 +154,16 @@ class BootcData(tmt.steps.provision.testcloud.ProvisionTestcloudData):
""",
)

build_disk_image_only: bool = field(
default=False,
is_flag=True,
option='--build-disk-image-only',
help="""
Only build a bootc disk image from a container image and quit.
Guest VM will not start.
""",
)


@tmt.steps.provides_method('bootc')
class ProvisionBootc(tmt.steps.provision.ProvisionPlugin[BootcData]):
Expand Down Expand Up @@ -209,6 +221,16 @@ class ProvisionBootc(tmt.steps.provision.ProvisionPlugin[BootcData]):
_guest = None
_rootless = True

@property
def is_in_standalone_mode(self) -> bool:
"""
Enable standalone mode when build_disk_image_only is True
"""

if self.data.build_disk_image_only:
return True
return super().is_in_standalone_mode

def _get_id(self) -> str:
# FIXME: cast() - https://github.com/teemtee/tmt/issues/1372
parent = cast(tmt.steps.provision.Provision, self.parent)
Expand Down Expand Up @@ -410,6 +432,11 @@ def go(self, *, logger: Optional[tmt.log.Logger] = None) -> None:
built_image.rename(renamed_image)
data.image = f"file://{renamed_image}"

if data.build_disk_image_only:
self.info("The disk image is converted and saved")
click.echo(tmt.log.indent(data.image, level=2))
return

self._guest = GuestBootc(
logger=self._logger,
data=data,
Expand Down