config

package
v1.6.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVersion added in v1.3.0

func CheckVersion(cfg *Config, currentVersion string) error

CheckVersion validates if the current version matches the required version in config

func FindConfig

func FindConfig() (string, error)

FindConfig searches for cidx TOML config files in common locations

Types

type Action

type Action struct {
	Description   string            `toml:"description"`
	Image         string            `toml:"image"`
	Command       string            `toml:"command"`
	Entrypoint    []string          `toml:"entrypoint"` // Override container entrypoint
	Workdir       string            `toml:"workdir"`
	Volumes       []string          `toml:"volumes"`
	Env           map[string]string `toml:"env"`
	AutoPush      bool              `toml:"auto_push"`
	PushTags      bool              `toml:"push_tags"`
	WatchWorkflow bool              `toml:"watch_workflow"`
}

Action represents an automated workflow configuration

type BranchConfig

type BranchConfig struct {
	StaleDays     int      `toml:"stale_days"`     // Days before a branch is considered stale (default: 30)
	NamingPattern string   `toml:"naming_pattern"` // Regex pattern for valid branch names
	AutoCleanup   bool     `toml:"auto_cleanup"`   // Cleanup merged branches after PR merge
	Protected     []string `toml:"protected"`      // Branches that should never be deleted
}

BranchConfig defines branch management settings

type Config

type Config struct {
	RequiredVersion string                    // Minimum or exact version required
	Phases          map[string]Phase          // Phases with containers (e.g., security, code, test)
	Pipelines       map[string]Pipeline       // Named pipelines (e.g., ci)
	Actions         map[string]Action         // Named actions (e.g., release-create)
	Branch          BranchConfig              // Branch management settings
	Release         ReleaseConfig             // Release workflow settings
	Tag             TagConfig                 // Tag workflow settings
	PR              PRConfig                  // PR workflow settings
	Provider        ProviderConfig            // Git provider settings
	Overrides       map[string]map[string]any // Container override sections
	Workspace       string                    // Auto-detected or from env
}

Config represents the complete CIDX configuration

func Load

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

Load loads configuration from a TOML file

type ContainerConfig

type ContainerConfig struct {
	Name        string
	Phase       string
	Image       string
	Command     string
	Entrypoint  []string // Override container entrypoint
	Workdir     string
	Volumes     []string
	Env         map[string]string
	ConfigFiles []string
	Privileged  bool   // Requires root privileges
	PullPolicy  string // always, if-not-present, never
	Timeout     string // duration string (e.g., "5m", "45m"), empty = default 30m
}

ContainerConfig represents a fully resolved container configuration after merging preset + overrides

type PRConfig added in v1.3.0

type PRConfig struct {
	// ConfirmMerge shows a confirmation dialog before merging (default: true)
	ConfirmMerge bool `toml:"confirm_merge"`

	// DeleteBranchAfterMerge deletes the feature branch after merge (default: true)
	DeleteBranchAfterMerge bool `toml:"delete_branch_after_merge"`

	// CheckoutAfterMerge switches to main branch after merge (default: true for trunk-based)
	CheckoutAfterMerge bool `toml:"checkout_after_merge"`

	// SyncAfterMerge pulls latest changes after checkout (default: true)
	SyncAfterMerge bool `toml:"sync_after_merge"`

	// WatchPipelineAfterMerge monitors CI pipeline on main after merge (default: true)
	WatchPipelineAfterMerge bool `toml:"watch_pipeline_after_merge"`

	// ConfirmQuitAfterMerge shows a quit confirmation dialog after successful merge (default: true)
	// When false, TUI exits automatically after merge completes
	ConfirmQuitAfterMerge bool `toml:"confirm_quit_after_merge"`

	// DefaultMergeMethod is the default merge method: "squash", "merge", "rebase" (default: "squash")
	DefaultMergeMethod string `toml:"default_merge_method"`

	// AutoRefreshInterval is the interval in seconds for auto-refresh (default: 5, 0 to disable)
	AutoRefreshInterval int `toml:"auto_refresh_interval"`
}

PRConfig defines pull request / merge request workflow settings

func DefaultPRConfig added in v1.3.0

func DefaultPRConfig() PRConfig

DefaultPRConfig returns a PRConfig with sensible defaults for trunk-based development

func (*PRConfig) GetAutoRefreshInterval added in v1.3.0

func (p *PRConfig) GetAutoRefreshInterval() int

GetAutoRefreshInterval returns the auto-refresh interval with fallback to 5 seconds

func (*PRConfig) GetDefaultMergeMethod added in v1.3.0

func (p *PRConfig) GetDefaultMergeMethod() string

GetDefaultMergeMethod returns the default merge method with fallback to "squash"

type Phase

type Phase struct {
	Containers []string `toml:"containers"`
}

Phase defines containers for a specific phase

type Pipeline

type Pipeline struct {
	Phases []string `toml:"phases"`
}

Pipeline defines a sequence of phases to execute

type ProviderConfig added in v1.2.1

type ProviderConfig struct {
	// Type is the provider type: "github", "gitlab", or "" (auto-detect)
	Type string `toml:"type"`
	// URL is the base URL for self-hosted instances (e.g., "https://gitlab.mycompany.com")
	URL string `toml:"url"`
}

ProviderConfig defines git remote provider settings (GitHub, GitLab)

type ReleaseConfig added in v1.2.1

type ReleaseConfig struct {
	// MainBranch is the branch where releases are created (default: "main")
	MainBranch string `toml:"main_branch"`

	// AllowReleaseFromAnyBranch allows creating releases from any branch (default: false)
	// When false, releases can only be created from MainBranch
	AllowReleaseFromAnyBranch bool `toml:"allow_release_from_any_branch"`

	// RequirePrepare requires running 'release prepare' before 'release create' (default: false)
	// When true, releases cannot be created without prepared notes
	RequirePrepare bool `toml:"require_prepare"`

	// AutoCleanup automatically removes .cidx/release-* files after successful release (default: true)
	AutoCleanup bool `toml:"auto_cleanup"`

	// Editor is the command to open release notes for editing (default: $EDITOR or "vim")
	Editor string `toml:"editor"`

	// NotesTemplate is a custom template for release notes (optional)
	NotesTemplate string `toml:"notes_template"`
}

ReleaseConfig defines release workflow settings

func DefaultReleaseConfig added in v1.2.1

func DefaultReleaseConfig() ReleaseConfig

DefaultReleaseConfig returns a ReleaseConfig with sensible defaults

func (*ReleaseConfig) GetEditor added in v1.2.1

func (r *ReleaseConfig) GetEditor() string

GetEditor returns the editor command with fallback to $EDITOR or "vim"

func (*ReleaseConfig) GetMainBranch added in v1.2.1

func (r *ReleaseConfig) GetMainBranch() string

GetMainBranch returns the main branch name with fallback to "main"

type TagConfig added in v1.2.1

type TagConfig struct {
	// Prefix for version tags (default: "v")
	// Examples: "v" → v1.2.3, "" → 1.2.3, "release-" → release-1.2.3
	Prefix string `toml:"prefix"`

	// Pattern is a regex pattern for valid tag names (optional)
	// Default allows semver with optional prefix: ^v?\d+\.\d+\.\d+.*$
	Pattern string `toml:"pattern"`

	// UseCommitizen uses commitizen to determine next version (default: true)
	// When true: runs "cz bump --dry-run" to get suggested version
	// When false: increments patch version from last tag
	UseCommitizen bool `toml:"use_commitizen"`

	// AutoPush automatically pushes tags after creation (default: true)
	AutoPush bool `toml:"auto_push"`

	// SignTags signs tags with GPG (default: false)
	SignTags bool `toml:"sign_tags"`

	// RequireAnnotated requires annotated tags with message (default: true)
	// When true: creates annotated tags with -a -m flags
	// When false: allows lightweight tags
	RequireAnnotated bool `toml:"require_annotated"`

	// ProtectedTags is a list of tag patterns that cannot be deleted
	// Supports glob patterns: ["v1.*", "release-*"]
	ProtectedTags []string `toml:"protected_tags"`

	// LinkedToRelease indicates if tags trigger release workflow (default: true)
	// When true: pushing a tag triggers the release pipeline
	LinkedToRelease bool `toml:"linked_to_release"`
}

TagConfig defines tag workflow settings

func DefaultTagConfig added in v1.2.1

func DefaultTagConfig() TagConfig

DefaultTagConfig returns a TagConfig with sensible defaults

func (*TagConfig) FormatTag added in v1.2.1

func (t *TagConfig) FormatTag(version string) string

FormatTag formats a version with the configured prefix

func (*TagConfig) GetPrefix added in v1.2.1

func (t *TagConfig) GetPrefix() string

GetPrefix returns the tag prefix with default "v"

type ValidationResult

type ValidationResult struct {
	Valid    bool
	Errors   []string
	Warnings []string
}

ValidationResult contains validation results

func Validate

func Validate(cfg *Config) ValidationResult

Validate validates the configuration

Jump to

Keyboard shortcuts

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