mirror of
https://github.com/anchore/syft.git
synced 2026-11-04 08:26:38 +01:00
add app config and logging interface
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package imgbom
|
||||
|
||||
import "github.com/anchore/imgbom/internal/logger"
|
||||
|
||||
func SetLogger(l logger.Logger) {
|
||||
logger.SetLogger(l)
|
||||
}
|
||||
@@ -1,23 +1,34 @@
|
||||
package presenter
|
||||
|
||||
import "strings"
|
||||
|
||||
const (
|
||||
UnknownPresenterOption Option = iota
|
||||
JSONOption
|
||||
UnknownPresenter Option = iota
|
||||
JSONPresenter
|
||||
)
|
||||
|
||||
var optionStr = []string{
|
||||
"UnknownPresenterOption",
|
||||
"UnknownPresenter",
|
||||
"json",
|
||||
}
|
||||
|
||||
var Options = []Option{
|
||||
JSONOption,
|
||||
JSONPresenter,
|
||||
}
|
||||
|
||||
type Option int
|
||||
type Option uint
|
||||
|
||||
func ParseOption(userStr string) Option {
|
||||
switch strings.ToLower(userStr) {
|
||||
case strings.ToLower(JSONPresenter.String()):
|
||||
return JSONPresenter
|
||||
default:
|
||||
return UnknownPresenter
|
||||
}
|
||||
}
|
||||
|
||||
func (o Option) String() string {
|
||||
if int(o) >= len(optionStr) || int(o) < 0 {
|
||||
if int(o) >= len(optionStr) {
|
||||
return optionStr[0]
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package presenter
|
||||
|
||||
import (
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/anchore/imgbom/imgbom/pkg"
|
||||
"github.com/anchore/imgbom/imgbom/presenter/json"
|
||||
@@ -13,9 +12,9 @@ type Presenter interface {
|
||||
Present(io.Writer, *image.Image, pkg.Catalog) error
|
||||
}
|
||||
|
||||
func GetPresenter(userStr string) Presenter {
|
||||
switch strings.ToLower(userStr) {
|
||||
case JSONOption.String():
|
||||
func GetPresenter(option Option) Presenter {
|
||||
switch option {
|
||||
case JSONPresenter:
|
||||
return json.NewPresenter()
|
||||
default:
|
||||
return nil
|
||||
|
||||
@@ -8,7 +8,7 @@ const (
|
||||
AllLayersScope
|
||||
)
|
||||
|
||||
type Option int
|
||||
type Option uint
|
||||
|
||||
var optionStr = []string{
|
||||
"UnknownScope",
|
||||
@@ -32,7 +32,7 @@ func ParseOption(userStr string) Option {
|
||||
}
|
||||
|
||||
func (o Option) String() string {
|
||||
if int(o) >= len(optionStr) || int(o) < 0 {
|
||||
if int(o) >= len(optionStr) {
|
||||
return optionStr[0]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user