config

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 9 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IncrementSprint added in v0.4.0

func IncrementSprint(path string) (int, error)

IncrementSprint reads the config file at path, increments versioning.sprint by one, writes the file back preserving all other content, and returns the new value. If sprint is absent from the file (default 0), it is inserted and set to 1.

func InitDest

func InitDest() string

InitDest returns the path heraut init should write to: .config/heraut.yml if .config/ exists, else .heraut.yml.

func ResolvePath

func ResolvePath(explicit string) string

ResolvePath returns the config file to use. See ResolvePathWithSource for the order.

Types

type Config

type Config struct {
	Version      string                 `yaml:"version"`
	Versioning   Versioning             `yaml:"versioning"`
	Changelog    *ContentDriver         `yaml:"changelog,omitempty"`
	Release      *Release               `yaml:"release,omitempty"`
	Environments map[string]Environment `yaml:"environments,omitempty"`
	// RemoteMetadata controls whether content generators fetch PR/MR metadata from the
	// platform API (author handle, PR number) to enrich changelog/release-notes:
	// "required" (fetch, fail if unavailable), "optional" (fetch when possible, else warn +
	// skip), "disabled" (never fetch). Empty resolves to "optional". Governs both changelog
	// and release-notes generation (T78).
	RemoteMetadata string `yaml:"remote_metadata,omitempty"`
	// Tickets configures issue-tracker links: each entry's regex is matched in commit
	// messages (subject/body/footer) and rendered as a link in the changelog and release
	// notes. git-cliff only (T79 / ADR-0024).
	Tickets []Ticket `yaml:"tickets,omitempty"`
}

Config is the parsed .heraut.yml.

func Load

func Load(path string) (*Config, error)

Load reads and strictly parses the config file at path, then applies heraut's post-parse defaults. Unknown YAML fields are rejected.

func LoadFromReader

func LoadFromReader(r io.Reader) (*Config, error)

LoadFromReader strictly parses config from r, then applies heraut's defaults.

func (*Config) EffectiveTagFormat added in v0.19.0

func (c *Config) EffectiveTagFormat(env string) string

EffectiveTagFormat returns the tag format for env: the environment-level override when set, otherwise the top-level versioning.tag_format. This lets a single top-level format (e.g. "{env}/{version}") cover every environment while allowing per-environment overrides. env may be empty for non-per-env strategies.

type ContentDriver

type ContentDriver struct {
	Generator  string `yaml:"generator"`
	Config     string `yaml:"config,omitempty"`
	Output     string `yaml:"output,omitempty"`
	TagPattern string `yaml:"tag_pattern,omitempty"`
	Template   string `yaml:"template,omitempty"`
	// HeadingVersionPattern is set by the app layer when the effective tag_format contains
	// {env} or {build}. It is injected into the effective git-cliff TOML as a postprocessor
	// that strips the env prefix/suffix and build ID from version headings (leaving just the
	// version). Not user-configurable.
	HeadingVersionPattern string `yaml:"-"`
	// RemoteMetadata is the effective top-level Config.RemoteMetadata policy, propagated onto
	// the driver by the app layer so the generator can honour it. Empty means "optional".
	// Not user-configurable at the driver level (the user sets it once at the top level).
	RemoteMetadata string `yaml:"-"`
	// Tickets is the effective top-level Config.Tickets, propagated onto the driver by the
	// app layer so the generator can inject link_parsers. Not user-configurable per-driver.
	Tickets []Ticket `yaml:"-"`
}

ContentDriver configures a content generator (git-cliff, communique, cocogitto).

func MergeContentDriver added in v0.20.0

func MergeContentDriver(base, override *ContentDriver) *ContentDriver

MergeContentDriver returns the effective ContentDriver for a per-environment override applied over a top-level base, per ADR-0019:

  • nil base → override (nothing to inherit); nil override → base.
  • If override sets a generator that differs from base, the override fully replaces base (generator-specific fields like config/template do not carry across generators).
  • Otherwise field-by-field merge: a non-empty override field wins; an empty field inherits from base.

Neither argument is mutated; the result is always a fresh value (or the sole non-nil argument when one side is nil).

type EnvRelease added in v0.10.0

type EnvRelease struct {
	Notes     *ContentDriver `yaml:"notes,omitempty"`
	Platforms []Platform     `yaml:"platforms,omitempty"`
}

EnvRelease holds per-environment release overrides. Nil fields mean "inherit from root release", which differs from root Release where nil means "disabled".

