Skip to content

Commit

Permalink
feat: add namespace arg when using 'merge' (#55)
Browse files Browse the repository at this point in the history
Signed-off-by: Ramkumar Chinchani <[email protected]>
  • Loading branch information
rchincha authored Jan 25, 2024
1 parent 52fb507 commit 363073d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/bom/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ func MergeMaps[K comparable, V any](map1 map[K]V, map2 map[K]V) map[K]V {
}

// MergeDocuments in a given dir.
func MergeDocuments(dir, name, author, organization, output string) error {
func MergeDocuments(dir, namespace, name, author, organization, output string) error {
sdoc := spdx.NewDocument()
sdoc.Namespace = namespace
sdoc.Name = name
sdoc.Creator.Person = author
sdoc.Creator.Organization = organization
Expand Down
5 changes: 4 additions & 1 deletion pkg/cli/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ stacker-bom merge --dir <bom-dir> --output <merged bom-file> --name <doc-name>
func MergeCmd() *cobra.Command {
dir := ""
output := ""
namespace := ""
name := ""

cmd := &cobra.Command{
Expand All @@ -27,7 +28,7 @@ func MergeCmd() *cobra.Command {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}

if err := bom.MergeDocuments(dir, name, Author, Organization, output); err != nil {
if err := bom.MergeDocuments(dir, namespace, name, Author, Organization, output); err != nil {
log.Error().Err(err).Msg("merge failed")
os.Exit(1)
}
Expand All @@ -38,6 +39,8 @@ func MergeCmd() *cobra.Command {
_ = cmd.MarkFlagRequired("dir")
cmd.Flags().StringVarP(&output, "output", "o", "", "output SBOM file")
_ = cmd.MarkFlagRequired("output")
cmd.Flags().StringVarP(&namespace, "namespace", "s", "", "document namespace of output SBOM file")
_ = cmd.MarkFlagRequired("namespace")
cmd.Flags().StringVarP(&name, "name", "n", "", "document name of output SBOM file")
_ = cmd.MarkFlagRequired("name")

Expand Down

0 comments on commit 363073d

Please sign in to comment.