config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConfigFileLookupPaths define the filepaths where to look for the releaser config file
	ConfigFileLookupPaths []string = []string{
		"./.releaser",
		"$HOME/.releaser",
		"~/.releaser",
		"/etc/releaser",
	}

	// Branch config default values
	BranchAllowedWithoutTypeDefault bool     = true
	BranchDelimiterDefault          string   = "-"
	BranchNameFormatDefault         string   = "{{if .Type}}{{ .Type }} {{end}}{{ .BranchName }}"
	BranchTypesDefault              []string = []string{"bug", "feature", "fix", "hotfix"}
	// Commit config default values
	CommitAllowedWithoutTypeDefault bool     = true
	CommitMessageFormatDefault      string   = "{{if .Type}}{{ .Type | ToTitle }}: {{end}}{{ .CommitMessage }}"
	CommitTypesDefault              []string = []string{"adjustment", "bug", "feature", "fix", "hotfix"}
	// Flag config default values
	FlagRequiredDefault       bool = false
	FlagSkipForBranchDefault  bool = false
	FlagSkipForCommitDefault  bool = false
	FlagSkipForReleaseDefault bool = true
	// Git config default values
	GitExecutableDefault string = "git"
	GitRemoteDefault     string = "origin"
	// Release config default values
	ReleaseFirstTagDefault          string = "v0.0.1"
	ReleaseNameFormatDefault        string = "Release {{ .ReleaseTag }} ({{ .DTYear }}-{{ .DTMonth }}-{{ .DTDay }})"
	ReleaseDescriptionFormatDefault string = `
## Changelog

{{range .GitCommitLogs -}}
* {{ .Message }}
{{end}}`
	ReleaseTargetDefault string = "main"
)

Functions

func Init

func Init() (string, error)

Init loads the config from a file if found and returns the used config filepath as result

Types

type Branch

type Branch struct {
	AllowedWithoutType *bool    `mapstructure:"allowed_without_type" yaml:"allowed_without_type" validate:"required"`
	Delimiter          *string  `mapstructure:"delimiter" yaml:"delimiter" validate:"required,len=1"`
	NameFormat         *string  `mapstructure:"name_format" yaml:"name_format" validate:"required"`
	Types              []string `mapstructure:"types" yaml:"types" validate:"required,unique,dive,lowercase,alphanum"`
}

Branch has git branch specific config settings

func (Branch) GetAllowedWithoutType

func (b Branch) GetAllowedWithoutType() bool

GetAllowedWithoutType returns the value of the AllowedWithoutType field if present, else default value

func (Branch) GetDelimiter

func (b Branch) GetDelimiter() string

GetDelimiter returns the value of the Delimiter field if present, else default value

func (Branch) GetNameFormat

func (b Branch) GetNameFormat() string

GetNameFormat returns the value of the NameFormat field if present, else default value

func (Branch) GetTypes

func (b Branch) GetTypes() []string

GetTypes returns the value of the Types field if present, else default value

type Commit

type Commit struct {
	AllowedWithoutType *bool    `mapstructure:"allowed_without_type" yaml:"allowed_without_type" validate:"required"`
	MessageFormat      *string  `mapstructure:"message_format" yaml:"message_format" validate:"required"`
	Types              []string `mapstructure:"types" yaml:"types" validate:"required,unique,dive,alphanum"`
}

Commit has git commit specific config settings

func (Commit) GetAllowedWithoutType

func (c Commit) GetAllowedWithoutType() bool

GetAllowedWithoutType returns the value of the AllowedWithoutType field if given, else default value

func (Commit) GetMessageFormat

func (c Commit) GetMessageFormat() string

GetMessageFormat returns the value of the MessageFormat field if given, else default value

func (Commit) GetTypes

func (c Commit) GetTypes() []string

Types the value of the Types field if given, else default value

type Config

type Config struct {
	// Git specific config fields
	Git Git `mapstructure:"git" yaml:"git" validate:"required,dive"`
	// Branch specific config fields
	Branch Branch `mapstructure:"branch" yaml:"branch" validate:"required,dive"`
	// Commit specific config fields
	Commit Commit `mapstructure:"commit" yaml:"commit" validate:"required,dive"`
	// Release specific config fields
	Release Release `mapstructure:"release" yaml:"release" validate:"required,dive"`
	// Flags specify custom flags for commands
	Flags []Flag `mapstructure:"flags" yaml:"flags" validate:"dive"`
}

Config has all the relevant settings

func New

func New() Config

New returns an new instance of Config with default values

func (Config) GetFlagsForBranch

func (c Config) GetFlagsForBranch() FlagList

GetFlagsForBranch returns all entries of the Flags field where SkipForBranch is not true

func (Config) GetFlagsForCommit

func (c Config) GetFlagsForCommit() FlagList

GetFlagsForCommit returns all entries of the Flags field where SkipForCommit is not true

func (Config) GetFlagsForRelease

func (c Config) GetFlagsForRelease() FlagList

GetFlagsForRelease returns all entries of the Flags field where SkipForRelease is not true

func (Config) Validate

func (c Config) Validate() error

Validate the Config structure

type Flag

