Documentation
¶
Index ¶
- Constants
- Variables
- func ContextWithConfig(ctx context.Context, cfg *GitteConfig) context.Context
- func ContextWithCwd(ctx context.Context, cwd string) context.Context
- func CwdFromContext(ctx context.Context) string
- func LoadRemoteConfig(ctx context.Context, envContent []byte, cache *RemoteConfigCache, ...) (*GitteConfig, *RemoteConfigCache, error)
- func LocalDirForRemote(remote string) (string, error)
- func MarshalYAMLRemoteCache(cache *RemoteConfigCache) ([]byte, error)
- func ParseRemoteURL(remote string) (host, path, localDir string, err error)
- func ResolveEnvWhen(entries map[string]EnvWhenEntry, arch string) map[string]string
- func ResolveTemplates(cfg *GitteConfig) error
- func SaveOverrideConfig(dir string, cfg *GitteConfig) error
- type ActionOverride
- type BaseStartupCheck
- type CommandStartupCheck
- type EnvWhenCondition
- type EnvWhenEntry
- type FeatureEffects
- type FeatureGate
- type FeatureScope
- type FileDefinition
- type GithubScope
- type GithubSource
- type GitlabScope
- type GitlabSource
- type GitteConfig
- func ConfigFromContext(ctx context.Context) *GitteConfig
- func LoadAndMergeConfig(fd FileDefinition) (*GitteConfig, error)
- func LoadGitteConfigFromYAML(content []byte) (*GitteConfig, error)
- func LoadOverrideConfig(dir string) (*GitteConfig, error)
- func MergeOverride(base, override *GitteConfig) *GitteConfig
- type ProjectAction
- type ProjectConfig
- type QuickSolveConfig
- type QuickSolveGitClean
- type RemoteConfigCache
- type RetryConfig
- type RetryDefaults
- type SearchFor
- type ShellStartupCheck
- type Sources
- type StartupCheck
- type StartupCheckMap
- type TelemetryConfig
- type Template
- type ToggledProjects
- type ValidationError
- type ValidationResult
- type YamlPathPresentStartupCheck
Constants ¶
const ConfigPath = ".gitte.yml"
const DotEnvPath = ".gitte-env"
const OverridePath = ".gitte-override.yml"
Variables ¶
var ErrGitteConfigNotFound = errors.New("gitte configuration file not found")
Functions ¶
func ContextWithConfig ¶
func ContextWithConfig(ctx context.Context, cfg *GitteConfig) context.Context
ContextWithConfig stores the GitteConfig in context
func ContextWithCwd ¶
ContextWithCwd stores the working directory in context
func CwdFromContext ¶
CwdFromContext retrieves the working directory from context
func LoadRemoteConfig ¶
func LoadRemoteConfig(ctx context.Context, envContent []byte, cache *RemoteConfigCache, onRefreshed func(*RemoteConfigCache), verbose bool) (*GitteConfig, *RemoteConfigCache, error)
LoadRemoteConfig fetches remote config via git archive. If a valid cache entry exists it is returned immediately and a background goroutine is started to refresh the cache. onRefreshed is called with the new cache entry when the refresh completes (use it to persist the cache).
func LocalDirForRemote ¶
LocalDirForRemote returns the local directory path for a project's remote URL
func MarshalYAMLRemoteCache ¶
func MarshalYAMLRemoteCache(cache *RemoteConfigCache) ([]byte, error)
MarshalYAMLRemoteCache serializes cache to YAML bytes.
func ParseRemoteURL ¶
ParseRemoteURL parses a git remote URL and returns (host, namespacedPath, localDir) Supports:
git@gitlab.example.com:org/services/myrepo.git -> gitlab.example.com/org/services/myrepo https://github.com/example/myrepo.git -> github.com/example/myrepo
func ResolveEnvWhen ¶
func ResolveEnvWhen(entries map[string]EnvWhenEntry, arch string) map[string]string
ResolveEnvWhen evaluates env_when entries against the given arch and returns only the variables whose conditions all pass. arch should be runtime.GOARCH. Unknown condition types conservatively exclude the variable.
func ResolveTemplates ¶
func ResolveTemplates(cfg *GitteConfig) error
ResolveTemplates applies template inheritance (extends) to all projects and performs Go text/template variable substitution. It modifies cfg.Projects in place and removes cfg.Templates when done.
func SaveOverrideConfig ¶
func SaveOverrideConfig(dir string, cfg *GitteConfig) error
SaveOverrideConfig writes cfg to .gitte-override.yml, replacing any existing file.
Types ¶
type ActionOverride ¶
type ActionOverride struct {
MaxParallelization int `yaml:"maxParallelization,omitempty"`
}
ActionOverride allows per-action configuration overrides
type BaseStartupCheck ¶
type BaseStartupCheck struct {
Type string `yaml:"type"`
Hint string `yaml:"hint,omitempty"`
Needs []string `yaml:"needs,omitempty"`
}
BaseStartupCheck holds common fields for all check types
func (*BaseStartupCheck) GetHint ¶
func (b *BaseStartupCheck) GetHint() string
func (*BaseStartupCheck) GetNeeds ¶
func (b *BaseStartupCheck) GetNeeds() []string
func (*BaseStartupCheck) GetType ¶
func (b *BaseStartupCheck) GetType() string
type CommandStartupCheck ¶
type CommandStartupCheck struct {
BaseStartupCheck `yaml:",inline"`
Command []string `yaml:"cmd"`
}
CommandStartupCheck runs a command and checks exit code
type EnvWhenCondition ¶
EnvWhenCondition is one condition in an EnvWhenEntry. Type is the discriminator; currently only "arch" is supported.
type EnvWhenEntry ¶
type EnvWhenEntry struct {
Value string `yaml:"value"`
Conditions []EnvWhenCondition `yaml:"conditions,omitempty"`
}
EnvWhenEntry is a single entry in an env_when map. The variable is only injected when all Conditions pass. An empty Conditions list means always inject (equivalent to plain env).
type FeatureEffects ¶
type FeatureEffects struct {
Env map[string]string `yaml:"env,omitempty"`
EnvWhen map[string]EnvWhenEntry `yaml:"env_when,omitempty"`
}
FeatureEffects defines what a feature gate does when enabled
type FeatureGate ¶
type FeatureGate struct {
Description string `yaml:"description,omitempty"`
Effects FeatureEffects `yaml:"effects,omitempty"`
Scope FeatureScope `yaml:"scope,omitempty"`
}
FeatureGate defines a feature that can be enabled/disabled per machine
type FeatureScope ¶
type FeatureScope struct {
Projects []string `yaml:"projects,omitempty"`
GitlabGroups []GitlabScope `yaml:"gitlab_groups,omitempty"`
GithubOrgs []GithubScope `yaml:"github_orgs,omitempty"`
}
FeatureScope defines which projects a feature gate applies to
type FileDefinition ¶
FileDefinition holds raw config file content and metadata
func ResolveGitteDir ¶
func ResolveGitteDir(cwd string) (FileDefinition, error)
ResolveGitteDir walks up from cwd to find .gitte.yml or .gitte-env
type GithubScope ¶
GithubScope defines a GitHub org scope for feature gates
type GithubSource ¶
type GithubSource struct {
Host string `yaml:"host"`
TokenEnv string `yaml:"token_env,omitempty"`
TokenCmd string `yaml:"token_cmd,omitempty"`
Orgs []string `yaml:"orgs,omitempty"`
}
GithubSource defines a GitHub source for auto-discovery
type GitlabScope ¶
GitlabScope defines a GitLab group scope for feature gates
type GitlabSource ¶
type GitlabSource struct {
Host string `yaml:"host"`
TokenEnv string `yaml:"token_env,omitempty"`
TokenCmd string `yaml:"token_cmd,omitempty"`
Groups []string `yaml:"groups,omitempty"`
}
GitlabSource defines a GitLab source for auto-discovery
type GitteConfig ¶
type GitteConfig struct {
StartupChecks StartupCheckMap `yaml:"startup,omitempty"`
Templates map[string]Template `yaml:"templates,omitempty"`
FeatureGates map[string]FeatureGate `yaml:"feature_gates,omitempty"`
Sources Sources `yaml:"sources,omitempty"`
SearchFor []SearchFor `yaml:"searchFor,omitempty"`
ActionOverride map[string]ActionOverride `yaml:"actionOverride,omitempty"`
Retry RetryDefaults `yaml:"retry,omitempty"`
GroupIncludes map[string][]string `yaml:"groupIncludes,omitempty"`
Projects map[string]ProjectConfig `yaml:"projects,omitempty"`
QuickSolve QuickSolveConfig `yaml:"quickSolve,omitempty"`
Telemetry TelemetryConfig `yaml:"telemetry,omitempty"`
}
GitteConfig is the top-level configuration struct for .gitte.yml
func ConfigFromContext ¶
func ConfigFromContext(ctx context.Context) *GitteConfig
ConfigFromContext retrieves the GitteConfig from context
func LoadAndMergeConfig ¶
func LoadAndMergeConfig(fd FileDefinition) (*GitteConfig, error)
LoadAndMergeConfig loads .gitte.yml and merges .gitte-override.yml if present
func LoadGitteConfigFromYAML ¶
func LoadGitteConfigFromYAML(content []byte) (*GitteConfig, error)
LoadGitteConfigFromYAML parses raw YAML bytes into a GitteConfig
func LoadOverrideConfig ¶
func LoadOverrideConfig(dir string) (*GitteConfig, error)
LoadOverrideConfig loads .gitte-override.yml and returns it as a GitteConfig. Returns an empty config if the file does not exist.
func MergeOverride ¶
func MergeOverride(base, override *GitteConfig) *GitteConfig
MergeOverride merges an override config on top of the base config Override values win over base values (shallow at top level, deep for projects/actions).
func (*GitteConfig) FilterToggles ¶
func (cfg *GitteConfig) FilterToggles(toggledProjects ToggledProjects)
FilterToggles removes projects based on toggle state
func (*GitteConfig) WithTogglesApplied ¶
func (cfg *GitteConfig) WithTogglesApplied(toggledProjects ToggledProjects) *GitteConfig
WithTogglesApplied returns a shallow copy of the config with toggles applied, leaving the receiver unmodified. Used by the toggle command which needs the full (unfiltered) project list.
type ProjectAction ¶
type ProjectAction struct {
SearchFors []SearchFor `yaml:"searchFor,omitempty"`
Needs []string `yaml:"needs,omitempty"`
Groups map[string][]string `yaml:"groups,omitempty"`
Retry *RetryConfig `yaml:"retry,omitempty"`
}
ProjectAction represents an action (build/up/down/purge) for a project
type ProjectConfig ¶
type ProjectConfig struct {
Remote string `yaml:"remote"`
DefaultBranch string `yaml:"default_branch,omitempty"`
Actions map[string]ProjectAction `yaml:"actions,omitempty"`
DefaultDisabled bool `yaml:"defaultDisabled,omitempty"`
Extends string `yaml:"extends,omitempty"`
Vars map[string]string `yaml:"vars,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
EnvWhen map[string]EnvWhenEntry `yaml:"env_when,omitempty"`
}
ProjectConfig represents a single project in the config
type QuickSolveConfig ¶
type QuickSolveConfig struct {
GitClean QuickSolveGitClean `yaml:"git_clean,omitempty"`
}
QuickSolveConfig holds settings for the quick solve feature in the actions TUI.
type QuickSolveGitClean ¶
type QuickSolveGitClean struct {
Exclude []string `yaml:"exclude,omitempty"`
}
QuickSolveGitClean configures which directories are excluded from git clean -fdx.
type RemoteConfigCache ¶
type RemoteConfigCache struct {
RemoteGitRepo string `yaml:"remote_git_repo"`
RemoteGitFile string `yaml:"remote_git_file"`
RemoteGitRef string `yaml:"remote_git_ref"`
FetchedAt time.Time `yaml:"fetched_at"`
Content string `yaml:"content"`
}
RemoteConfigCache holds cached remote config state
type RetryConfig ¶
type RetryConfig struct {
Attempts int `yaml:"attempts"`
Delay string `yaml:"delay,omitempty"` // e.g. "5s", "10s"
Backoff string `yaml:"backoff,omitempty"` // "none", "linear", "exponential"
}
RetryConfig defines retry behavior for a task
type RetryDefaults ¶
type RetryDefaults struct {
Default RetryConfig `yaml:"default,omitempty"`
}
RetryDefaults holds global retry defaults
type ShellStartupCheck ¶
type ShellStartupCheck struct {
BaseStartupCheck `yaml:",inline"`
Shell string `yaml:"shell"`
Script string `yaml:"script"`
}
ShellStartupCheck runs a shell script
type Sources ¶
type Sources struct {
Gitlab []GitlabSource `yaml:"gitlab,omitempty"`
Github []GithubSource `yaml:"github,omitempty"`
}
Sources defines auto-discovery sources
type StartupCheck ¶
type StartupCheck interface {
GetType() string
GetHint() string
GetNeeds() []string
Check(ctx context.Context, cwd string, stdout, stderr io.Writer) error
}
StartupCheck is the interface for all startup check types
type StartupCheckMap ¶
type StartupCheckMap map[string]StartupCheck
StartupCheckMap is a map of startup checks with custom YAML unmarshaling
func (*StartupCheckMap) UnmarshalYAML ¶
func (cm *StartupCheckMap) UnmarshalYAML(value *yaml.Node) error
type TelemetryConfig ¶
type TelemetryConfig struct {
Endpoint string `yaml:"endpoint,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
}
TelemetryConfig configures OpenTelemetry tracing export. Telemetry is enabled when an endpoint is resolved (from this config or the GITTE_TELEMETRY_URL env var). Headers carries arbitrary export headers, e.g. an Elastic APM secret token as Authorization: "Bearer <token>" or an API key as "ApiKey <key>".
type Template ¶
type Template struct {
Extends []string `yaml:"extends,omitempty"`
Vars map[string]string `yaml:"vars,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
EnvWhen map[string]EnvWhenEntry `yaml:"env_when,omitempty"`
Actions map[string]ProjectAction `yaml:"actions,omitempty"`
}
Template is a reusable project configuration template. Extends lists parent template names (resolved left-to-right, self applied last).
type ToggledProjects ¶
ToggledProjects maps project keys to their explicit enabled/disabled state
type ValidationError ¶
ValidationError represents a single config validation issue
func (ValidationError) Error ¶
func (e ValidationError) Error() string
type ValidationResult ¶
type ValidationResult struct {
Errors []ValidationError
Warnings []ValidationError
}
ValidationResult holds all errors and warnings from validation
func ValidateConfig ¶
func ValidateConfig(cfg *GitteConfig) *ValidationResult
ValidateConfig performs structural validation on the config
func (*ValidationResult) AddError ¶
func (r *ValidationResult) AddError(field, msg string)
func (*ValidationResult) AddWarning ¶
func (r *ValidationResult) AddWarning(field, msg string)
func (*ValidationResult) HasErrors ¶
func (r *ValidationResult) HasErrors() bool
type YamlPathPresentStartupCheck ¶
type YamlPathPresentStartupCheck struct {
BaseStartupCheck `yaml:",inline"`
Path string `yaml:"path"`
File string `yaml:"file"`
}
YamlPathPresentStartupCheck checks that a YAML path exists in a file