mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 16:06:36 +01:00
feat: add --from flag, refactor source providers (#2610)
Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
@@ -10,11 +10,11 @@ func DocumentName(src source.Description) string {
|
||||
}
|
||||
|
||||
switch metadata := src.Metadata.(type) {
|
||||
case source.StereoscopeImageSourceMetadata:
|
||||
case source.ImageMetadata:
|
||||
return metadata.UserInput
|
||||
case source.DirectorySourceMetadata:
|
||||
case source.DirectoryMetadata:
|
||||
return metadata.Path
|
||||
case source.FileSourceMetadata:
|
||||
case source.FileMetadata:
|
||||
return metadata.Path
|
||||
default:
|
||||
return "unknown"
|
||||
|
||||
@@ -23,7 +23,7 @@ func Test_DocumentName(t *testing.T) {
|
||||
{
|
||||
name: "image",
|
||||
srcMetadata: source.Description{
|
||||
Metadata: source.StereoscopeImageSourceMetadata{
|
||||
Metadata: source.ImageMetadata{
|
||||
UserInput: "image-repo/name:tag",
|
||||
ID: "id",
|
||||
ManifestDigest: "digest",
|
||||
@@ -34,14 +34,14 @@ func Test_DocumentName(t *testing.T) {
|
||||
{
|
||||
name: "directory",
|
||||
srcMetadata: source.Description{
|
||||
Metadata: source.DirectorySourceMetadata{Path: "some/path/to/place"},
|
||||
Metadata: source.DirectoryMetadata{Path: "some/path/to/place"},
|
||||
},
|
||||
expected: "some/path/to/place",
|
||||
},
|
||||
{
|
||||
name: "file",
|
||||
srcMetadata: source.Description{
|
||||
Metadata: source.FileSourceMetadata{Path: "some/path/to/place"},
|
||||
Metadata: source.FileMetadata{Path: "some/path/to/place"},
|
||||
},
|
||||
expected: "some/path/to/place",
|
||||
},
|
||||
@@ -49,7 +49,7 @@ func Test_DocumentName(t *testing.T) {
|
||||
name: "named",
|
||||
srcMetadata: source.Description{
|
||||
Name: "some/name",
|
||||
Metadata: source.FileSourceMetadata{Path: "some/path/to/place"},
|
||||
Metadata: source.FileMetadata{Path: "some/path/to/place"},
|
||||
},
|
||||
expected: "some/name",
|
||||
},
|
||||
|
||||
@@ -27,11 +27,11 @@ func DocumentNamespace(name string, src source.Description, desc sbom.Descriptor
|
||||
name = cleanName(name)
|
||||
input := "unknown-source-type"
|
||||
switch src.Metadata.(type) {
|
||||
case source.StereoscopeImageSourceMetadata:
|
||||
case source.ImageMetadata:
|
||||
input = InputImage
|
||||
case source.DirectorySourceMetadata:
|
||||
case source.DirectoryMetadata:
|
||||
input = InputDirectory
|
||||
case source.FileSourceMetadata:
|
||||
case source.FileMetadata:
|
||||
input = InputFile
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ func Test_documentNamespace(t *testing.T) {
|
||||
name: "image",
|
||||
inputName: "my-name",
|
||||
src: source.Description{
|
||||
Metadata: source.StereoscopeImageSourceMetadata{
|
||||
Metadata: source.ImageMetadata{
|
||||
UserInput: "image-repo/name:tag",
|
||||
ID: "id",
|
||||
ManifestDigest: "digest",
|
||||
@@ -37,7 +37,7 @@ func Test_documentNamespace(t *testing.T) {
|
||||
name: "directory",
|
||||
inputName: "my-name",
|
||||
src: source.Description{
|
||||
Metadata: source.DirectorySourceMetadata{
|
||||
Metadata: source.DirectoryMetadata{
|
||||
Path: "some/path/to/place",
|
||||
},
|
||||
},
|
||||
@@ -47,7 +47,7 @@ func Test_documentNamespace(t *testing.T) {
|
||||
name: "file",
|
||||
inputName: "my-name",
|
||||
src: source.Description{
|
||||
Metadata: source.FileSourceMetadata{
|
||||
Metadata: source.FileMetadata{
|
||||
Path: "some/path/to/place",
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user