mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 08:53:15 +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:
parent
bd89e22fe5
commit
c6447cb62b
@ -8,7 +8,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"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"
|
"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) {
|
func packageSbomModel(s source.Metadata, catalog *pkg.Catalog, d *distro.Distro, scope source.Scope) (*external.ImagePackageManifest, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
pres := packages.NewJSONPresenter(catalog, s, d, scope)
|
pres := formats.ByOption(format.JSONOption).Presenter(catalog, &s, d)
|
||||||
err := pres.Present(&buf)
|
err := pres.Present(&buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to serialize results: %w", err)
|
return nil, fmt.Errorf("unable to serialize results: %w", err)
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
model2 "github.com/anchore/syft/internal/formats/syftjson/model"
|
||||||
|
|
||||||
"github.com/anchore/syft/internal/presenter/packages"
|
"github.com/anchore/syft/internal/presenter/packages"
|
||||||
|
|
||||||
"github.com/wagoodman/go-progress"
|
"github.com/wagoodman/go-progress"
|
||||||
@ -94,13 +96,13 @@ func TestPackageSbomToModel(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// unmarshal expected result
|
// unmarshal expected result
|
||||||
var expectedDoc packages.JSONDocument
|
var expectedDoc model2.Document
|
||||||
if err := json.Unmarshal(buf.Bytes(), &expectedDoc); err != nil {
|
if err := json.Unmarshal(buf.Bytes(), &expectedDoc); err != nil {
|
||||||
t.Fatalf("unable to parse json doc: %+v", err)
|
t.Fatalf("unable to parse json doc: %+v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// unmarshal actual result
|
// unmarshal actual result
|
||||||
var actualDoc packages.JSONDocument
|
var actualDoc model2.Document
|
||||||
if err := json.Unmarshal(modelJSON, &actualDoc); err != nil {
|
if err := json.Unmarshal(modelJSON, &actualDoc); err != nil {
|
||||||
t.Fatalf("unable to parse json doc: %+v", err)
|
t.Fatalf("unable to parse json doc: %+v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user