cmd: --blueprint

Moves the blueprint argument to a named argument; freeing up space to
later be able to pass in multiple image types. This also slightly
simplifies the case where we're building without a blueprint available.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2025-01-16 09:45:31 +01:00 committed by Michael Vogt
parent ffb22eb837
commit c1c60a3c77
2 changed files with 11 additions and 6 deletions

View file

@ -84,15 +84,18 @@ func cmdManifestWrapper(cmd *cobra.Command, args []string, w io.Writer, archChec
return nil, err return nil, err
} }
var blueprintPath string blueprintPath, err := cmd.Flags().GetString("blueprint")
imgTypeStr := args[0] if err != nil {
if len(args) > 1 { return nil, err
blueprintPath = args[1]
} }
imgTypeStr := args[0]
bp, err := blueprintload.Load(blueprintPath) bp, err := blueprintload.Load(blueprintPath)
if err != nil { if err != nil {
return nil, err return nil, err
} }
distroStr, err = findDistro(distroStr, bp.Distro) distroStr, err = findDistro(distroStr, bp.Distro)
if err != nil { if err != nil {
return nil, err return nil, err
@ -176,6 +179,7 @@ operating sytsems like centos and RHEL with easy customizations support.`,
Args: cobra.RangeArgs(1, 2), Args: cobra.RangeArgs(1, 2),
Hidden: true, Hidden: true,
} }
manifestCmd.Flags().String("blueprint", "", `blueprint to customize an image`)
manifestCmd.Flags().String("arch", "", `build manifest for a different architecture`) manifestCmd.Flags().String("arch", "", `build manifest for a different architecture`)
manifestCmd.Flags().String("distro", "", `build manifest for a different distroname (e.g. centos-9)`) manifestCmd.Flags().String("distro", "", `build manifest for a different distroname (e.g. centos-9)`)
manifestCmd.Flags().String("ostree-ref", "", `OSTREE reference`) manifestCmd.Flags().String("ostree-ref", "", `OSTREE reference`)

View file

@ -3,6 +3,7 @@ package main_test
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"net/http" "net/http"
"os" "os"
@ -166,7 +167,7 @@ func TestManifestIntegrationSmoke(t *testing.T) {
"qcow2", "qcow2",
"--arch=x86_64", "--arch=x86_64",
"--distro=centos-9", "--distro=centos-9",
makeTestBlueprint(t, testBlueprint), fmt.Sprintf("--blueprint=%s", makeTestBlueprint(t, testBlueprint)),
}) })
defer restore() defer restore()
@ -318,7 +319,7 @@ func TestBuildIntegrationHappy(t *testing.T) {
restore = main.MockOsArgs([]string{ restore = main.MockOsArgs([]string{
"build", "build",
"qcow2", "qcow2",
makeTestBlueprint(t, testBlueprint), fmt.Sprintf("--blueprint=%s", makeTestBlueprint(t, testBlueprint)),
"--distro", "centos-9", "--distro", "centos-9",
"--store", tmpdir, "--store", tmpdir,
}) })