mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 14:02:26 +01:00
update anchore import to use the new format option
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
@@ -8,7 +8,8 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/anchore/syft/internal/presenter/packages"
|
||||
"github.com/anchore/syft/internal/formats"
|
||||
"github.com/anchore/syft/syft/format"
|
||||
|
||||
"github.com/wagoodman/go-progress"
|
||||
|
||||
@@ -26,7 +27,7 @@ type packageSBOMImportAPI interface {
|
||||
|
||||
func packageSbomModel(s source.Metadata, catalog *pkg.Catalog, d *distro.Distro, scope source.Scope) (*external.ImagePackageManifest, error) {
|
||||
var buf bytes.Buffer
|
||||
pres := packages.NewJSONPresenter(catalog, s, d, scope)
|
||||
pres := formats.ByOption(format.JSONOption).Presenter(catalog, &s, d)
|
||||
err := pres.Present(&buf)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to serialize results: %w", err)
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
model2 "github.com/anchore/syft/internal/formats/syftjson/model"
|
||||
|
||||
"github.com/anchore/syft/internal/presenter/packages"
|
||||
|
||||
"github.com/wagoodman/go-progress"
|
||||
@@ -94,13 +96,13 @@ func TestPackageSbomToModel(t *testing.T) {
|
||||
}
|
||||
|
||||
// unmarshal expected result
|
||||
var expectedDoc packages.JSONDocument
|
||||
var expectedDoc model2.Document
|
||||
if err := json.Unmarshal(buf.Bytes(), &expectedDoc); err != nil {
|
||||
t.Fatalf("unable to parse json doc: %+v", err)
|
||||
}
|
||||
|
||||
// unmarshal actual result
|
||||
var actualDoc packages.JSONDocument
|
||||
var actualDoc model2.Document
|
||||
if err := json.Unmarshal(modelJSON, &actualDoc); err != nil {
|
||||
t.Fatalf("unable to parse json doc: %+v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user