Skip to content

Commit

Permalink
docs: add simplest example from regsitry
Browse files Browse the repository at this point in the history
Signed-off-by: Keith Zantow <kzantow@gmail.com>
  • Loading branch information
kzantow committed Mar 5, 2024
1 parent 5bd1cd5 commit 452c81d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/source_from_registry/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"context"
"os"

"github.com/anchore/syft/syft"
"github.com/anchore/syft/syft/format/syftjson"
)

// This example demonstrates how to create an SBOM, pulling only from "registry", with error handling omitted
func main() {
image := "alpine:3.19"

src, _ := syft.GetSource(context.Background(), image, syft.DefaultGetSourceConfig().WithSources("registry"))

sbom, _ := syft.CreateSBOM(context.Background(), src, syft.DefaultCreateSBOMConfig())

_ = syftjson.NewFormatEncoder().Encode(os.Stdout, *sbom)
}

0 comments on commit 452c81d

Please sign in to comment.