config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigExists

func ConfigExists(path string) bool

ConfigExists checks if a configuration file exists at the given path

func GetDefaultConfigPath

func GetDefaultConfigPath() (string, error)

GetDefaultConfigPath returns the default configuration file path

func MigrateLegacyConfig added in v1.0.0

func MigrateLegacyConfig(cfg *Config)

MigrateLegacyConfig converts legacy single-instance configuration to new multi-instance format. This function automatically migrates when: - GitLab.Instances is empty (new format not used) - GitLab.Instance is set (legacy format present)

The migration preserves all existing configuration and ensures backward compatibility.

func ValidateInstances added in v1.0.0

func ValidateInstances(cfg *Config) error

ValidateInstances validates the instance configuration. Returns an error if: - Instance names are not unique - Instance URLs are invalid

func WriteConfig

func WriteConfig(path string, cfg *Config) error

WriteConfig writes the configuration to a file with proper permissions It creates the directory if it doesn't exist and uses atomic write for safety

Types

type AuthConfig

type AuthConfig struct {
	Token string `yaml:"token"`
	Netrc bool   `yaml:"netrc"`
}

AuthConfig contains authentication settings

type Config

type Config struct {
	GitLab     GitLabConfig     `yaml:"gitlab"`
	Auth       AuthConfig       `yaml:"auth"`
	Validation ValidationConfig `yaml:"validation"`
	Output     OutputConfig     `yaml:"output"`
	Files      FilesConfig      `yaml:"files"`
}

Config represents the application configuration

func GetDefaults

func GetDefaults() Config

GetDefaults returns the default configuration values

type ConfigFlags

type ConfigFlags struct {
	ConfigFile  string
	Token       string
	Netrc       bool
	Instance    string
	Timeout     string
	Project     string
	SkipAPI     bool
	Strict      bool
	Output      string
	Debug       bool // --debug flag
	Verbosity   int  // -v, -vv count
	Color       string
	Files       []string // From -f flag
	Directories []string // From -d flag
}

ConfigFlags represents CLI flag values

type Duration added in v1.0.0

type Duration struct {
	time.Duration
}

Duration wraps time.Duration to provide custom YAML marshaling

func (Duration) MarshalYAML added in v1.0.0

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML marshals a duration to YAML as a string (e.g., "30s")

func (*Duration) UnmarshalYAML added in v1.0.0

func (d *Duration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML unmarshals a duration from YAML string Supports all time.ParseDuration formats: "300ms", "1.5h", "2h45m", etc.

type FilesConfig added in v0.2.0

type FilesConfig struct {
	SearchParent   bool     `yaml:"search_parent"`
	MaxDepth       int      `yaml:"max_depth"`
	IgnorePatterns []string `yaml:"ignore_patterns"`
}

FilesConfig contains file discovery settings

type GitLabConfig

type GitLabConfig struct {
	// Legacy single-instance support (deprecated but kept for backward compatibility)
	Instance string    `yaml:"instance,omitempty"` // DEPRECATED: Use instances instead
	Timeout  *Duration `yaml:"timeout,omitempty"`

	// Multi-instance support
	Instances []InstanceConfig `yaml:"instances,omitempty"` // List of configured GitLab instances
}

GitLabConfig contains GitLab instance settings

func (*GitLabConfig) FindInstanceByName added in v1.0.0

func (c *GitLabConfig) FindInstanceByName(name string) *InstanceConfig

FindInstanceByName searches for an instance by name. Returns nil if not found.

func (*GitLabConfig) FindInstanceByURL added in v1.0.0

func (c *GitLabConfig) FindInstanceByURL(url string) *InstanceConfig

FindInstanceByURL searches for an instance by normalized URL. Returns nil if not found.

func (*GitLabConfig) GetTimeout added in v1.0.0

func (c *GitLabConfig) GetTimeout() time.Duration

GetTimeout safely returns the timeout duration from GitLabConfig

type InstanceConfig added in v1.0.0

type InstanceConfig struct {
	Name    string    `yaml:"name"`              // Unique identifier (e.g., "gitlab.com", "work")
	URL     string    `yaml:"url"`               // Instance URL (e.g., "https://gitlab.com")
	Token   string    `yaml:"token,omitempty"`   // Personal access token
	Timeout *Duration `yaml:"timeout,omitempty"` // Optional timeout override for this instance
}

InstanceConfig represents a single GitLab instance configuration

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader handles loading configuration from multiple sources with priority

func NewLoader

func NewLoader(flags *ConfigFlags) *Loader

NewLoader creates a new configuration loader

func (*Loader) GetWarnings added in v0.3.2

func (l *Loader) GetWarnings() []string

GetWarnings returns any warnings collected during configuration loading

func (*Loader) Load

func (l *Loader) Load() (*Config, error)

Load loads configuration from all sources and merges them with proper priority Priority (low to high): defaults -> config file -> env vars -> CLI flags

type OutputConfig

type OutputConfig struct {
	Format  string `yaml:"format"` // text, json, yaml
	Verbose bool   `yaml:"verbose"`
	Debug   bool   `yaml:"debug"`
	Color   string `yaml:"color"` // auto, always, never
}

OutputConfig contains output formatting settings

type ValidationConfig

type ValidationConfig struct {
	SkipAPI bool `yaml:"skip_api"`
	Strict  bool `yaml:"strict"`
	// Project is NOT loaded from config file (yaml:"-" prevents marshaling)
	// It can only be set via CLI flag or environment variable (GCL_PROJECT)
	// This allows per-file auto-detection from .git/config
	Project string `yaml:"-"`
}

ValidationConfig contains validation behavior settings

Jump to

Keyboard shortcuts

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