config

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultDockerConfig = &Config{
		Language: "docker",
		Install: &RunConfig{
			Enabled: makeBool(false),
		},
		Build: &RunConfig{
			Enabled: makeBool(false),
		},
		Test: &RunConfig{
			Enabled: makeBool(false),
		},
		Version: &TemplateFileConfig{
			Enabled: makeBool(false),
		},
		GitHubAction: &TemplateFileConfig{
			Enabled:  makeBool(true),
			Template: "!docker_action.tmpl",
		},
		Commands: map[string]*RunConfig{},
		Homebrew: homebrew,
	}

	DefaultGoConfig = &Config{
		Language: "go",
		Install: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Download modules",
			Command: "go mod download",
		},
		Build: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Build",
			Command: "go build ./...",
		},
		Test: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Test",
			Command: "go test ./...",
		},
		Version: &TemplateFileConfig{
			File:     "version/version_gen.go",
			Template: "!version_go.tmpl",
		},
		GitHubAction: &TemplateFileConfig{
			Enabled:  makeBool(true),
			Template: "!go_action.tmpl",
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!go_dockerfile.tmpl",
		},
		Commands: map[string]*RunConfig{
			"update-dep": {
				Enabled: makeBool(true),
				Name:    "Update dependencies",
				Command: "git checkout master && git pull && go get -u ./... && go mod tidy && git add go.* && git commit -m 'chore(deps): upgraded dependencies' && git push",
			},
			"format-check": {
				Enabled: makeBool(true),
				Name:    "Check format",
				Command: "[ $(gofmt -l . | wc  -l) -ne 0 ] && exit 1 || exit 0",
			},
			"format": {
				Enabled: makeBool(true),
				Name:    "Format",
				Command: "go fmt ./...",
			},
			"vet": {
				Enabled: makeBool(true),
				Name:    "Vet",
				Command: "go vet ./...",
			},
			"lint-fix": {
				Enabled: makeBool(true),
				Name:    "Fix lint",
				Command: "go fix ./...",
			},
			"errcheck": {
				Enabled: makeBool(true),
				Name:    "Errcheck",
				Command: "winch-go-errcheck ./...",
			},
			"imports": {
				Enabled: makeBool(true),
				Name:    "Import check",
				Command: "winch-go-imports -d -e . && winch-go-imports -l .",
			},
			"lint": {
				Enabled: makeBool(true),
				Name:    "Lint",
				Command: "winch-go-lint -set_exit_status ./...",
			},
			"gosec": {
				Enabled: makeBool(true),
				Name:    "Gosec",
				Command: "winch-go-sec ./...",
			},
			"shadow": {
				Enabled: makeBool(true),
				Name:    "Shadow",
				Command: "go vet -vettool=$(which winch-go-shadow) ./...",
			},
			"staticcheck": {
				Enabled: makeBool(true),
				Name:    "Staticcheck",
				Command: "winch-go-staticcheck ./...",
			},
		},
		Homebrew: homebrew,
	}

	DefaultNpmConfig = &Config{
		Language:  "node",
		Toolchain: "npm",
		Install: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Download modules",
			Command: "npm install",
		},
		Build: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Build",
			Command: "npm run build",
		},
		Test: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Test",
			Command: "npm test",
		},
		Version: &TemplateFileConfig{
			File: "package.json",
		},
		GitHubAction: &TemplateFileConfig{
			Enabled:  makeBool(true),
			Template: "!node_action.tmpl",
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!node_npm_dockerfile.tmpl",
		},
		Commands: map[string]*RunConfig{
			"update-dep": {
				Enabled: makeBool(true),
				Name:    "Update dependencies",
				Command: "git checkout master && git pull && npm upgrade && git add package*.json && git commit -m 'chore(deps): upgraded dependencies' && git push",
			},
			"format": {
				Enabled: makeBool(true),
				Name:    "Format",
				Command: "npm run prettier",
			},
			"lint": {
				Enabled: makeBool(true),
				Name:    "Check lint",
				Command: "npm run lint",
			},
		},
		Homebrew: homebrew,
	}

	DefaultYarnConfig = &Config{
		Language:  "node",
		Toolchain: "yarn",
		Install: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Download modules",
			Command: "yarn",
		},
		Build: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Build",
			Command: "yarn run build",
		},
		Test: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Test",
			Command: "yarn test",
		},
		Version: &TemplateFileConfig{
			File: "package.json",
		},
		GitHubAction: &TemplateFileConfig{
			Enabled:  makeBool(true),
			Template: "!node_action.tmpl",
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!node_yarn_dockerfile.tmpl",
		},
		Commands: map[string]*RunConfig{
			"update-dep": {
				Enabled: makeBool(true),
				Name:    "Update dependencies",
				Command: "git checkout master && git pull && yarn upgrade && git add package.json yarn.lock && git commit -m 'chore(deps): upgraded dependencies' && git push",
			},
			"format": {
				Enabled: makeBool(true),
				Name:    "Format",
				Command: "npm prettier",
			},
			"lint": {
				Enabled: makeBool(true),
				Name:    "Check lint",
				Command: "npm lint",
			},
		},
		Homebrew: homebrew,
	}

	DefaultJavaMavenConfig = &Config{
		Language:  "java",
		Toolchain: "mvn",
		Install: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Download modules",
			Command: "mvn install",
		},
		Build: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Build",
			Command: "mvn compile",
		},
		Test: &RunConfig{
			Enabled: makeBool(false),
			Name:    "Test",
			Command: "mvn test",
		},
		Version: &TemplateFileConfig{
			File: "pom.xml",
		},
		GitHubAction: &TemplateFileConfig{
			Enabled:  makeBool(true),
			Template: "!java_mvn_action.tmpl",
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!java_mvn_dockerfile.tmpl",
		},
		Commands: map[string]*RunConfig{},
		Homebrew: homebrew,
	}

	DefaultScalaSbtConfig = &Config{
		Language:  "scala",
		Toolchain: "sbt",
		Install: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Download modules",
			Command: "sbt install",
		},
		Build: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Build",
			Command: "sbt compile",
		},
		Test: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Test",
			Command: "sbt test",
		},
		Version: &TemplateFileConfig{
			Enabled: makeBool(false),
		},
		GitHubAction: &TemplateFileConfig{
			Enabled:  makeBool(true),
			Template: "!scala_sbt_action.tmpl",
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!scala_sbt_dockerfile.tmpl",
		},
		Commands: map[string]*RunConfig{},
		Homebrew: homebrew,
	}

	DefaultPythonConfig = &Config{
		Language: "python",
		Install: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Download modules",
			Command: "pip install",
		},
		Build: &RunConfig{
			Enabled: makeBool(false),
		},
		Test: &RunConfig{
			Enabled: makeBool(false),
		},
		Version: &TemplateFileConfig{
			File:     "version.py",
			Template: "!version_py.tmpl",
		},
		GitHubAction: &TemplateFileConfig{
			Enabled:  makeBool(true),
			Template: "!python_action.tmpl",
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!python_dockerfile.tmpl",
		},
		Commands: map[string]*RunConfig{
			"update-dep": {
				Enabled: makeBool(true),
				Name:    "Update dependencies",
				Command: "git checkout master && git pull && pip install pipupgrade && pipupgrade --verbose --latest --yes && git add requirements.txt && git commit -m 'chore(deps): upgraded dependencies' && git push",
			},
		},
		Homebrew: homebrew,
	}
)

Default configurations

Functions

func AddCommandToContext

func AddCommandToContext(ctx context.Context, c *cobra.Command) context.Context

func AddConfigToContext

func AddConfigToContext(ctx context.Context, c *Config) context.Context

func AddDB

func AddDB(flags *pflag.FlagSet)

func AddDynamodb

func AddDynamodb(flags *pflag.FlagSet, prefix ...string)

AddDynamodb adds the dynamodb parameters

func CommandFromContext

func CommandFromContext(ctx context.Context) *cobra.Command

func GuessLanguageAndToolchain

func GuessLanguageAndToolchain() (string, string)

func LoadConfig

func LoadConfig(ctx context.Context) (context.Context, error)

LoadConfig loads config from the configuration file

func LoadDBConfig

func LoadDBConfig(ctx context.Context, cfg *Config) error

func Setup

func Setup() func(cmd *cobra.Command, args []string) error

Setup sets up the configuration system.

Types

type AssetConfig

type AssetConfig struct {
	Enabled   *bool         `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Branches  *FilterConfig `json:"branches,omitempty" yaml:"branches,omitempty"`
	Tags      *FilterConfig `json:"tags,omitempty" yaml:"tags,omitempty"`
	Filename  string        `json:"filename,omitempty" yaml:"filename,omitempty"`
	Directory string        `json:"directory,omitempty" yaml:"directory,omitempty"`
	Package   string        `json:"package,omitempty" yaml:"package,omitempty"`
	Variable  string        `json:"variable,omitempty" yaml:"variable,omitempty"`
	Tag       string        `json:"tag,omitempty" yaml:"tag,omitempty"`
	Only      []string      `json:"only,omitempty" yaml:"only,omitempty"`
	Except    []string      `json:"except,omitempty" yaml:"except,omitempty"`
}

AssetConfig provides config for asset generate

func (*AssetConfig) IsEnabled

func (c *AssetConfig) IsEnabled() bool

type CIConfig

type CIConfig struct {
	Enabled  *bool         `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Branches *FilterConfig `json:"branches,omitempty" yaml:"branches,omitempty"`
	Tags     *FilterConfig `json:"tags,omitempty" yaml:"tags,omitempty"`
}

CIConfig provides config for CI

func (*CIConfig) IsEnabled

func (c *CIConfig) IsEnabled() bool

type Config

type Config struct {
	Filename      string                       `json:"filename,omitempty" yaml:"filename,omitempty"`
	BasePath      string                       `json:"base,omitempty" yaml:"base,omitempty"`
	Name          string                       `json:"name,omitempty" yaml:"name,omitempty"`
	Description   string                       `json:"description,omitempty" yaml:"description,omitempty"`
	Repository    string                       `json:"repository,omitempty" yaml:"repository,omitempty"`
	Local         bool                         `json:"local,omitempty" yaml:"local,omitempty"`
	Verbose       bool                         `json:"verbose,omitempty" yaml:"verbose,omitempty"`
	Quiet         bool                         `json:"quiet,omitempty" yaml:"quiet,omitempty"`
	Language      string                       `json:"language,omitempty" yaml:"language,omitempty"`
	Toolchain     string                       `json:"toolchain,omitempty" yaml:"toolchain,omitempty"`
	CI            *CIConfig                    `json:"ci,omitempty" yaml:"ci,omitempty"`
	BeforeInstall *RunConfig                   `json:"before_install,omitempty" yaml:"before_install,omitempty"`
	Install       *RunConfig                   `json:"install,omitempty" yaml:"install,omitempty"`
	AfterInstall  *RunConfig                   `json:"after_install,omitempty" yaml:"after_install,omitempty"`
	BeforeBuild   *RunConfig                   `json:"before_build,omitempty" yaml:"before_build,omitempty"`
	Build         *RunConfig                   `json:"build,omitempty" yaml:"build,omitempty"`
	AfterBuild    *RunConfig                   `json:"after_build,omitempty" yaml:"after_build,omitempty"`
	BeforeTest    *RunConfig                   `json:"before_test,omitempty" yaml:"before_test,omitempty"`
	Test          *RunConfig                   `json:"test,omitempty" yaml:"test,omitempty"`
	AfterTest     *RunConfig                   `json:"after_test,omitempty" yaml:"after_test,omitempty"`
	Changelog     *TemplateFileConfig          `json:"changelog,omitempty" yaml:"changelog,omitempty"`
	Version       *TemplateFileConfig          `json:"version,omitempty" yaml:"version,omitempty"`
	Versions      []*TemplateFileConfig        `json:"versions,omitempty" yaml:"versions,omitempty"`
	GitHubAction  *TemplateFileConfig          `json:"githubaction,omitempty" yaml:"githubaction,omitempty"`
	Dockerfile    *TemplateFileConfig          `json:"dockerfile,omitempty" yaml:"dockerfile,omitempty"`
	Dockerfiles   []*TemplateFileConfig        `json:"dockerfiles,omitempty" yaml:"dockerfiles,omitempty"`
	Homebrew      *HomebrewConfig              `json:"homebrew,omitempty" yaml:"homebrew,omitempty"`
	Transom       *TransomConfig               `json:"transom,omitempty" yaml:"transom,omitempty"`
	Database      *DatabaseConfig              `json:"database,omitempty" yaml:"database,omitempty"`
	Dynamodb      *DynamoDBConfig              `json:"dynamodb,omitempty" yaml:"dynamodb,omitempty"`
	Vault         *VaultConfig                 `json:"vault,omitempty" yaml:"vault,omitempty"`
	Docker        *DockerConfig                `json:"docker,omitempty" yaml:"docker,omitempty"`
	Dockers       []*DockerConfig              `json:"dockers,omitempty" yaml:"dockers,omitempty"`
	Assets        []*AssetConfig               `json:"assets,omitempty" yaml:"assets,omitempty"`
	BeforeRelease *RunConfig                   `json:"before_release,omitempty" yaml:"before_release,omitempty"`
	Release       *ReleaseConfig               `json:"release,omitempty" yaml:"release,omitempty"`
	AfterRelease  *RunConfig                   `json:"after_release,omitempty" yaml:"after_release,omitempty"`
	BeforePublish *RunConfig                   `json:"before_publish,omitempty" yaml:"before_publish,omitempty"`
	Publish       *RunConfig                   `json:"publish,omitempty" yaml:"publish,omitempty"`
	AfterPublish  *RunConfig                   `json:"after_publish,omitempty" yaml:"after_publish,omitempty"`
	Environment   map[string]string            `json:"environment,omitempty" yaml:"environment,omitempty"`
	Environments  map[string]map[string]string `json:"environments,omitempty" yaml:"environments,omitempty"`
	Commands      map[string]*RunConfig        `json:"commands,omitempty" yaml:"commands,omitempty"`
	Scopes        []string                     `json:"scopes,omitempty" yaml:"scopes,omitempty"`
	Artifacts     []string                     `json:"artifacts,omitempty" yaml:"artifacts,omitempty"`
}

