config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigDir        = "config"
	OutputsDir       = "outputs"
	TemplatesDir     = "templates"
	OutputFileSuffix = ".gitrepoforge"

	TemplateModeDoubleBracket       = "DOUBLE_BRACKET"
	TemplateModeDoubleBracketStrict = "DOUBLE_BRACKET_STRICT"
)
View Source
const (
	// PullRequestNo disables pull request creation.
	PullRequestNo = "NO"
	// PullRequestGitHubCLI creates pull requests using the GitHub CLI.
	PullRequestGitHubCLI = "GITHUB_CLI"
)
View Source
const RepoConfigFileName = ".gitrepoforge"
View Source
const RootConfigFileName = ".gitrepoforge-config"

Variables

This section is empty.

Functions

func ApplyConfigDefaults

func ApplyConfigDefaults(repoCfg *RepoConfig, centralCfg *CentralConfig)

func AsConfigMap

func AsConfigMap(value interface{}) (map[string]interface{}, bool)

func ExtractGitPlaceholders

func ExtractGitPlaceholders(value string) []string

func IsReservedConfigName

func IsReservedConfigName(name string) bool

func RepoConfigExists

func RepoConfigExists(repoPath string) bool

RepoConfigExists returns true if a .gitrepoforge file exists in the repo.

func ResolvedConfigValues

func ResolvedConfigValues(repoCfg *RepoConfig, centralCfg *CentralConfig) map[string]interface{}

func TemplateModeOrDefault

func TemplateModeOrDefault(mode string) string

TemplateModeOrDefault returns the configured template mode, or the default mode when the field is omitted.

Types

type CentralConfig

type CentralConfig struct {
	RootDir     string
	Definitions []ConfigDefinition
	Files       []FileRule
}

CentralConfig represents the desired-state configuration repository. Config definitions are loaded from individual files under config/. File rules are loaded from individual files under outputs/.

func LoadCentralConfig

func LoadCentralConfig(configRepoPath string) (*CentralConfig, error)

LoadCentralConfig loads the central config from the config repo by scanning the config/ and outputs/ directories for individual definition files.

type ConfigDefinition

type ConfigDefinition struct {
	Name            string             `yaml:"-"`
	Type            string             `yaml:"type"`
	Required        bool               `yaml:"required"`
	Enum            []string           `yaml:"enum"`
	Default         interface{}        `yaml:"default"`
	HasDefault      bool               `yaml:"-"`
	Description     string             `yaml:"description"`
	Pattern         string             `yaml:"pattern"`
	CompiledPattern *regexp.Regexp     `yaml:"-"`
	PatternGroups   []string           `yaml:"-"`
	Attributes      []ConfigDefinition `yaml:"-"`
}

ConfigDefinition defines a valid config value for per-repo configs. Each definition is stored as its own file: config/<name>.yaml

func (*ConfigDefinition) UnmarshalYAML

func (d *ConfigDefinition) UnmarshalYAML(node *yaml.Node) error

type FileRule

type FileRule struct {
	Path      string        `yaml:"-"`
	Mode      string        `yaml:"mode"`
	Templates []TemplateRef `yaml:"templates"`
}

FileRule defines how an output file is managed. Each rule is stored as its own file: outputs/<path>.gitrepoforge

type GitConfig

type GitConfig struct {
	CreateBranch           bool   `yaml:"create_branch"`
	BranchName             string `yaml:"branch_name"`
	Commit                 bool   `yaml:"commit"`
	CommitMessage          string `yaml:"commit_message"`
	Push                   bool   `yaml:"push"`
	Remote                 string `yaml:"remote"`
	PullRequest            string `yaml:"pull_request"`
	ReturnToOriginalBranch bool   `yaml:"return_to_original_branch"`
	DeleteBranch           bool   `yaml:"delete_branch"`
}

GitConfig controls the Git automation performed during apply. It mirrors the git configuration section from the repver tool.

func (*GitConfig) BuildBranchName

func (g *GitConfig) BuildBranchName(values map[string]string) string

func (*GitConfig) BuildCommitMessage

func (g *GitConfig) BuildCommitMessage(values map[string]string) string

func (*GitConfig) GitOptionsSpecified

func (g *GitConfig) GitOptionsSpecified() bool

func (*GitConfig) Normalize

func (g *GitConfig) Normalize()

type RepoConfig

type RepoConfig struct {
	Name          string                 `yaml:"name"`
	DefaultBranch string                 `yaml:"default_branch"`
	Config        map[string]interface{} `yaml:"config"`
}

RepoConfig represents the per-repo config dotfile (.gitrepoforge).

func LoadRepoConfig

func LoadRepoConfig(repoPath string) (*RepoConfig, error)

func (*RepoConfig) PlaceholderValues

func (rc *RepoConfig) PlaceholderValues() map[string]string

type RootConfig

type RootConfig struct {
	ConfigRepo    string    `yaml:"config_repo"`
	Excludes      []string  `yaml:"excludes"`
	IgnoreMissing bool      `yaml:"ignore_missing"`
	Git           GitConfig `yaml:"-"`
}

RootConfig represents the root config dotfile (.gitrepoforge-config) that lives in the checkout root (workspace directory).

func LoadRootConfig

func LoadRootConfig(workspaceDir string) (*RootConfig, error)

func (*RootConfig) ResolveConfigRepoPath

func (rc *RootConfig) ResolveConfigRepoPath(workspaceDir string) string

ResolveConfigRepoPath resolves the config repo path (relative to workspace or absolute).

type TemplateRef

type TemplateRef struct {
	Condition    string `yaml:"condition"`
	Template     string `yaml:"template"`
	Evaluate     bool   `yaml:"evaluate"`
	TemplateMode string `yaml:"template_mode"`
	Absent       bool   `yaml:"absent"`
	ResolvedPath string `yaml:"-"`
}

TemplateRef selects a template file from templates/.

Jump to

Keyboard shortcuts

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