github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/cmd/syft/internal/options/golang.go (about)

     1  package options
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/anchore/syft/syft/pkg/cataloger/golang"
     7  )
     8  
     9  type golangConfig struct {
    10  	SearchLocalModCacheLicenses bool                          `json:"search-local-mod-cache-licenses" yaml:"search-local-mod-cache-licenses" mapstructure:"search-local-mod-cache-licenses"`
    11  	LocalModCacheDir            string                        `json:"local-mod-cache-dir" yaml:"local-mod-cache-dir" mapstructure:"local-mod-cache-dir"`
    12  	SearchRemoteLicenses        bool                          `json:"search-remote-licenses" yaml:"search-remote-licenses" mapstructure:"search-remote-licenses"`
    13  	Proxy                       string                        `json:"proxy" yaml:"proxy" mapstructure:"proxy"`
    14  	NoProxy                     string                        `json:"no-proxy" yaml:"no-proxy" mapstructure:"no-proxy"`
    15  	MainModuleVersion           golangMainModuleVersionConfig `json:"main-module-version" yaml:"main-module-version" mapstructure:"main-module-version"`
    16  }
    17  
    18  type golangMainModuleVersionConfig struct {
    19  	FromLDFlags       bool `json:"from-ld-flags" yaml:"from-ld-flags" mapstructure:"from-ld-flags"`
    20  	FromContents      bool `json:"from-contents" yaml:"from-contents" mapstructure:"from-contents"`
    21  	FromBuildSettings bool `json:"from-build-settings" yaml:"from-build-settings" mapstructure:"from-build-settings"`
    22  }
    23  
    24  func defaultGolangConfig() golangConfig {
    25  	def := golang.DefaultCatalogerConfig()
    26  	return golangConfig{
    27  		SearchLocalModCacheLicenses: def.SearchLocalModCacheLicenses,
    28  		LocalModCacheDir:            def.LocalModCacheDir,
    29  		SearchRemoteLicenses:        def.SearchRemoteLicenses,
    30  		Proxy:                       strings.Join(def.Proxies, ","),
    31  		NoProxy:                     strings.Join(def.NoProxy, ","),
    32  		MainModuleVersion: golangMainModuleVersionConfig{
    33  			FromLDFlags:       def.MainModuleVersion.FromLDFlags,
    34  			FromContents:      def.MainModuleVersion.FromContents,
    35  			FromBuildSettings: def.MainModuleVersion.FromBuildSettings,
    36  		},
    37  	}
    38  }