main: add new --store argument to image-builder build

This commit adds a new `--store` flag to the `image-builder build`
command. This is used to specify a osbuild store directory to
store the intermediate build tree for faster rebuilding. It is
also useful for the container version of `image-builder-cli` to
allow mapping the users store into the container.
This commit is contained in:
Michael Vogt 2024-12-18 10:55:21 +01:00
parent e5b3ccd6ed
commit b3f9fb88f1
3 changed files with 15 additions and 5 deletions

View file

@ -239,11 +239,13 @@ func TestBuildIntegrationHappy(t *testing.T) {
restore := main.MockNewRepoRegistry(testrepos.New)
defer restore()
tmpdir := t.TempDir()
restore = main.MockOsArgs([]string{
"build",
"qcow2",
makeTestBlueprint(t, testBlueprint),
"--distro", "centos-9",
"--store", tmpdir,
})
defer restore()
@ -256,8 +258,12 @@ func TestBuildIntegrationHappy(t *testing.T) {
// ensure osbuild was run exactly one
assert.Equal(t, 1, len(fakeOsbuildCmd.Calls()))
// and we passed the output dir
osbuildCall := fakeOsbuildCmd.Calls()[0]
// --store is passed correctly to osbuild
storePos := slices.Index(osbuildCall, "--store")
assert.True(t, storePos > -1)
assert.Equal(t, tmpdir, osbuildCall[storePos+1])
// and we passed the output dir
outputDirPos := slices.Index(osbuildCall, "--output-directory")
assert.True(t, outputDirPos > -1)
assert.Equal(t, "centos-9-qcow2-x86_64", osbuildCall[outputDirPos+1])