mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 15:06:36 +01:00
Split the sbom.Format interface by encode and decode use cases (#2186)
* split up sbom.Format into encode and decode ops Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update cmd pkg to inject format configs Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bump cyclonedx schema to 1.5 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * redact image metadata from github encoder tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add more testing around format decoder identify Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add test case for format version options Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix cli tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix CLI test Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * [wip] - review comments Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * keep encoder creation out of post load function Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * keep decider and identify functions Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add a few more doc comments Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * remove format encoder default function helpers Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * address PR feedback Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * move back to streaming based decode functions Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * with common convention for encoder constructors Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix tests and allow for encoders to be created from cli options Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix cli tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix linting Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * buffer reads from stdin to support seeking Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -6,8 +6,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/anchore/syft/syft/formats"
|
||||
"github.com/anchore/syft/syft/formats/template"
|
||||
"github.com/anchore/syft/cmd/syft/cli/options"
|
||||
"github.com/anchore/syft/syft/format"
|
||||
"github.com/anchore/syft/syft/format/template"
|
||||
)
|
||||
|
||||
func TestAllFormatsExpressible(t *testing.T) {
|
||||
@@ -20,9 +21,15 @@ func TestAllFormatsExpressible(t *testing.T) {
|
||||
},
|
||||
assertSuccessfulReturnCode,
|
||||
}
|
||||
formatNames := formats.AllIDs()
|
||||
require.NotEmpty(t, formatNames)
|
||||
for _, o := range formatNames {
|
||||
|
||||
opts := options.DefaultOutput()
|
||||
encoders, err := opts.Encoders()
|
||||
require.NoError(t, err)
|
||||
|
||||
encs := format.NewEncoderCollection(encoders...)
|
||||
formatIDs := encs.IDs()
|
||||
require.NotEmpty(t, formatIDs)
|
||||
for _, o := range formatIDs {
|
||||
t.Run(fmt.Sprintf("format:%s", o), func(t *testing.T) {
|
||||
args := []string{"dir:./test-fixtures/image-pkg-coverage", "-o", string(o)}
|
||||
if o == template.ID {
|
||||
|
||||
Reference in New Issue
Block a user