Skip to content

Commit

Permalink
Koji: expose boot mode in image extra metadata
Browse files Browse the repository at this point in the history
Also extend the Koji test case to verify that the boot mode information
is in the build extra metadata and that it contains valid value.

Signed-off-by: Tomáš Hozza <[email protected]>
  • Loading branch information
thozza authored and ondrejbudai committed Aug 8, 2023
1 parent 0a5c820 commit 4ac6a7a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
4 changes: 3 additions & 1 deletion cmd/osbuild-koji-tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/osbuild/images/pkg/distro"
"github.com/osbuild/images/pkg/rpmmd"
"github.com/osbuild/osbuild-composer/internal/upload/koji"
)
Expand Down Expand Up @@ -180,7 +181,8 @@ func TestKojiImport(t *testing.T) {
RPMs: []rpmmd.RPM{},
Extra: koji.BuildOutputExtra{
Image: koji.ImageExtraInfo{
Arch: "noarch",
Arch: "noarch",
BootMode: distro.BOOT_LEGACY.String(),
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion cmd/osbuild-koji/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/google/uuid"
"github.com/osbuild/images/pkg/distro"
"github.com/osbuild/images/pkg/rpmmd"
"github.com/osbuild/osbuild-composer/internal/upload/koji"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -99,7 +100,8 @@ func main() {
RPMs: []rpmmd.RPM{},
Extra: koji.BuildOutputExtra{
Image: koji.ImageExtraInfo{
Arch: arch,
Arch: arch,
BootMode: distro.BOOT_NONE.String(), // TODO: put the correct boot mode here
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion cmd/osbuild-worker/jobimpl-koji-finalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
imageRPMs = rpmmd.DeduplicateRPMs(imageRPMs)

imgOutputExtraInfo := koji.ImageExtraInfo{
Arch: buildArgs.Arch,
Arch: buildArgs.Arch,
BootMode: buildArgs.ImageBootMode,
}
imgOutputsExtraInfo[args.KojiFilenames[i]] = imgOutputExtraInfo

Expand Down
8 changes: 6 additions & 2 deletions internal/upload/koji/koji.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@ type BuildRoot struct {
// ImageExtraInfo holds extra metadata about the image.
// This structure is shared for the Extra metadata of the output and the build.
type ImageExtraInfo struct {
// TODO: Ideally this is where the pipeline would be passed.
Arch string `json:"arch"` // TODO: why?
// Koji docs say: "should contain IDs that allow tracking the output back to the system in which it was generated"
// TODO: we should probably add some ID here, probably the OSBuildJob UUID?

Arch string `json:"arch"`
// Boot mode of the image
BootMode string `json:"boot_mode,omitempty"`
}

// BuildOutputExtra holds extra metadata associated with the build output.
Expand Down
13 changes: 13 additions & 0 deletions test/cases/koji.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ function verify_buildinfo() {
echo "Unexpected arch for '${image}'. Expected '${ARCH}', but got '${image_arch}'"
exit 1
fi

local image_boot_mode
image_boot_mode="$(echo "${image_metadata}" | jq -r '.boot_mode')"
# for now, check just that the boot mode is a valid value
case "${image_boot_mode}" in
"uefi"|"legacy"|"hybrid")
;;
"none"|*)
# for now, we don't upload any images that have 'none' as boot mode, although it is a valid value
echo "Unexpected boot mode for '${image}'. Expected 'uefi', 'legacy' or 'hybrid', but got '${image_boot_mode}'"
exit 1
;;
esac
done
}

Expand Down

0 comments on commit 4ac6a7a

Please sign in to comment.