config

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

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 Config

type Config struct {
	Prefix     string            `yaml:"prefix"`
	PreRelease PreReleaseConfig  `yaml:"prerelease"`
	Metadata   MetadataConfig    `yaml:"metadata"`
	Logging    LoggingConfig     `yaml:"logging"`
	Custom     map[string]string `yaml:"custom,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"
	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.

Jump to

Keyboard shortcuts

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