type Environment added in v0.10.0

type Environment struct {
	// Versioning fields
	Bump      string `yaml:"bump"`
	TagFormat string `yaml:"tag_format,omitempty"`
	Branch    string `yaml:"branch,omitempty"`
	Source    string `yaml:"source,omitempty"`

	// Content fields
	DisableChangelog bool           `yaml:"disable_changelog,omitempty"`
	DisableNotes     bool           `yaml:"disable_notes,omitempty"`
	Changelog        *ContentDriver `yaml:"changelog,omitempty"`
	Release          *EnvRelease    `yaml:"release,omitempty"`
}

Environment holds all per-environment configuration under the root environments map. Versioning fields drive version resolution; content fields override changelog/release.

type PathSource added in v0.16.0

type PathSource string

PathSource identifies how a config file path was resolved. The values mirror forge's Resolver.Label output for app "heraut".

const (
	SourceFlag      PathSource = "--config"
	SourceEnvVar    PathSource = "HERAUT_FILE"
	SourceXDGConfig PathSource = ".config/heraut.yml"
	SourceDefault   PathSource = ".heraut.yml"
)

func ResolvePathWithSource added in v0.16.0

func ResolvePathWithSource(explicit string) (string, PathSource)

ResolvePathWithSource returns the config file to use and the source that determined it (see forge's Resolver: --config flag → HERAUT_FILE → .config/heraut.yml → .heraut.yml).

type Platform

type Platform struct {
	Type string `yaml:"platform"`
	// GitHub-specific
	Repository string `yaml:"repository,omitempty"`
	Draft      bool   `yaml:"draft,omitempty"`
	Prerelease bool   `yaml:"prerelease,omitempty"`
	// GitLab-specific
	Project string `yaml:"project,omitempty"`
	// Shared
	BaseURL  string   `yaml:"base_url,omitempty"`
	TokenEnv string   `yaml:"token_env,omitempty"`
	Assets   []string `yaml:"assets,omitempty"`
	// LenientAssets is set programmatically when assets come from release.assets (top-level).
	// When true, a glob pattern that matches nothing emits a warning instead of an error.
	LenientAssets bool `yaml:"-"`
}

Platform holds settings for one release platform (github or gitlab). Type is the platform discriminator ("github" or "gitlab") mapping to yaml:"platform"; using Type avoids the Platform.Platform self-reference (ADR-0006).

type Release

type Release struct {
	Notes     *ContentDriver `yaml:"notes,omitempty"`
	Platforms []Platform     `yaml:"platforms,omitempty"`
	// Assets lists glob patterns for files to attach to the GitHub/GitLab release.
	// Globs are expanded at release time; a pattern matching nothing emits a warning
	// but does not abort the release. Applied to all configured platforms.
	Assets []string `yaml:"assets,omitempty"`
}

Release holds release notes and platform settings.

type Ticket added in v0.30.0

type Ticket struct {
	Pattern string `yaml:"pattern"`
	URL     string `yaml:"url"`
}

Ticket maps a commit ticket-ID pattern to a URL template. {ticket} in URL is the first capture group of Pattern (or the full match if Pattern has no group); the link label is always the full match.

type ValidationError

type ValidationError = forgeconfig.ValidationError

ValidationError and ValidationErrors are heraut's aliases for forge's structured validation errors (Path/Message/Hint). The validator produces them; cmd renders them.

type ValidationErrors

type ValidationErrors = forgeconfig.ValidationErrors

ValidationError and ValidationErrors are heraut's aliases for forge's structured validation errors (Path/Message/Hint). The validator produces them; cmd renders them.

func Validate

func Validate(cfg *Config) ValidationErrors

Validate runs all semantic validation layers against cfg. All errors are collected and returned; validation does not stop on the first error.

type Versioning

type Versioning struct {
	Strategy       string  `yaml:"strategy"`
	TagPrefix      *string `yaml:"tag_prefix,omitempty"`
	InitialVersion string  `yaml:"initial_version,omitempty"`
	Bump           string  `yaml:"bump,omitempty"`
	Format         string  `yaml:"format,omitempty"`
	Sprint         int     `yaml:"sprint,omitempty"`
	TagFormat      string  `yaml:"tag_format,omitempty"`
	TagType        string  `yaml:"tag_type,omitempty"`
}

Versioning holds version resolution settings.

Jump to

Keyboard shortcuts

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