cmd: implement manifest command
This commit implements the `manifest` command for `image-builder`.
It will generate an osbuild manifest based on the given inputs,
e.g.:
```
$ ./image-builder manifest centos-9 qcow2
{"version":"2","pipelines":[{"name":"build","runner":",...
```
Note that there is an integration test but because of the depsolve
it will be slow. It will be skipped when doing `go test -short`.
This commit is contained in:
parent
ea61ef593f
commit
830528fa15
5 changed files with 91 additions and 16 deletions
|
|
@ -3,6 +3,7 @@ package main_test
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
@ -11,6 +12,7 @@ import (
|
|||
testrepos "github.com/osbuild/images/test/data/repositories"
|
||||
|
||||
"github.com/osbuild/image-builder-cli/cmd/image-builder"
|
||||
"github.com/osbuild/image-builder-cli/internal/manifesttest"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -123,3 +125,38 @@ func TestListImagesErrorsOnExtraArgs(t *testing.T) {
|
|||
err := main.Run()
|
||||
assert.EqualError(t, err, `unknown command "extra-arg" for "image-builder list-images"`)
|
||||
}
|
||||
|
||||
func hasDepsolveDnf() bool {
|
||||
// XXX: expose images/pkg/depsolve:findDepsolveDnf()
|
||||
_, err := os.Stat("/usr/libexec/osbuild-depsolve-dnf")
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// XXX: move to pytest like bib maybe?
|
||||
func TestManifestIntegrationSmoke(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("manifest generation takes a while")
|
||||
}
|
||||
if !hasDepsolveDnf() {
|
||||
t.Skip("no osbuild-depsolve-dnf binary found")
|
||||
}
|
||||
|
||||
restore := main.MockNewRepoRegistry(testrepos.New)
|
||||
defer restore()
|
||||
|
||||
restore = main.MockOsArgs([]string{
|
||||
"manifest", "centos-9", "qcow2"},
|
||||
)
|
||||
defer restore()
|
||||
|
||||
var fakeStdout bytes.Buffer
|
||||
restore = main.MockOsStdout(&fakeStdout)
|
||||
defer restore()
|
||||
|
||||
err := main.Run()
|
||||
assert.NoError(t, err)
|
||||
|
||||
pipelineNames, err := manifesttest.PipelineNamesFrom(fakeStdout.Bytes())
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, pipelineNames, "qcow2")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue