Add a simple tool `osbuild-composer-image-definitions` which dumps the matrix of all distributions, architectures and image types names supported by composer as a JSON to the stdout. Default to fetching the image test case generation matrix directly from composer. This eliminates the need to update a JSON source file with this information every time a new distro or image type are added to composer. Delete the previously used JSON source file with the image test case generation matrix. Signed-off-by: Tomas Hozza <thozza@redhat.com>
35 lines
834 B
Go
35 lines
834 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
|
)
|
|
|
|
func main() {
|
|
definitions := map[string]map[string][]string{}
|
|
distroRegistry := distroregistry.NewDefault()
|
|
|
|
for _, distroName := range distroRegistry.List() {
|
|
distro := distroRegistry.GetDistro(distroName)
|
|
for _, archName := range distro.ListArches() {
|
|
arch, err := distro.GetArch(archName)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("failed to get arch %q of distro %q listed in aches list", archName, distroName))
|
|
}
|
|
_, ok := definitions[distroName]
|
|
if !ok {
|
|
definitions[distroName] = map[string][]string{}
|
|
}
|
|
definitions[distroName][archName] = arch.ListImageTypes()
|
|
}
|
|
}
|
|
|
|
encoder := json.NewEncoder(os.Stdout)
|
|
err := encoder.Encode(definitions)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|