ensurefile

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package ensurefile assists with loading and representing .ensure.yml files.

Index

Constants

View Source
const ExampleFile = `` /* 784-byte string literal not displayed */

ExampleFile for use in error messages and CLI help menus.

Variables

View Source
var (
	ErrCannotFindGoModule  = erk.New(ErkCannotLoadConfig{}, "Cannot find root go.mod file by searching parent working directories")
	ErrCannotParseGoModule = erk.New(ErkCannotLoadConfig{}, "Cannot read module path from go.mod file: {{.path}}")
	ErrCannotOpenFile      = erk.New(ErkCannotLoadConfig{}, "Cannot open the file '{{.path}}': {{.err}}")
	ErrCannotUnmarshalFile = erk.New(ErkCannotLoadConfig{}, "Cannot parse the file '{{.path}}': {{.err}}")
)
View Source
var (
	ErrMissingMockConfig = erk.New(ErkInvalidConfig{}, "Missing `mocks` config in .ensure.yml file. For example:\n\n"+ExampleFile)

	ErrMissingPackages = erk.New(ErkInvalidConfig{},
		"No mocks to generate. Please add some to `mocks.packages` in .ensure.yml file. For example:\n\n"+ExampleFile,
	)
	ErrDuplicatePackagePath = erk.New(ErkInvalidConfig{}, "Found duplicate package path: {{.packagePath}} in .ensure.yml file. Package paths must be unique.")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	RootPath   string `yaml:"-"`
	ModulePath string `yaml:"-"`

	Mocks *MockConfig `yaml:"mocks"`
}

Config is the root of the .ensure.yml file.

type ErkCannotLoadConfig

type ErkCannotLoadConfig struct{ erk.DefaultKind }

type ErkInvalidConfig

type ErkInvalidConfig struct{ erk.DefaultKind }

type Loader

type Loader struct {
	FS fs.FS
}

Loader allows loading the project's .ensure.yml file.

func (*Loader) LoadConfig

func (l *Loader) LoadConfig(pwd string) (*Config, error)

LoadConfig from the .ensure.yml file that is located in pwd or a parent of pwd. It validates the config and sets default values before it is returned.

type LoaderIface

type LoaderIface interface {
	LoadConfig(pwd string) (*Config, error)
}

LoaderIface allows loading the project's .ensure.yml file.

type MockConfig

type MockConfig struct {
	PrimaryDestination   string `yaml:"primaryDestination"`
	InternalDestination  string `yaml:"internalDestination"`
	TidyAfterGenerate    bool   `yaml:"-"`
	RawTidyAfterGenerate *bool  `yaml:"tidyAfterGenerate"`

	Packages []*MockPackage `yaml:"packages"`
}

MockConfig is configuration related to mocks.

type MockPackage

type MockPackage struct {
	Path       string   `yaml:"path"`
	Interfaces []string `yaml:"interfaces"`
}

MockPackage is configuration related to mocking a single package.

func (*MockPackage) String

func (pkg *MockPackage) String() string

String exposes the Package as `<Path>:<Interfaces[0]>,<Interfaces[1]>,...`.

Jump to

Keyboard shortcuts

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