main: rename list-images to list

Rename the `list-images` command to `list`. We don't have `-image(s)` in
our other subcommands so this is for consistency.

We keep a `list-images` alias behind for compatibility reasons.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2025-03-31 11:57:27 +02:00 committed by Michael Vogt
parent a963712152
commit 274a75387b
5 changed files with 27 additions and 26 deletions

View file

@ -74,7 +74,7 @@ $ sudo dnf install osbuild osbuild-depsolve-dnf
To see the list of buildable images run: To see the list of buildable images run:
```console ```console
$ image-builder list-images $ image-builder list
... ...
centos-9 type:qcow2 arch:x86_64 centos-9 type:qcow2 arch:x86_64
... ...
@ -161,7 +161,7 @@ after they are built.
When listing images, it is possible to filter: When listing images, it is possible to filter:
```console ```console
$ image-builder list-images --filter ami $ image-builder list --filter ami
... ...
centos-9 type:ami arch:x86_64 centos-9 type:ami arch:x86_64
... ...
@ -171,7 +171,7 @@ rhel-10.0 type:ami arch:aarch64
``` ```
or be more specific or be more specific
```console ```console
$ image-builder list-images --filter "arch:x86*" --filter "distro:*centos*" $ image-builder list --filter "arch:x86*" --filter "distro:*centos*"
centos-9 type:ami arch:x86_64 centos-9 type:ami arch:x86_64
... ...
centos-9 type:qcow2 arch:x86_64 centos-9 type:qcow2 arch:x86_64
@ -188,7 +188,7 @@ The following filters are currently supported, shell-style globbing is supported
The text format can also be switched, supported are "text", "json": The text format can also be switched, supported are "text", "json":
```console ```console
$ image-builder list-images --format=json $ image-builder list --format=json
[ [
{ {
"distro": { "distro": {

View file

@ -42,7 +42,7 @@ func getOneImage(distroName, imgTypeStr, archStr string, repoOpts *repoOptions)
return nil, err return nil, err
} }
// strip prefixes to make ib copy/paste friendly when pasting output // strip prefixes to make ib copy/paste friendly when pasting output
// from "list-images" // from "list"
distroName = strings.TrimPrefix(distroName, "distro:") distroName = strings.TrimPrefix(distroName, "distro:")
imgTypeStr = strings.TrimPrefix(imgTypeStr, "type:") imgTypeStr = strings.TrimPrefix(imgTypeStr, "type:")
archStr = strings.TrimPrefix(archStr, "arch:") archStr = strings.TrimPrefix(archStr, "arch:")

View file

@ -392,16 +392,17 @@ operating systems like Fedora, CentOS and RHEL with easy customizations support.
rootCmd.SetOut(osStdout) rootCmd.SetOut(osStdout)
rootCmd.SetErr(osStderr) rootCmd.SetErr(osStderr)
listImagesCmd := &cobra.Command{ listCmd := &cobra.Command{
Use: "list-images", Use: "list",
Short: "List buildable images, use --filter to limit further", Short: "List buildable images, use --filter to limit further",
RunE: cmdListImages, RunE: cmdListImages,
SilenceUsage: true, SilenceUsage: true,
Args: cobra.NoArgs, Args: cobra.NoArgs,
Aliases: []string{"list-images"},
} }
listImagesCmd.Flags().StringArray("filter", nil, `Filter distributions by a specific criteria (e.g. "type:iot*")`) listCmd.Flags().StringArray("filter", nil, `Filter distributions by a specific criteria (e.g. "type:iot*")`)
listImagesCmd.Flags().String("format", "", "Output in a specific format (text, json)") listCmd.Flags().String("format", "", "Output in a specific format (text, json)")
rootCmd.AddCommand(listImagesCmd) rootCmd.AddCommand(listCmd)
manifestCmd := &cobra.Command{ manifestCmd := &cobra.Command{
Use: "manifest <image-type>", Use: "manifest <image-type>",

View file

@ -35,7 +35,7 @@ func TestListImagesNoArguments(t *testing.T) {
defer restore() defer restore()
for _, args := range [][]string{nil, []string{"--format=text"}} { for _, args := range [][]string{nil, []string{"--format=text"}} {
restore = main.MockOsArgs(append([]string{"list-images"}, args...)) restore = main.MockOsArgs(append([]string{"list"}, args...))
defer restore() defer restore()
var fakeStdout bytes.Buffer var fakeStdout bytes.Buffer
@ -55,7 +55,7 @@ func TestListImagesNoArgsOutputJSON(t *testing.T) {
restore := main.MockNewRepoRegistry(testrepos.New) restore := main.MockNewRepoRegistry(testrepos.New)
defer restore() defer restore()
restore = main.MockOsArgs([]string{"list-images", "--format=json"}) restore = main.MockOsArgs([]string{"list", "--format=json"})
defer restore() defer restore()
var fakeStdout bytes.Buffer var fakeStdout bytes.Buffer
@ -80,7 +80,7 @@ func TestListImagesFilteringSmoke(t *testing.T) {
restore := main.MockNewRepoRegistry(testrepos.New) restore := main.MockNewRepoRegistry(testrepos.New)
defer restore() defer restore()
restore = main.MockOsArgs([]string{"list-images", "--filter=centos*"}) restore = main.MockOsArgs([]string{"list", "--filter=centos*"})
defer restore() defer restore()
var fakeStdout bytes.Buffer var fakeStdout bytes.Buffer
@ -113,7 +113,7 @@ func TestListImagesErrorsOnExtraArgs(t *testing.T) {
restore := main.MockNewRepoRegistry(testrepos.New) restore := main.MockNewRepoRegistry(testrepos.New)
defer restore() defer restore()
restore = main.MockOsArgs(append([]string{"list-images"}, "extra-arg")) restore = main.MockOsArgs(append([]string{"list"}, "extra-arg"))
defer restore() defer restore()
var fakeStdout bytes.Buffer var fakeStdout bytes.Buffer
@ -121,7 +121,7 @@ func TestListImagesErrorsOnExtraArgs(t *testing.T) {
defer restore() defer restore()
err := main.Run() err := main.Run()
assert.EqualError(t, err, `unknown command "extra-arg" for "image-builder list-images"`) assert.EqualError(t, err, `unknown command "extra-arg" for "image-builder list"`)
} }
func hasDepsolveDnf() bool { func hasDepsolveDnf() bool {

View file

@ -5,7 +5,7 @@ After [installation](./00-installation.md) you probably want to use `image-build
Let's take a look at the available `x86_64` image types for Fedora 41 and build one of them. Let's take a look at the available `x86_64` image types for Fedora 41 and build one of them.
```console ```console
$ image-builder list-images --filter arch:x86_64 --filter distro:fedora-41 $ image-builder list --filter arch:x86_64 --filter distro:fedora-41
fedora-41 type:ami arch:x86_64 fedora-41 type:ami arch:x86_64
fedora-41 type:container arch:x86_64 fedora-41 type:container arch:x86_64
fedora-41 type:image-installer arch:x86_64 fedora-41 type:image-installer arch:x86_64
@ -29,21 +29,21 @@ $ sudo image-builder build --distro fedora-41 qcow2
# ... # ...
``` ```
## `image-builder list-images` ## `image-builder list`
The `list-images` command for `image-builder` lists the available built-in image types that can be built for the [built-in distributions](./10-faq.md#built-in-distributions). The `list` command for `image-builder` lists the available built-in image types that can be built for the [built-in distributions](./10-faq.md#built-in-distributions).
```console ```console
$ image-builder list-images $ image-builder list
# ... long list ... # ... long list ...
``` ```
### Format ### Format
The output format used by `list-images` can be swapped with the `--format` flag. Available types are `text` (for display in a terminal) and `json` which can be useful to consume programmatically: The output format used by `list` can be swapped with the `--format` flag. Available types are `text` (for display in a terminal) and `json` which can be useful to consume programmatically:
```console ```console
$ image-builder list-images --format=json | jq '.[0]' $ image-builder list --format=json | jq '.[0]'
{ {
"distro": { "distro": {
"name": "centos-9" "name": "centos-9"
@ -59,14 +59,14 @@ $ image-builder list-images --format=json | jq '.[0]'
### Filtering ### Filtering
`list-images` output can be filtered with the `--filter` argument. `list` output can be filtered with the `--filter` argument.
### Distribution ### Distribution
To filter on a given distribution, one can use `--filter` with the `distro:` prefix: To filter on a given distribution, one can use `--filter` with the `distro:` prefix:
```console ```console
$ image-builder list-images --filter distro:fedora-41 $ image-builder list --filter distro:fedora-41
# ... long list ... # ... long list ...
``` ```
@ -75,7 +75,7 @@ $ image-builder list-images --filter distro:fedora-41
To filter on a given [image type](./10-faq.md#image-types) the `type:` prefix: To filter on a given [image type](./10-faq.md#image-types) the `type:` prefix:
```console ```console
$ image-builder list-images --filter type:qcow2 $ image-builder list --filter type:qcow2
# ... long list ... # ... long list ...
``` ```
### Architecture ### Architecture
@ -83,7 +83,7 @@ $ image-builder list-images --filter type:qcow2
To filter on a given architecture use the `arch:` prefix: To filter on a given architecture use the `arch:` prefix:
```console ```console
$ image-builder list-images --filter arch:aarch64 $ image-builder list --filter arch:aarch64
# ... long list ... # ... long list ...
``` ```
@ -92,7 +92,7 @@ $ image-builder list-images --filter arch:aarch64
Filters can be combined to narrow the list further. Filters can be combined to narrow the list further.
```console ```console
$ image-builder list-images --filter type:qcow2 --filter distro:fedora-41 $ image-builder list --filter type:qcow2 --filter distro:fedora-41
# ... list ... # ... list ...
``` ```