main: initial version of image-builder with basic --list-images
This commit adds the new `image-builder` binary. This binary is meant to build images from the CLI without the need to setup a daemon. The main use-case is CI/CD and admins running this in scripts or ad-hoc. The CLI should be pleasant to use. This first commit adds the `list-images` command which is a thin wrapper around functionality from the `osbuild/images` library. It will list all buildable images by default and can be trimmed down further via `--filter` which supports the filtering from the `images` library, see https://github.com/osbuild/images/pull/1015 It also supports `--output` which will output the result in the given format. Currently "text" and "json" are supported. Note that this will not work on it's own yet, it will need an installed image-builder to get the repositories. This will need to get fixed via either: 1. a dependency package for `ibuilder` that carries all the repos 2. a shared repo that contains the repos 3. using go:embed to get them (see images#1038)
This commit is contained in:
parent
12d60a9c74
commit
7a838332c8
8 changed files with 813 additions and 0 deletions
44
cmd/image-builder/export_test.go
Normal file
44
cmd/image-builder/export_test.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/osbuild/images/pkg/reporegistry"
|
||||
)
|
||||
|
||||
func MockOsArgs(new []string) (restore func()) {
|
||||
saved := os.Args
|
||||
os.Args = append([]string{"argv0"}, new...)
|
||||
return func() {
|
||||
os.Args = saved
|
||||
}
|
||||
}
|
||||
|
||||
func MockOsStdout(new io.Writer) (restore func()) {
|
||||
saved := osStdout
|
||||
osStdout = new
|
||||
return func() {
|
||||
osStdout = saved
|
||||
}
|
||||
}
|
||||
|
||||
func MockOsStderr(new io.Writer) (restore func()) {
|
||||
saved := osStderr
|
||||
osStderr = new
|
||||
return func() {
|
||||
osStderr = saved
|
||||
}
|
||||
}
|
||||
|
||||
func MockNewRepoRegistry(f func() (*reporegistry.RepoRegistry, error)) (restore func()) {
|
||||
saved := newRepoRegistry
|
||||
newRepoRegistry = f
|
||||
return func() {
|
||||
newRepoRegistry = saved
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
Run = run
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue