config

package
v2.51.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2025 License: BSD-3-Clause Imports: 17 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoConfigFile         = fmt.Errorf("no config file exists")
	ErrNoGoFilesFoundInRoot = fmt.Errorf("no go files found in root search path")
	ErrPkgNotFound          = fmt.Errorf("package not found in config")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	All                         bool                   `mapstructure:"all"`
	Anchors                     map[string]any         `mapstructure:"_anchors"`
	BoilerplateFile             string                 `mapstructure:"boilerplate-file"`
	BuildTags                   string                 `mapstructure:"tags"`
	Case                        string                 `mapstructure:"case"`
	Config                      string                 `mapstructure:"config"`
	Cpuprofile                  string                 `mapstructure:"cpuprofile"`
	Dir                         string                 `mapstructure:"dir"`
	DisableConfigSearch         bool                   `mapstructure:"disable-config-search"`
	DisableDeprecationWarnings  bool                   `mapstructure:"disable-deprecation-warnings"`
	DisabledDeprecationWarnings []string               `mapstructure:"disabled-deprecation-warnings"`
	DisableFuncMocks            bool                   `mapstructure:"disable-func-mocks"`
	DisableVersionString        bool                   `mapstructure:"disable-version-string"`
	DryRun                      bool                   `mapstructure:"dry-run"`
	Exclude                     []string               `mapstructure:"exclude"`
	ExcludeRegex                string                 `mapstructure:"exclude-regex"`
	Exported                    bool                   `mapstructure:"exported"`
	FileName                    string                 `mapstructure:"filename"`
	InPackage                   bool                   `mapstructure:"inpackage"`
	InPackageSuffix             bool                   `mapstructure:"inpackage-suffix"`
	IncludeAutoGenerated        bool                   `mapstructure:"include-auto-generated"`
	IncludeRegex                string                 `mapstructure:"include-regex"`
	Issue845Fix                 bool                   `mapstructure:"issue-845-fix"`
	KeepTree                    bool                   `mapstructure:"keeptree"`
	LogLevel                    string                 `mapstructure:"log-level"`
	MockBuildTags               string                 `mapstructure:"mock-build-tags"`
	MockName                    string                 `mapstructure:"mockname"`
	Name                        string                 `mapstructure:"name"`
	Note                        string                 `mapstructure:"note"`
	Outpkg                      string                 `mapstructure:"outpkg"`
	Output                      string                 `mapstructure:"output"`
	Packageprefix               string                 `mapstructure:"packageprefix"`
	Packages                    map[string]interface{} `mapstructure:"packages"`
	Print                       bool                   `mapstructure:"print"`
	Profile                     string                 `mapstructure:"profile"`
	Quiet                       bool                   `mapstructure:"quiet"`
	Recursive                   bool                   `mapstructure:"recursive"`
	ReplaceType                 []string               `mapstructure:"replace-type"`
	ResolveTypeAlias            bool                   `mapstructure:"resolve-type-alias"`
	SrcPkg                      string                 `mapstructure:"srcpkg"`
	// StructName overrides the name given to the mock struct and should only be nonempty
	// when generating for an exact match (non regex expression in -name).
	StructName     string `mapstructure:"structname"`
	TestOnly       bool   `mapstructure:"testonly"`
	UnrollVariadic bool   `mapstructure:"unroll-variadic"`
	Version        bool   `mapstructure:"version"`
	WithExpecter   bool   `mapstructure:"with-expecter"`
	// contains filtered or unexported fields
}

func NewConfigFromViper added in v2.21.3

func NewConfigFromViper(v *viper.Viper) (*Config, error)

func (*Config) CfgAsMap added in v2.23.4

func (c *Config) CfgAsMap(ctx context.Context) (map[string]any, error)

CfgAsMap reads in the config file and returns a map representation, instead of a struct representation. This is mainly needed because viper throws away case-sensitivity in the `packages` section, which won't work when defining interface names 😞

func (*Config) ExcludePath added in v2.23.4

func (c *Config) ExcludePath(path string) bool

func (*Config) GetInterfaceConfig added in v2.21.0

func (c *Config) GetInterfaceConfig(ctx context.Context, packageName string, interfaceName string) ([]*Config, error)

func (*Config) GetPackageConfig added in v2.21.0

func (c *Config) GetPackageConfig(ctx context.Context, packageName string) (*Config, error)

GetPackageConfig returns a struct representation of the package's config as provided in yaml. If the package did not specify a config section, this method will inject the top-level config into the package's config. This is especially useful as it allows us to lazily evaluate a package's config. If the package does specify config, this method takes care to merge the top-level config with the values specified for this package.

func (*Config) GetPackages added in v2.21.0

func (c *Config) GetPackages(ctx context.Context) ([]string, error)

GetPackages returns a list of the packages that are defined in the `packages` config section.

func (*Config) Initialize added in v2.23.4

func (c *Config) Initialize(ctx context.Context) error

func (*Config) LogDeprecatedConfig added in v2.51.0

func (c *Config) LogDeprecatedConfig(ctx context.Context)

func (*Config) LogUnsupportedPackagesConfig added in v2.23.4

func (c *Config) LogUnsupportedPackagesConfig(ctx context.Context)

LogUnsupportedPackagesConfig is a method that will help aid migrations to the packages config feature. This is intended to be a temporary measure until v3 when we can remove all legacy config options.

func (*Config) ShouldGenerateInterface added in v2.21.0

func (c *Config) ShouldGenerateInterface(ctx context.Context, packageName, interfaceName string) (bool, error)

func (*Config) TagName added in v2.23.4

func (c *Config) TagName(name string) string

type Interface added in v2.21.0

type Interface struct {
	Config Config `mapstructure:"config"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL