cmd: add new describe-image command
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.
This commit is contained in:
parent
2455b9d586
commit
3c2e8dd9af
5 changed files with 235 additions and 3 deletions
|
|
@ -543,3 +543,27 @@ func TestManifestIntegrationWithSBOMWithOutputDir(t *testing.T) {
|
|||
assert.Equal(t, filepath.Join(outputDir, "centos-9-qcow2-x86_64.buildroot-build.spdx.json"), sboms[0])
|
||||
assert.Equal(t, filepath.Join(outputDir, "centos-9-qcow2-x86_64.image-os.spdx.json"), sboms[1])
|
||||
}
|
||||
|
||||
func TestDescribeImageSmoke(t *testing.T) {
|
||||
restore := main.MockNewRepoRegistry(testrepos.New)
|
||||
defer restore()
|
||||
|
||||
restore = main.MockOsArgs([]string{
|
||||
"describe-image",
|
||||
"qcow2",
|
||||
"--distro=centos-9",
|
||||
"--arch=x86_64",
|
||||
})
|
||||
defer restore()
|
||||
|
||||
var fakeStdout bytes.Buffer
|
||||
restore = main.MockOsStdout(&fakeStdout)
|
||||
defer restore()
|
||||
|
||||
err := main.Run()
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Contains(t, fakeStdout.String(), `distro: centos-9
|
||||
type: qcow2
|
||||
arch: x86_64`)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue