config

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config messages - error and log message constants Exported so tests can compare against them

Index

Constants

View Source
const (
	ErrConfigNotFound        = "config file not found"
	ErrConfigParseFail       = "failed to parse config file"
	ErrInvalidTemplateSyntax = "invalid template syntax"
)

Error messages

View Source
const (
	LogConfigLoaded  = "config_loaded"
	LogConfigSaved   = "config_saved"
	LogConfigCreated = "config_created"
)

Log messages for structured logging

View Source
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

func DeleteCustom(key string) error

DeleteCustom removes a custom key from the config

func GetAllCustom

func GetAllCustom() (map[string]string, error)

GetAllCustom returns all custom key-value pairs

func GetCustom

func GetCustom(key string) (string, bool, error)

GetCustom returns a custom value by key

func SetCustom

func SetCustom(key, value string) error

SetCustom sets a custom key-value pair in the config

func ValidateTemplate

func ValidateTemplate(template string) error

ValidateTemplate checks if a Mustache template is syntactically valid

func WriteConfig

func WriteConfig(config *Config) error

Types

type BranchVersioningConfig added in v0.1.0

type BranchVersioningConfig struct {
	// Enabled controls whether branch-aware versioning is active
	// Default: false (opt-in)
	Enabled bool `yaml:"enabled"`
	// MainBranches is a list of branch patterns that produce clean versions
	// Supports exact matches and glob patterns (e.g., "release/*")
	// Default: ["main", "master", "release/*"]
	MainBranches []string `yaml:"mainBranches"`
	// PrereleaseTemplate is a Mustache template for the branch pre-release identifier
	// Default: "{{EscapedBranchName}}-{{CommitsSinceTag}}"
	PrereleaseTemplate string `yaml:"prereleaseTemplate"`
	// Mode controls how branch pre-release interacts with existing pre-release
	// "replace" (default): Branch pre-release replaces any existing pre-release
	// "append": Branch pre-release is appended to existing pre-release
	Mode string `yaml:"mode"`
}

BranchVersioningConfig holds branch-aware versioning configuration

type Config

type Config struct {
	Prefix           string                 `yaml:"prefix"`
	PreRelease       PreReleaseConfig       `yaml:"prerelease"`
	Metadata         MetadataConfig         `yaml:"metadata"`
	Release          ReleaseConfig          `yaml:"release"`
	BranchVersioning BranchVersioningConfig `yaml:"branchVersioning"`
	Logging          LoggingConfig          `yaml:"logging"`
	Custom           map[string]string      `yaml:"custom,omitempty"`
	Updates          []UpdateConfig         `yaml:"updates,omitempty"`
}

Config holds configuration for version metadata behavior

func ReadConfig

func ReadConfig() (*Config, error)

ReadConfig reads the configuration from .versionator.yaml file

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the config is valid, including template syntax

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"
	Stable   bool      `yaml:"stable"`   // If true, value is written to VERSION file; if false, generated at output time
	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.

Stability controls where the metadata value lives:

  • Stable=true: Value is written to VERSION file
  • Stable=false: Value is generated from template at output time (default)

type PreReleaseConfig

type PreReleaseConfig struct {
	Template string `yaml:"template"` // Mustache template with DASHES as separators: "alpha-{{CommitsSinceTag}}" → "alpha-5"
	Stable   bool   `yaml:"stable"`   // If true, value is written to VERSION file; if false, generated at output time
}

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.

Stability controls where the pre-release value lives:

  • Stable=true: Value is written to VERSION file (traditional release workflow)
  • Stable=false: Value is generated from template at output time (default, CD workflow)

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

type UpdateConfig added in v0.1.0

type UpdateConfig struct {
	// File is the path to the file to update (relative to repo root)
	File string `yaml:"file"`
	// Path is the dasel selector for the value to update (e.g., "package.version")
	Path string `yaml:"path"`
	// Template is a Mustache template for the new value (e.g., "{{MajorMinorPatch}}")
	Template string `yaml:"template"`
	// Format explicitly sets the file format (json, yaml, toml). Auto-detected from extension if empty.
	Format string `yaml:"format,omitempty"`
}

UpdateConfig holds configuration for a single structured file update Updates are applied during release to keep manifest files in sync with VERSION

Jump to

Keyboard shortcuts

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