mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
docs: add simplest example from regsitry (#2691)
Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
parent
d2ac672f8f
commit
f9e09aef19
20
examples/source_from_registry/main.go
Normal file
20
examples/source_from_registry/main.go
Normal file
@ -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)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user