Config provides overall configuration

func ConfigFromContext

func ConfigFromContext(ctx context.Context) *Config

type DatabaseConfig

type DatabaseConfig struct {
	Dialect      string `json:"dialect" yaml:"dialect"`
	Host         string `json:"host" yaml:"host"`
	Port         int    `json:"port" yaml:"port"`
	Database     string `json:"database" yaml:"database"`
	Username     string `json:"username" yaml:"username"`
	Password     string `json:"password" yaml:"password"`
	Dir          string `json:"dir" yaml:"dir"`
	Secure       bool   `json:"secure" yaml:"secure"`
	Timestamp    bool   `json:"timestamp" yaml:"timestamp"`
	UpdateConfig bool   `json:"updateconfig" yaml:"updateconfig"`
}

DatabaseConfig provides the database configuration.

func (DatabaseConfig) String

func (c DatabaseConfig) String() string

String returns a string version of the config, suitable for passing as a connection string.

type DockerConfig

type DockerConfig struct {
	Enabled      *bool              `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Server       string             `json:"server,omitempty" yaml:"server,omitempty"`
	Organization string             `json:"organization,omitempty" yaml:"organization,omitempty"`
	Repository   string             `json:"repository,omitempty" yaml:"repository,omitempty"`
	Username     string             `json:"username,omitempty" yaml:"username,omitempty"`
	Password     string             `json:"password,omitempty" yaml:"password,omitempty"`
	Dockerfile   string             `json:"dockerfile,omitempty" yaml:"dockerfile,omitempty"`
	Context      string             `json:"context,omitempty" yaml:"context,omitempty"`
	Tag          string             `json:"tag,omitempty" yaml:"tag,omitempty"`
	BuildArgs    map[string]*string `json:"buildargs,omitempty" yaml:"buildargs,omitempty"`
	Labels       map[string]string  `json:"labels,omitempty" yaml:"labels,omitempty"`
	Branches     *FilterConfig      `json:"branches,omitempty" yaml:"branches,omitempty"`
	Tags         *FilterConfig      `json:"tags,omitempty" yaml:"tags,omitempty"`
}

DockerConfig provides config for Docker

func (*DockerConfig) IsEnabled

func (d *DockerConfig) IsEnabled() bool

type DynamoDBConfig

type DynamoDBConfig struct {
	Endpoint string
	Dir      string
}

func (DynamoDBConfig) GetEndpoint

func (c DynamoDBConfig) GetEndpoint() string

type DynamoDBConfigIf

type DynamoDBConfigIf interface {
	GetEndpoint() string
}

type FilterConfig

type FilterConfig struct {
	Ignore string `json:"ignore,omitempty" yaml:"ignore,omitempty"`
	Only   string `json:"only,omitempty" yaml:"only,omitempty"`
}

FilterConfig provides config for filters

func (*FilterConfig) IsEnabled

func (c *FilterConfig) IsEnabled() bool

type HomebrewConfig added in v1.2.0

type HomebrewConfig struct {
	Enabled      *bool                  `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Organization string                 `json:"organization,omitempty" yaml:"organization,omitempty"`
	Repository   string                 `json:"repository,omitempty" yaml:"repository,omitempty"`
	Template     string                 `json:"template,omitempty" yaml:"template,omitempty"`
	File         string                 `json:"file,omitempty" yaml:"file,omitempty"`
	Url          string                 `json:"url,omitempty" yaml:"url,omitempty"`
	Asset        string                 `json:"asset,omitempty" yaml:"asset,omitempty"`
	Install      string                 `json:"install,omitempty" yaml:"install,omitempty"`
	Test         string                 `json:"test,omitempty" yaml:"test,omitempty"`
	DependsOn    []string               `json:"depends_on,omitempty" yaml:"depends_on,omitempty"`
	Variables    map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty"`
	Branches     *FilterConfig          `json:"branches,omitempty" yaml:"branches,omitempty"`
	Tags         *FilterConfig          `json:"tags,omitempty" yaml:"tags,omitempty"`
}

