Documentation
¶
Overview ¶
Package config messages - error and log message constants Exported so tests can compare against them
Index ¶
- Constants
- func DefaultConfigYAML() string
- func DeleteCustom(key string) error
- func GetAllCustom() (map[string]string, error)
- func GetCustom(key string) (string, bool, error)
- func SetCustom(key, value string) error
- func ValidateTemplate(template string) error
- func WriteConfig(config *Config) error
- type Config
- type GitConfig
- type LoggingConfig
- type MetadataConfig
- type PreReleaseConfig
- type ReleaseConfig
Constants ¶
const ( ErrConfigNotFound = "config file not found" ErrConfigParseFail = "failed to parse config file" ErrInvalidTemplateSyntax = "invalid template syntax" )
Error messages
const ( LogConfigLoaded = "config_loaded" LogConfigSaved = "config_saved" LogConfigCreated = "config_created" )
Log messages for structured logging
const ( // FilePermission is the default permission for created files (owner rw, group/other r) FilePermission os.FileMode = 0644 )
File permission constants
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigYAML ¶
func DefaultConfigYAML() string
DefaultConfigYAML returns a well-documented default configuration as YAML
func DeleteCustom ¶
DeleteCustom removes a custom key from the config
func GetAllCustom ¶
GetAllCustom returns all custom key-value pairs
func ValidateTemplate ¶
ValidateTemplate checks if a Mustache template is syntactically valid
func WriteConfig ¶
Types ¶
type Config ¶
type Config struct {
Prefix string `yaml:"prefix"`
PreRelease PreReleaseConfig `yaml:"prerelease"`
Metadata MetadataConfig `yaml:"metadata"`
Release ReleaseConfig `yaml:"release"`
Logging LoggingConfig `yaml:"logging"`
Custom map[string]string `yaml:"custom,omitempty"`
}
Config holds configuration for version metadata behavior
func ReadConfig ¶
ReadConfig reads the configuration from .versionator.yaml file
type GitConfig ¶
type GitConfig struct {
HashLength int `yaml:"hashLength"`
}
GitConfig holds git-specific configuration
type LoggingConfig ¶
type LoggingConfig struct {
Output string `yaml:"output"` // console, json, development
}
LoggingConfig holds logging-specific configuration
type MetadataConfig ¶
type MetadataConfig struct {
Template string `yaml:"template"` // Mustache template with DOTS as separators: "{{BuildDateTimeCompact}}.{{ShortHash}}" → "20241211.abc1234"
Git GitConfig `yaml:"git"`
}
MetadataConfig holds build metadata configuration Metadata follows SemVer 2.0.0: appended with + (plus)
IMPORTANT: The Template is a Mustache template string. Use DOTS (.) to separate metadata identifiers per SemVer 2.0.0. Example: "{{BuildDateTimeCompact}}.{{ShortHash}}" → "20241211103045.abc1234"
The leading plus (+) is automatically prepended when using {{MetadataWithPlus}} Do NOT include the leading plus in your template.
The VERSION file is the source of truth for current metadata value. This template is stored for use with 'metadata enable' and '--metadata' flag.
type PreReleaseConfig ¶
type PreReleaseConfig struct {
Template string `yaml:"template"` // Mustache template with DASHES as separators: "alpha-{{CommitsSinceTag}}" → "alpha-5"
}
PreReleaseConfig holds pre-release identifier configuration Pre-release follows SemVer 2.0.0: appended with - (dash)
IMPORTANT: The Template is a Mustache template string. Use DASHES (-) to separate pre-release identifiers per SemVer 2.0.0. Example: "alpha-{{CommitsSinceTag}}" → "alpha-5"
The leading dash (-) is automatically prepended when using {{PreReleaseWithDash}} Do NOT include the leading dash in your template.
The VERSION file is the source of truth for current pre-release value. This template is stored for use with 'prerelease enable' and '--prerelease' flag.
type ReleaseConfig ¶ added in v0.0.12
type ReleaseConfig struct {
// CreateBranch controls whether a release branch is created when tagging
// Default: true
CreateBranch bool `yaml:"createBranch"`
// BranchPrefix is prepended to the tag name to form the branch name
// Default: "release/" (e.g., tag "v1.2.3" -> branch "release/v1.2.3")
BranchPrefix string `yaml:"branchPrefix"`
}
ReleaseConfig holds release-related configuration