github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/syft/source/sourceproviders/source_provider_config.go (about) 1 package sourceproviders 2 3 import ( 4 "crypto" 5 6 "github.com/anchore/stereoscope/pkg/image" 7 "github.com/anchore/syft/syft/source" 8 ) 9 10 // Config is the uber-configuration for all Syft source providers 11 type Config struct { 12 Platform *image.Platform 13 Alias source.Alias 14 RegistryOptions *image.RegistryOptions 15 Exclude source.ExcludeConfig 16 DigestAlgorithms []crypto.Hash 17 BasePath string 18 } 19 20 func (c *Config) WithAlias(alias source.Alias) *Config { 21 c.Alias = alias 22 return c 23 } 24 25 func (c *Config) WithRegistryOptions(registryOptions *image.RegistryOptions) *Config { 26 c.RegistryOptions = registryOptions 27 return c 28 } 29 30 func (c *Config) WithPlatform(platform *image.Platform) *Config { 31 c.Platform = platform 32 return c 33 } 34 35 func (c *Config) WithExcludeConfig(excludeConfig source.ExcludeConfig) *Config { 36 c.Exclude = excludeConfig 37 return c 38 } 39 40 func (c *Config) WithDigestAlgorithms(algorithms ...crypto.Hash) *Config { 41 c.DigestAlgorithms = algorithms 42 return c 43 } 44 45 func (c *Config) WithBasePath(basePath string) *Config { 46 c.BasePath = basePath 47 return c 48 } 49 50 func DefaultConfig() *Config { 51 return &Config{ 52 DigestAlgorithms: []crypto.Hash{ 53 crypto.SHA256, 54 }, 55 } 56 }