mirror of
https://github.com/anchore/syft.git
synced 2026-11-02 23:46:35 +01:00
Add support for multiple output files in different formats (#732)
This commit is contained in:
@@ -25,7 +25,7 @@ type packageSBOMImportAPI interface {
|
||||
func packageSbomModel(s sbom.SBOM) (*external.ImagePackageManifest, error) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
err := syftjson.Format().Presenter(s).Present(&buf)
|
||||
err := syftjson.Format().Encode(&buf, s)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to serialize results: %w", err)
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func packageSbomModel(s sbom.SBOM) (*external.ImagePackageManifest, error) {
|
||||
// the model is 1:1 the JSON output of today. As the schema changes, this will need to be converted into individual mappings.
|
||||
var model external.ImagePackageManifest
|
||||
if err = json.Unmarshal(buf.Bytes(), &model); err != nil {
|
||||
return nil, fmt.Errorf("unable to convert JSON presenter output to import model: %w", err)
|
||||
return nil, fmt.Errorf("unable to convert JSON output to import model: %w", err)
|
||||
}
|
||||
|
||||
return &model, nil
|
||||
|
||||
@@ -105,8 +105,7 @@ func TestPackageSbomToModel(t *testing.T) {
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
pres := syftjson.Format().Presenter(s)
|
||||
if err := pres.Present(&buf); err != nil {
|
||||
if err := syftjson.Format().Encode(&buf, s); err != nil {
|
||||
t.Fatalf("unable to get expected json: %+v", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user