github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/internal/config/cataloger_options.go (about) 1 package config 2 3 import ( 4 "fmt" 5 6 "github.com/nextlinux/gosbom/gosbom/source" 7 "github.com/spf13/viper" 8 ) 9 10 type catalogerOptions struct { 11 Enabled bool `yaml:"enabled" json:"enabled" mapstructure:"enabled"` 12 Scope string `yaml:"scope" json:"scope" mapstructure:"scope"` 13 ScopeOpt source.Scope `yaml:"-" json:"-"` 14 } 15 16 func (cfg catalogerOptions) loadDefaultValues(v *viper.Viper) { 17 v.SetDefault("package.cataloger.enabled", true) 18 } 19 20 func (cfg *catalogerOptions) parseConfigValues() error { 21 scopeOption := source.ParseScope(cfg.Scope) 22 if scopeOption == source.UnknownScope { 23 return fmt.Errorf("bad scope value %q", cfg.Scope) 24 } 25 cfg.ScopeOpt = scopeOption 26 27 return nil 28 }