Documentation
¶
Index ¶
- func Init()
- func Load(runValidation bool) error
- func SetDefaultValues()
- type Config
- type DynamicFlag
- type Rule
- func (r Rule) FlagNames() []string
- func (r Rule) FlagNamesForBranch() []string
- func (r Rule) FlagNamesForCommit() []string
- func (r Rule) FlagsForBranch() []DynamicFlag
- func (r Rule) FlagsForCommit() []DynamicFlag
- func (r Rule) GetGitBranchDelimiter() string
- func (r Rule) GetGitBranchTypes() []string
- func (r Rule) MatchesWithPath(p string) (bool, error)
- func (r Rule) ParsedPaths() ([]string, error)
- func (r Rule) Validate() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init()
Init function is to setup config paths and their ENV binding. Should just be called once.
func SetDefaultValues ¶
func SetDefaultValues()
SetDefaultValues sets the default values for the config keys managed with viper.
Types ¶
type Config ¶
type Config struct { FirstVersion string `mapstructure:"first_version" validate="required"` GitExecutable string `mapstructure:"git_executable" validate="required"` GitRemote string `mapstructure:"git_remote" validate="required"` GitRepoURL string `mapstructure:"git_repo_url"` LatestVersion string `mapstructure:"latest_version"` NewVersion string `mapstructure:"new_version"` // Rules defines rule sets for different paths Rules []Rule `mapstructure:"rules" yaml:"rules"` }
Config is the application configuration data struct
var ( // Cfg is the global instance of Config Cfg *Config )
func (Config) GetMatchingPathRule ¶
GetMatchingPathRule returns first Rule of the Config where MatchesWithPath is true
func (Config) ValidateRules ¶
ValidateRules runs Validate function on each entry in Rules list of Config instance
type DynamicFlag ¶
type DynamicFlag struct { // Name of the itself Name string `validate:"required,alpha,lowercase"` // Default is an optional default value which should always be used for the flag Default string // Description of the flag itself (optional) Description string Required bool // SkipForBranch will not use this flag for any branch releated command and operation SkipForBranch bool `mapstructure:"skip_for_branch" yaml="skip_for_branch"` // SkipForCommit will not use this flag for any commit releated command and operation SkipForCommit bool `mapstructure:"skip_for_commit" yaml="skip_for_commit"` }
DynamicFlag holds a config for a dynamic flag which applies for a certain path. It should be used within a Rule.
func (DynamicFlag) Validate ¶
func (d DynamicFlag) Validate() error
Validate runs the validators of the DynamicFlag instance
type Rule ¶
type Rule struct { // A list of dynamic flags which are added to certain commands under the given paths. Flags []DynamicFlag `mapstructure:"flags" yaml:"flags"` // GitBranchDefaultType defines the default type of branch that should be used GitBranchDefaultType string `mapstructure:"git_branch_default_type" yaml:"git_branch_default_type"` // GitBranchDelimiter defines the sign which connects certain parts of the branch name. // It just can be one sign and only one of '-', '_', '/' '+'. Default is '-' GitBranchDelimiter string `mapstructure:"git_branch_delimiter" validate:"omitempty,max=1,oneof='-' '_' '/' '+'" yaml:"git_branch_delimiter"` // GitBranchForceType: if true a type for the branch needs always to be set GitBranchForceType bool `mapstructure:"git_branch_force_type" yaml:"git_branch_force_type"` // GitBranchPrefix defines the prefix which is set for a branch name GitBranchPrefix string `mapstructure:"git_branch_prefix" yaml:"git_branch_prefix"` // GitBranchSuffix defines the suffix which is set for a branch name GitBranchSuffix string `mapstructure:"git_branch_suffix" yaml:"git_branch_suffix"` // GitBranchTypes defines the overwrites of available types. If not set the defaults are: // feature, bug, hotfix GitBranchTypes []string `mapstructure:"git_branch_types" validate:"unique,dive,lowercase,alpha" yaml:"git_branch_types"` // Paths are the paths with certain rules to which this rule should be applied to Paths []string `mapstructure:"paths" yaml:"paths"` }
Rule is a struct of settings and rules for a certain path
func (Rule) FlagNamesForBranch ¶
FlagNamesForBranch returns the Name attribute of each element in r.FlagNamesForBranch
func (Rule) FlagNamesForCommit ¶
FlagNamesForCommit returns the Name attribute of each element in r.FlagNamesForCommit
func (Rule) FlagsForBranch ¶
func (r Rule) FlagsForBranch() []DynamicFlag
FlagsForBranch will only return entries of r.Flags list where SkipForBranch is false
func (Rule) FlagsForCommit ¶
func (r Rule) FlagsForCommit() []DynamicFlag
FlagsForCommit will only return entries of r.Flags list where SkipForCommit is false
func (Rule) GetGitBranchDelimiter ¶
GetGitBranchDelimiter returns the defined r.GitBranchDelimiter or "-" as default
func (Rule) GetGitBranchTypes ¶
GetGitBranchTypes returns either r.GitBranchTypes or the default ones
func (Rule) MatchesWithPath ¶
MatchesWithPath checks if a given path matches with any of the defined path rules
func (Rule) ParsedPaths ¶
ParsedPaths returns the Paths list with parsed variables of the Rule instance