type Flag struct {
	Name           string  `mapstructure:"name" yaml:"name" validate:"required,alphanum,lowercase"`
	Description    *string `mapstructure:"description" yaml:"description"`
	Required       *bool   `mapstructure:"required" yaml:"required"`
	Default        string  `mapstructure:"default" yaml:"default"`
	SkipForBranch  *bool   `mapstructure:"skip_for_branch" yaml:"skip_for_branch"`
	SkipForCommit  *bool   `mapstructure:"skip_for_commit" yaml:"skip_for_commit"`
	SkipForRelease *bool   `mapstructure:"skip_for_release" yaml:"skip_for_release"`
}

Flag is a custom configured flag which could be used for various commands of releaser

func (Flag) GetDefault

func (f Flag) GetDefault() string

GetDefault returns the value of the Default field

func (Flag) GetDescription

func (f Flag) GetDescription() string

GetDescription returns the value of the Description field if given, else default values

func (Flag) GetName

func (f Flag) GetName() string

GetName returns the value of the Name field

func (Flag) GetRequired

func (f Flag) GetRequired() bool

GetRequired returns the value of the Required field if given, else default value

func (Flag) GetSkipForBranch

func (f Flag) GetSkipForBranch() bool

GetSkipForBranch returns the value of the SkipForBranch field if given, else default value

func (Flag) GetSkipForCommit

func (f Flag) GetSkipForCommit() bool

GetSkipForCommit returns the value of the SkipForCommit field if given, else default value

func (Flag) GetSkipForRelease

func (f Flag) GetSkipForRelease() bool

GetkipForRelease returns the value of the SkipForRelease field if given, else default value

type FlagList

type FlagList []Flag

FlagList is a slice of Flag entries with some helpful functions

func (FlagList) Names

func (fl FlagList) Names() []string

Names of the entries in the FlagList

type Git

type Git struct {
	Executable *string `mapstructure:"executable" yaml:"executable" validate:"required,alpha,lowercase"`
	Remote     *string `mapstructure:"remote" yaml:"remote" validate:"required,alphanum,lowercase"`
}

Git has git specific config settings

func (Git) GetExecutable

func (g Git) GetExecutable() string

GetExecutable returns the value of the Executable field if given, else default value

func (Git) GetRemote

func (g Git) GetRemote() string

GetRemote returns the value of the Remote field if given, else default value

type Global

type Global struct {
	Config `mapstructure:",squash"`
	// Projects which are handled by releaser
	Projects []Project `mapstructure:"projects" yaml:"projects"`
}

Global is the global config data structure of releaser. This is the actual data structure in the YAML configuration file

func Load

func Load() (*Global, error)

Load uses viper and unmarshals the YAML config into Global struct

func NewGlobal

func NewGlobal() *Global

NewGlobal returns an new instance of Global with default values

func (Global) GetConfigWithPresentProjectValues

func (g Global) GetConfigWithPresentProjectValues(project *Project) Config

GetConfigWithPresentProjectValues creates an instance of Config and assigns values of the Project instance to it if present Non-nil project param must be part of the Projects field.

func (Global) GetProjectConfigByPath

func (g Global) GetProjectConfigByPath(path string, textTemplateValues *data.TextTemplateValues) (*Project, error)

GetProjectConfigByPath checks and returns if any of the configured entries in the Projects field matches with the specified path

type Project

type Project struct {
	Config `mapstructure:",squash"`
	// Paths of the system to which these config settings should apply to. Supports wildcards
	Paths []string `mapstructure:"paths" yaml:"paths"`
}

Project is the project (path) specific config data structure

func (Project) MatchesWithPath

func (p Project) MatchesWithPath(pp string, textTemplateValues *data.TextTemplateValues) (bool, error)

MatchesWithPath checks if a given path string matches with the configured Path field

type Release

type Release struct {
	DescriptionFormat *string `mapstructure:"description_format" yaml:"description_format" validate:"required"`

	NameFormat *string                    `mapstructure:"name_format" yaml:"name_format" validate:"required"`
	FirstTag   *string                    `mapstructure:"first_tag" yaml:"first_tag" validate:"required"`
	Target     *string                    `mapstructure:"target" yaml:"target" validate:"required"`
	Upstreams  map[string]ReleaseUpstream `mapstructure:"upstreams" yaml:"upstreams"`
}

Release has release specific config settings

func (Release) GetDescriptionFormat

func (r Release) GetDescriptionFormat() string

GetDescriptionFormat returns the value of the DescriptionFormat field if given, else default value

func (Release) GetFirstTag

func (r Release) GetFirstTag() string

GetFirstTag returns the value of the FirstTag field if given, else default value

func (Release) GetNameFormat

func (r Release) GetNameFormat() string

GetNameFormat returns the value of the NameFormat field if given, else default value

func (Release) GetTarget

func (r Release) GetTarget() string

GetTarget returns the value of the Target field if given, else default value

func (Release) GetUpstreams

func (r Release) GetUpstreams() map[string]ReleaseUpstream

GetUpstreams returns the value of the Upstreams field

type ReleaseUpstream

type ReleaseUpstream struct {
	APITokenEnvVar *string `mapstructure:"api_token_env_var" yaml:"api_token_env_var"`
}

ReleaseUpstream has release upstream specific config settings

func (ReleaseUpstream) GetAPITokenEnvVar

func (r ReleaseUpstream) GetAPITokenEnvVar(name string) string

GetAPITokenEnvVar returns the value of the APITokenEnvVar field if given, else default value

Jump to

Keyboard shortcuts

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