config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 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),
		},
	}

	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",
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!go_dockerfile.tmpl",
		},
		Commands: map[string]*RunConfig{
			"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: "errcheck ./...",
			},
			"imports": {
				Enabled: makeBool(true),
				Name:    "Import check",
				Command: "goimports -d -e . && goimports -l .",
			},
			"lint": {
				Enabled: makeBool(true),
				Name:    "Lint",
				Command: "golint -set_exit_status ./...",
			},
			"gosec": {
				Enabled: makeBool(true),
				Name:    "Gosec",
				Command: "gosec ./...",
			},
			"shadow": {
				Enabled: makeBool(true),
				Name:    "Shadow",
				Command: "go vet -vettool=$(which shadow) ./...",
			},
			"staticcheck": {
				Enabled: makeBool(true),
				Name:    "Staticcheck",
				Command: "staticcheck ./...",
			},
		},
	}

	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",
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!node_npm_dockerfile.tmpl",
		},
		Commands: map[string]*RunConfig{
			"format": {
				Enabled: makeBool(true),
				Name:    "Format",
				Command: "npm run prettier",
			},
			"lint": {
				Enabled: makeBool(true),
				Name:    "Check lint",
				Command: "npm run lint",
			},
		},
	}

	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",
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!node_yarn_dockerfile.tmpl",
		},
		Commands: map[string]*RunConfig{
			"format": {
				Enabled: makeBool(true),
				Name:    "Format",
				Command: "npm prettier",
			},
			"lint": {
				Enabled: makeBool(true),
				Name:    "Check lint",
				Command: "npm lint",
			},
		},
	}

	DefaultJavaMavenConfig = &Config{
		Language:  "java",
		Toolchain: "mvn",
		Install: &RunConfig{
			Enabled: makeBool(false),
		},
		Build: &RunConfig{
			Enabled: makeBool(true),
			Name:    "Build",
			Command: "mvn compile",
		},
		Test: &RunConfig{
			Enabled: makeBool(false),
			Name:    "Test",
			Command: "mvn test",
		},
		Version: &TemplateFileConfig{
			Enabled: makeBool(false),
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!java_mvn_dockerfile.tmpl",
		},
	}

	DefaultScalaSbtConfig = &Config{
		Language:  "scala",
		Toolchain: "sbt",
		Install: &RunConfig{
			Enabled: makeBool(false),
		},
		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),
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!scala_sbt_dockerfile.tmpl",
		},
	}

	DefaultPythonConfig = &Config{
		Language: "python",
		Install: &RunConfig{
			Enabled: makeBool(false),
			Name:    "Install",
		},
		Build: &RunConfig{
			Enabled: makeBool(false),
		},
		Test: &RunConfig{
			Enabled: makeBool(false),
		},
		Version: &TemplateFileConfig{
			Enabled: makeBool(false),
		},
		Dockerfile: &TemplateFileConfig{
			Template: "!python_dockerfile.tmpl",
		},
	}
)

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"`
	Dockerfile    *TemplateFileConfig          `json:"dockerfile,omitempty" yaml:"dockerfile,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"`
	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 ReleaseConfig

type ReleaseConfig struct {
	RunConfig
	Artifacts []string `json:"artifacts,omitempty" yaml:"artifacts,omitempty"`
}

ReleaseConfig provides config for releases

func (*ReleaseConfig) IsEnabled

func (d *ReleaseConfig) IsEnabled() bool

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"`
}

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) 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"`
	Shipyard     string        `json:"shipyard,omitempty" yaml:"shipyard,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"`
	Username     string        `json:"username,omitempty" yaml:"username,omitempty"`
	Password     string        `json:"password,omitempty" yaml:"password,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