mirror of
https://github.com/anchore/syft
synced 2024-11-10 06:14:16 +00:00
f9e09aef19
Signed-off-by: Keith Zantow <kzantow@gmail.com>
20 lines
532 B
Go
20 lines
532 B
Go
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)
|
|
}
|