refactor: move formats from internal into syft module (#1172)

This commit is contained in:
Chapman Pendery 2022-09-13 08:20:52 -07:00 committed by GitHub
parent c5dca001e2
commit 9097614f3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
185 changed files with 80 additions and 80 deletions

View File

@ -16,13 +16,13 @@ import (
"github.com/anchore/syft/cmd/syft/cli/packages" "github.com/anchore/syft/cmd/syft/cli/packages"
"github.com/anchore/syft/internal/bus" "github.com/anchore/syft/internal/bus"
"github.com/anchore/syft/internal/config" "github.com/anchore/syft/internal/config"
"github.com/anchore/syft/internal/formats/cyclonedxjson"
"github.com/anchore/syft/internal/formats/spdx22json"
"github.com/anchore/syft/internal/formats/syftjson"
"github.com/anchore/syft/internal/log" "github.com/anchore/syft/internal/log"
"github.com/anchore/syft/internal/ui" "github.com/anchore/syft/internal/ui"
"github.com/anchore/syft/syft" "github.com/anchore/syft/syft"
"github.com/anchore/syft/syft/event" "github.com/anchore/syft/syft/event"
"github.com/anchore/syft/syft/formats/cyclonedxjson"
"github.com/anchore/syft/syft/formats/spdx22json"
"github.com/anchore/syft/syft/formats/syftjson"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
"github.com/anchore/syft/syft/source" "github.com/anchore/syft/syft/source"
"github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/name"

View File

@ -3,8 +3,8 @@ package options
import ( import (
"fmt" "fmt"
"github.com/anchore/syft/internal/formats/table"
"github.com/anchore/syft/syft" "github.com/anchore/syft/syft"
"github.com/anchore/syft/syft/formats/table"
"github.com/anchore/syft/syft/pkg/cataloger" "github.com/anchore/syft/syft/pkg/cataloger"
"github.com/anchore/syft/syft/source" "github.com/anchore/syft/syft/source"
"github.com/spf13/cobra" "github.com/spf13/cobra"

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/anchore/syft/internal/formats/table"
"github.com/anchore/syft/internal/formats/template"
"github.com/anchore/syft/syft" "github.com/anchore/syft/syft"
"github.com/anchore/syft/syft/formats/table"
"github.com/anchore/syft/syft/formats/template"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
"github.com/hashicorp/go-multierror" "github.com/hashicorp/go-multierror"
) )

View File

@ -13,13 +13,13 @@ import (
"github.com/anchore/syft/internal/anchore" "github.com/anchore/syft/internal/anchore"
"github.com/anchore/syft/internal/bus" "github.com/anchore/syft/internal/bus"
"github.com/anchore/syft/internal/config" "github.com/anchore/syft/internal/config"
"github.com/anchore/syft/internal/formats/template"
"github.com/anchore/syft/internal/log" "github.com/anchore/syft/internal/log"
"github.com/anchore/syft/internal/ui" "github.com/anchore/syft/internal/ui"
"github.com/anchore/syft/internal/version" "github.com/anchore/syft/internal/version"
"github.com/anchore/syft/syft" "github.com/anchore/syft/syft"
"github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/artifact"
"github.com/anchore/syft/syft/event" "github.com/anchore/syft/syft/event"
"github.com/anchore/syft/syft/formats/template"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
"github.com/anchore/syft/syft/source" "github.com/anchore/syft/syft/source"
"github.com/wagoodman/go-partybus" "github.com/wagoodman/go-partybus"

View File

@ -12,13 +12,13 @@ import (
"github.com/anchore/syft/internal" "github.com/anchore/syft/internal"
"github.com/anchore/syft/internal/bus" "github.com/anchore/syft/internal/bus"
"github.com/anchore/syft/internal/config" "github.com/anchore/syft/internal/config"
"github.com/anchore/syft/internal/formats/syftjson"
"github.com/anchore/syft/internal/log" "github.com/anchore/syft/internal/log"
"github.com/anchore/syft/internal/ui" "github.com/anchore/syft/internal/ui"
"github.com/anchore/syft/internal/version" "github.com/anchore/syft/internal/version"
"github.com/anchore/syft/syft" "github.com/anchore/syft/syft"
"github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/artifact"
"github.com/anchore/syft/syft/event" "github.com/anchore/syft/syft/event"
"github.com/anchore/syft/syft/formats/syftjson"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
"github.com/anchore/syft/syft/source" "github.com/anchore/syft/syft/source"
"github.com/gookit/color" "github.com/gookit/color"

View File

@ -9,9 +9,9 @@ import (
"net/http" "net/http"
"github.com/anchore/client-go/pkg/external" "github.com/anchore/client-go/pkg/external"
"github.com/anchore/syft/internal/formats/syftjson"
syftjsonModel "github.com/anchore/syft/internal/formats/syftjson/model"
"github.com/anchore/syft/internal/log" "github.com/anchore/syft/internal/log"
"github.com/anchore/syft/syft/formats/syftjson"
syftjsonModel "github.com/anchore/syft/syft/formats/syftjson/model"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
"github.com/wagoodman/go-progress" "github.com/wagoodman/go-progress"
) )

View File

@ -9,8 +9,8 @@ import (
"testing" "testing"
"github.com/anchore/client-go/pkg/external" "github.com/anchore/client-go/pkg/external"
"github.com/anchore/syft/internal/formats/syftjson"
"github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/artifact"
"github.com/anchore/syft/syft/formats/syftjson"
"github.com/anchore/syft/syft/linux" "github.com/anchore/syft/syft/linux"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"

View File

@ -12,7 +12,7 @@ import (
"github.com/alecthomas/jsonschema" "github.com/alecthomas/jsonschema"
"github.com/anchore/syft/internal" "github.com/anchore/syft/internal"
syftjsonModel "github.com/anchore/syft/internal/formats/syftjson/model" syftjsonModel "github.com/anchore/syft/syft/formats/syftjson/model"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg"
) )

View File

@ -4,15 +4,15 @@ import (
"bytes" "bytes"
"strings" "strings"
"github.com/anchore/syft/internal/formats/cyclonedxjson" "github.com/anchore/syft/syft/formats/cyclonedxjson"
"github.com/anchore/syft/internal/formats/cyclonedxxml" "github.com/anchore/syft/syft/formats/cyclonedxxml"
"github.com/anchore/syft/internal/formats/github" "github.com/anchore/syft/syft/formats/github"
"github.com/anchore/syft/internal/formats/spdx22json" "github.com/anchore/syft/syft/formats/spdx22json"
"github.com/anchore/syft/internal/formats/spdx22tagvalue" "github.com/anchore/syft/syft/formats/spdx22tagvalue"
"github.com/anchore/syft/internal/formats/syftjson" "github.com/anchore/syft/syft/formats/syftjson"
"github.com/anchore/syft/internal/formats/table" "github.com/anchore/syft/syft/formats/table"
"github.com/anchore/syft/internal/formats/template" "github.com/anchore/syft/syft/formats/template"
"github.com/anchore/syft/internal/formats/text" "github.com/anchore/syft/syft/formats/text"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
) )

View File

@ -6,7 +6,7 @@ import (
"github.com/CycloneDX/cyclonedx-go" "github.com/CycloneDX/cyclonedx-go"
"github.com/anchore/packageurl-go" "github.com/anchore/packageurl-go"
"github.com/anchore/syft/internal/formats/common" "github.com/anchore/syft/syft/formats/common"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/source" "github.com/anchore/syft/syft/source"
) )

View File

@ -6,8 +6,8 @@ import (
"github.com/CycloneDX/cyclonedx-go" "github.com/CycloneDX/cyclonedx-go"
"github.com/anchore/syft/internal/formats/common"
"github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/artifact"
"github.com/anchore/syft/syft/formats/common"
"github.com/anchore/syft/syft/linux" "github.com/anchore/syft/syft/linux"
"github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
@ -38,7 +38,7 @@ func GetDecoder(format cyclonedx.BOMFileFormat) sbom.Decoder {
if err != nil { if err != nil {
return nil, err return nil, err
} }
s, err := toSyftModel(bom) s, err := ToSyftModel(bom)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -46,7 +46,7 @@ func GetDecoder(format cyclonedx.BOMFileFormat) sbom.Decoder {
} }
} }
func toSyftModel(bom *cyclonedx.BOM) (*sbom.SBOM, error) { func ToSyftModel(bom *cyclonedx.BOM) (*sbom.SBOM, error) {
if bom == nil { if bom == nil {
return nil, fmt.Errorf("no content defined in CycloneDX BOM") return nil, fmt.Errorf("no content defined in CycloneDX BOM")
} }

View File

@ -204,7 +204,7 @@ func Test_decode(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
sbom, err := toSyftModel(&test.input) sbom, err := ToSyftModel(&test.input)
assert.NoError(t, err) assert.NoError(t, err)
test: test:
@ -267,12 +267,12 @@ func Test_missingDataDecode(t *testing.T) {
Components: &[]cyclonedx.Component{}, Components: &[]cyclonedx.Component{},
} }
_, err := toSyftModel(bom) _, err := ToSyftModel(bom)
assert.NoError(t, err) assert.NoError(t, err)
bom.Metadata = &cyclonedx.Metadata{} bom.Metadata = &cyclonedx.Metadata{}
_, err = toSyftModel(bom) _, err = ToSyftModel(bom)
assert.NoError(t, err) assert.NoError(t, err)
pkg := decodeComponent(&cyclonedx.Component{ pkg := decodeComponent(&cyclonedx.Component{

View File

@ -3,7 +3,7 @@ package cyclonedxhelpers
import ( import (
"github.com/CycloneDX/cyclonedx-go" "github.com/CycloneDX/cyclonedx-go"
"github.com/anchore/syft/internal/formats/common" "github.com/anchore/syft/syft/formats/common"
) )
var ( var (

View File

@ -4,7 +4,7 @@ import (
"io" "io"
"github.com/CycloneDX/cyclonedx-go" "github.com/CycloneDX/cyclonedx-go"
"github.com/anchore/syft/internal/formats/common/cyclonedxhelpers" "github.com/anchore/syft/syft/formats/common/cyclonedxhelpers"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
) )

View File

@ -5,7 +5,7 @@ import (
"regexp" "regexp"
"testing" "testing"
"github.com/anchore/syft/internal/formats/common/testutils" "github.com/anchore/syft/syft/formats/common/testutils"
) )
var updateCycloneDx = flag.Bool("update-cyclonedx", false, "update the *.golden files for cyclone-dx encoders") var updateCycloneDx = flag.Bool("update-cyclonedx", false, "update the *.golden files for cyclone-dx encoders")

View File

@ -2,7 +2,7 @@ package cyclonedxjson
import ( import (
"github.com/CycloneDX/cyclonedx-go" "github.com/CycloneDX/cyclonedx-go"
"github.com/anchore/syft/internal/formats/common/cyclonedxhelpers" "github.com/anchore/syft/syft/formats/common/cyclonedxhelpers"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
) )

View File

@ -4,7 +4,7 @@ import (
"io" "io"
"github.com/CycloneDX/cyclonedx-go" "github.com/CycloneDX/cyclonedx-go"
"github.com/anchore/syft/internal/formats/common/cyclonedxhelpers" "github.com/anchore/syft/syft/formats/common/cyclonedxhelpers"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
) )

View File

@ -5,7 +5,7 @@ import (
"regexp" "regexp"
"testing" "testing"
"github.com/anchore/syft/internal/formats/common/testutils" "github.com/anchore/syft/syft/formats/common/testutils"
) )
var updateCycloneDx = flag.Bool("update-cyclonedx", false, "update the *.golden files for cyclone-dx encoders") var updateCycloneDx = flag.Bool("update-cyclonedx", false, "update the *.golden files for cyclone-dx encoders")

View File

@ -2,7 +2,7 @@ package cyclonedxxml
import ( import (
"github.com/CycloneDX/cyclonedx-go" "github.com/CycloneDX/cyclonedx-go"
"github.com/anchore/syft/internal/formats/common/cyclonedxhelpers" "github.com/anchore/syft/syft/formats/common/cyclonedxhelpers"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
) )

View File

@ -6,7 +6,7 @@ import (
"github.com/spdx/tools-golang/jsonloader" "github.com/spdx/tools-golang/jsonloader"
"github.com/anchore/syft/internal/formats/common/spdxhelpers" "github.com/anchore/syft/syft/formats/common/spdxhelpers"
"github.com/anchore/syft/syft/sbom" "github.com/anchore/syft/syft/sbom"
) )

View File

@ -5,7 +5,7 @@ import (
"regexp" "regexp"
"testing" "testing"
"github.com/anchore/syft/internal/formats/common/testutils" "github.com/anchore/syft/syft/formats/common/testutils"
) )
var updateSpdxJson = flag.Bool("update-spdx-json", false, "update the *.golden files for spdx-json encoders") var updateSpdxJson = flag.Bool("update-spdx-json", false, "update the *.golden files for spdx-json encoders")

View File

@ -1,6 +1,6 @@
package model package model
import "github.com/anchore/syft/internal/formats/common/spdxhelpers" import "github.com/anchore/syft/syft/formats/common/spdxhelpers"
// ElementID represents the identifier string portion of an SPDX element // ElementID represents the identifier string portion of an SPDX element
// identifier. DocElementID should be used for any attributes which can // identifier. DocElementID should be used for any attributes which can

View File

@ -1,6 +1,6 @@
package model package model
import "github.com/anchore/syft/internal/formats/common/spdxhelpers" import "github.com/anchore/syft/syft/formats/common/spdxhelpers"
type Package struct { type Package struct {
Item Item

Some files were not shown because too many files have changed in this diff Show More