This commit adds a new `describe-image` comamnd that contains
the details about the given image type. The output is yaml as
it is both nicely human readable and also machine readable.
Note that this version carries an invalid yaml header on
purpose to avoid people replying on the feature for scripts
before it is stable.
The output looks like this:
```yaml
$ ./image-builder describe-image rhel-9.1 tar
@WARNING - the output format is not stable yet and may change
distro: rhel-9.1
type: tar
arch: x86_64
os_vesion: "9.1"
bootmode: none
partition_type: ""
default_filename: root.tar.xz
packages:
include:
- policycoreutils
- selinux-policy-targeted
- selinux-policy-targeted
exclude:
- rng-tools
```
Thanks to Ondrej Budai for the idea and the example.
60 lines
1.1 KiB
Go
60 lines
1.1 KiB
Go
package main_test
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
testrepos "github.com/osbuild/images/test/data/repositories"
|
|
|
|
"github.com/osbuild/image-builder-cli/cmd/image-builder"
|
|
)
|
|
|
|
func TestDescribeImage(t *testing.T) {
|
|
restore := main.MockNewRepoRegistry(testrepos.New)
|
|
defer restore()
|
|
|
|
res, err := main.GetOneImage("", "centos-9", "tar", "x86_64")
|
|
assert.NoError(t, err)
|
|
|
|
var buf bytes.Buffer
|
|
err = main.DescribeImage(res, &buf)
|
|
assert.NoError(t, err)
|
|
|
|
expectedOutput := `@WARNING - the output format is not stable yet and may change
|
|
distro: centos-9
|
|
type: tar
|
|
arch: x86_64
|
|
os_vesion: 9-stream
|
|
bootmode: none
|
|
partition_type: ""
|
|
default_filename: root.tar.xz
|
|
build_pipelines:
|
|
- build
|
|
payload_pipelines:
|
|
- os
|
|
- archive
|
|
packages:
|
|
build:
|
|
include:
|
|
- coreutils
|
|
- glibc
|
|
- platform-python
|
|
- policycoreutils
|
|
- python3
|
|
- rpm
|
|
- selinux-policy-targeted
|
|
- systemd
|
|
- tar
|
|
- xz
|
|
exclude: []
|
|
os:
|
|
include:
|
|
- policycoreutils
|
|
- selinux-policy-targeted
|
|
exclude:
|
|
- rng-tools
|
|
`
|
|
assert.Equal(t, expectedOutput, buf.String())
|
|
}
|