HomebrewConfig provides config for Homebrew

func (*HomebrewConfig) GetFile added in v1.2.0

func (c *HomebrewConfig) GetFile() string

func (*HomebrewConfig) GetTemplate added in v1.2.0

func (c *HomebrewConfig) GetTemplate() string

func (*HomebrewConfig) IsEnabled added in v1.2.0

func (c *HomebrewConfig) IsEnabled() bool

type ReleaseConfig

type ReleaseConfig struct {
	Enabled     *bool             `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Name        string            `json:"name,omitempty" yaml:"name,omitempty"`
	Command     string            `json:"command,omitempty" yaml:"command,omitempty"`
	Environment map[string]string `json:"environment,omitempty" yaml:"environment,omitempty"`
	Branches    *FilterConfig     `json:"branches,omitempty" yaml:"branches,omitempty"`
	Tags        *FilterConfig     `json:"tags,omitempty" yaml:"tags,omitempty"`
	Input       string            `json:"input,omitempty" yaml:"input,omitempty"`
	Artifacts   []string          `json:"artifacts,omitempty" yaml:"artifacts,omitempty"`
}

ReleaseConfig provides config for releases

func (*ReleaseConfig) IsEnabled

func (c *ReleaseConfig) IsEnabled() bool

func (*ReleaseConfig) RunConfig added in v1.2.7

func (c *ReleaseConfig) RunConfig() *RunConfig

type RunConfig

type RunConfig struct {
	Enabled     *bool             `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Name        string            `json:"name,omitempty" yaml:"name,omitempty"`
	Command     string            `json:"command,omitempty" yaml:"command,omitempty"`
	Environment map[string]string `json:"environment,omitempty" yaml:"environment,omitempty"`
	Branches    *FilterConfig     `json:"branches,omitempty" yaml:"branches,omitempty"`
	Tags        *FilterConfig     `json:"tags,omitempty" yaml:"tags,omitempty"`
	Input       string            `json:"input,omitempty" yaml:"input,omitempty"`
}

RunConfig provides config for commands to run

func (*RunConfig) IsEnabled

func (c *RunConfig) IsEnabled() bool

type TemplateFileConfig

type TemplateFileConfig struct {
	Enabled   *bool             `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Template  string            `json:"template,omitempty" yaml:"template,omitempty"`
	File      string            `json:"file,omitempty" yaml:"file,omitempty"`
	Variables map[string]string `json:"variables,omitempty" yaml:"variables,omitempty"`
}

TemplateFileConfig provides config for files produced from templates

func (TemplateFileConfig) GetFile

func (c TemplateFileConfig) GetFile() string

func (TemplateFileConfig) GetTemplate

func (c TemplateFileConfig) GetTemplate() string

func (TemplateFileConfig) GetVariables added in v1.2.0

func (c TemplateFileConfig) GetVariables() map[string]string

func (*TemplateFileConfig) IsEnabled

func (c *TemplateFileConfig) IsEnabled() bool

type TransomConfig

type TransomConfig struct {
	Enabled      *bool         `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Server       string        `json:"server,omitempty" yaml:"server,omitempty"`
	Organization string        `json:"organization,omitempty" yaml:"organization,omitempty"`
	Application  string        `json:"application,omitempty" yaml:"application,omitempty"`
	Token        string        `json:"token,omitempty" yaml:"token,omitempty"`
	Branches     *FilterConfig `json:"branches,omitempty" yaml:"branches,omitempty"`
	Tags         *FilterConfig `json:"tags,omitempty" yaml:"tags,omitempty"`
	Directory    string        `json:"directory,omitempty" yaml:"directory,omitempty"`
	Artifacts    []string      `json:"artifacts,omitempty" yaml:"artifacts,omitempty"`
}

TransomConfig provides configuration for Transom

func (*TransomConfig) IsEnabled

func (d *TransomConfig) IsEnabled() bool

type VaultConfig

type VaultConfig struct {
	Address string `json:"address" yaml:"address"`
	Token   string `json:"token" yaml:"token"`
	Prefix  string `json:"prefix" yaml:"prefix"`
	Dir     string `json:"dir" yaml:"dir"`
}

The keys for the parameters

Jump to

Keyboard shortcuts

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