mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
* add new cyclonedx format object Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove cyclonedx presenter Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove cyclonedx presenter call Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove dependence on golden images for format tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * wire up new formt + rename all-presenters ref Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add CLI test to ensure that all formats can be expressed as report output Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add cyclonedx version and encoding format to package name Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * optionally preserve format snapshot images Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting + text unit tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
44 lines
1018 B
Go
44 lines
1018 B
Go
package format
|
|
|
|
import "strings"
|
|
|
|
const (
|
|
UnknownFormatOption Option = "UnknownFormatOption"
|
|
JSONOption Option = "json"
|
|
TextOption Option = "text"
|
|
TableOption Option = "table"
|
|
CycloneDxOption Option = "cyclonedx"
|
|
SPDXTagValueOption Option = "spdx-tag-value"
|
|
SPDXJSONOption Option = "spdx-json"
|
|
)
|
|
|
|
var AllOptions = []Option{
|
|
JSONOption,
|
|
TextOption,
|
|
TableOption,
|
|
CycloneDxOption,
|
|
SPDXTagValueOption,
|
|
SPDXJSONOption,
|
|
}
|
|
|
|
type Option string
|
|
|
|
func ParseOption(userStr string) Option {
|
|
switch strings.ToLower(userStr) {
|
|
case string(JSONOption):
|
|
return JSONOption
|
|
case string(TextOption):
|
|
return TextOption
|
|
case string(TableOption):
|
|
return TableOption
|
|
case string(CycloneDxOption), "cyclone", "cyclone-dx":
|
|
return CycloneDxOption
|
|
case string(SPDXTagValueOption), "spdx", "spdx-tagvalue", "spdxtagvalue", "spdx-tv", "spdxtv":
|
|
return SPDXTagValueOption
|
|
case string(SPDXJSONOption), "spdxjson":
|
|
return SPDXJSONOption
|
|
default:
|
|
return UnknownFormatOption
|
|
}
|
|
}
|