image-builder: --extra-artifacts split
Split out `--extra-artifacts` into `--with-sbom` and `--with-manifest`. Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
parent
ee38c45122
commit
585d349d0f
2 changed files with 14 additions and 7 deletions
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"slices"
|
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
@ -86,7 +85,7 @@ func cmdManifestWrapper(cmd *cobra.Command, args []string, w io.Writer, archChec
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
extraArtifacts, err := cmd.Flags().GetStringArray("extra-artifacts")
|
withSBOM, err := cmd.Flags().GetBool("with-sbom")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -134,6 +133,12 @@ func cmdManifestWrapper(cmd *cobra.Command, args []string, w io.Writer, archChec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var extraArtifacts []string
|
||||||
|
|
||||||
|
if withSBOM {
|
||||||
|
extraArtifacts = append(extraArtifacts, "sbom")
|
||||||
|
}
|
||||||
|
|
||||||
opts := &manifestOptions{
|
opts := &manifestOptions{
|
||||||
OutputDir: outputDir,
|
OutputDir: outputDir,
|
||||||
BlueprintPath: blueprintPath,
|
BlueprintPath: blueprintPath,
|
||||||
|
|
@ -159,7 +164,8 @@ func cmdBuild(cmd *cobra.Command, args []string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
extraArtifacts, err := cmd.Flags().GetStringArray("extra-artifacts")
|
|
||||||
|
withManifest, err := cmd.Flags().GetBool("with-manifest")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -179,7 +185,7 @@ func cmdBuild(cmd *cobra.Command, args []string) error {
|
||||||
buildOpts := &buildOptions{
|
buildOpts := &buildOptions{
|
||||||
OutputDir: outputDir,
|
OutputDir: outputDir,
|
||||||
StoreDir: cacheDir,
|
StoreDir: cacheDir,
|
||||||
WriteManifest: slices.Contains(extraArtifacts, "manifest"),
|
WriteManifest: withManifest,
|
||||||
}
|
}
|
||||||
return buildImage(res, mf.Bytes(), buildOpts)
|
return buildImage(res, mf.Bytes(), buildOpts)
|
||||||
}
|
}
|
||||||
|
|
@ -201,7 +207,6 @@ operating sytsems like centos and RHEL with easy customizations support.`,
|
||||||
}
|
}
|
||||||
rootCmd.PersistentFlags().String("datadir", "", `Override the default data direcotry for e.g. custom repositories/*.json data`)
|
rootCmd.PersistentFlags().String("datadir", "", `Override the default data direcotry for e.g. custom repositories/*.json data`)
|
||||||
rootCmd.PersistentFlags().String("output-dir", "", `Put output into the specified direcotry`)
|
rootCmd.PersistentFlags().String("output-dir", "", `Put output into the specified direcotry`)
|
||||||
rootCmd.PersistentFlags().StringArray("extra-artifacts", nil, `Export extra artifacts to the output dir (supported: "sbom","manifest", can be given multiple times)`)
|
|
||||||
rootCmd.SetOut(osStdout)
|
rootCmd.SetOut(osStdout)
|
||||||
rootCmd.SetErr(osStderr)
|
rootCmd.SetErr(osStderr)
|
||||||
|
|
||||||
|
|
@ -231,6 +236,7 @@ operating sytsems like centos and RHEL with easy customizations support.`,
|
||||||
manifestCmd.Flags().String("ostree-parent", "", `OSTREE parent`)
|
manifestCmd.Flags().String("ostree-parent", "", `OSTREE parent`)
|
||||||
manifestCmd.Flags().String("ostree-url", "", `OSTREE url`)
|
manifestCmd.Flags().String("ostree-url", "", `OSTREE url`)
|
||||||
manifestCmd.Flags().Bool("use-librepo", true, `use librepo to download packages (disable if you use old versions of osbuild)`)
|
manifestCmd.Flags().Bool("use-librepo", true, `use librepo to download packages (disable if you use old versions of osbuild)`)
|
||||||
|
manifestCmd.Flags().Bool("with-sbom", false, `export SPDX SBOM document`)
|
||||||
rootCmd.AddCommand(manifestCmd)
|
rootCmd.AddCommand(manifestCmd)
|
||||||
|
|
||||||
buildCmd := &cobra.Command{
|
buildCmd := &cobra.Command{
|
||||||
|
|
@ -241,6 +247,7 @@ operating sytsems like centos and RHEL with easy customizations support.`,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
}
|
}
|
||||||
buildCmd.Flags().AddFlagSet(manifestCmd.Flags())
|
buildCmd.Flags().AddFlagSet(manifestCmd.Flags())
|
||||||
|
buildCmd.Flags().Bool("with-manifest", false, `export osbuild manifest`)
|
||||||
// XXX: add --rpmmd cache too and put under /var/cache/image-builder/dnf
|
// XXX: add --rpmmd cache too and put under /var/cache/image-builder/dnf
|
||||||
buildCmd.Flags().String("cache", "/var/cache/image-builder/store", `osbuild directory to cache intermediate build artifacts"`)
|
buildCmd.Flags().String("cache", "/var/cache/image-builder/store", `osbuild directory to cache intermediate build artifacts"`)
|
||||||
rootCmd.AddCommand(buildCmd)
|
rootCmd.AddCommand(buildCmd)
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@ func TestBuildIntegrationExtraArtifactsManifest(t *testing.T) {
|
||||||
"qcow2",
|
"qcow2",
|
||||||
"--distro", "centos-9",
|
"--distro", "centos-9",
|
||||||
"--cache", outputDir,
|
"--cache", outputDir,
|
||||||
"--extra-artifacts", "manifest",
|
"--with-manifest",
|
||||||
"--output-dir", outputDir,
|
"--output-dir", outputDir,
|
||||||
})
|
})
|
||||||
defer restore()
|
defer restore()
|
||||||
|
|
@ -488,7 +488,7 @@ func TestManifestIntegrationExtraArtifactsSBOMWithOutputDir(t *testing.T) {
|
||||||
"--arch=x86_64",
|
"--arch=x86_64",
|
||||||
"--distro=centos-9",
|
"--distro=centos-9",
|
||||||
fmt.Sprintf("--blueprint=%s", makeTestBlueprint(t, testBlueprint)),
|
fmt.Sprintf("--blueprint=%s", makeTestBlueprint(t, testBlueprint)),
|
||||||
"--extra-artifacts=sbom",
|
"--with-sbom",
|
||||||
"--output-dir", outputDir,
|
"--output-dir", outputDir,
|
||||||
})
|
})
|
||||||
defer restore()
|
defer restore()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue