Documentation
¶
Overview ¶
Package config is a helper package to facilitate getting and setting config values using Viper.
This package provides functions to read and write configuration settings for the eng CLI tool. It supports various configuration file formats and allows for easy management of local configuration settings.
Key features: - Load configuration from JSON, YAML, TOML, and other formats. - Set and get configuration values programmatically. - Support for environment variable overrides. - Easy integration with the Viper library.
These are local configs related to the eng CLI, not deployment configs.
Index ¶
- Constants
- Variables
- func AddComposeStack(entry ComposeStackEntry) error
- func AddProject(project Project) error
- func AddRepoToProject(projectName string, repo ProjectRepo) error
- func BackupFile(path string) (string, error)
- func BareRepoPath() string
- func Branch() string
- func DefaultConfigPath() string
- func DisableAllProxies() error
- func DotfilesRepo() string
- func Email() string
- func EnsureProfileID() string
- func ExplicitTargetRepoPath() string
- func FindProxyIndexByTitle(proxies []ProxyConfig, title string) int
- func FindUnknownKeys(configFile string) []string
- func FormatProxyOption(proxy ProxyConfig) string
- func GenerateUUIDv4() string
- func GetActiveProxy() (string, bool)
- func GetDotfilesRepo()
- func GetEmail()
- func GetProjectNames() []string
- func GitDevPath() string
- func GitEditor(optionalEditor ...string) string
- func IdeURL(optionalURL ...string) string
- func IsGitRepo(path string) bool
- func IsTelemetryConfigured() bool
- func IsTelemetryEnabled() bool
- func IsVerbose() bool
- func MigrateConfig()
- func MigrateFile(path string) (backup string, changed bool, err error)
- func MigrateMap(in map[string]any) (map[string]any, bool, error)
- func MigratePlaintextToken(provider SecretProvider, item string) error
- func NewLoader(configFile string) *viper.Viper
- func NormalizeProxyURLString(value string) string
- func PromptComposeStackValuesImpl(initialName, initialPath string) (name, path string, err error)
- func PromptProxyValuesImpl(initialTitle, initialValue, initialNoProxy string) (title, value, noProxy string, err error)
- func RemoveComposeStack(name string) error
- func RemoveProject(projectName string) error
- func RemoveRepoFromProject(projectName, repoURL string) error
- func RepoURL() string
- func ResolveConfigPath(explicit string) string
- func ResolveGitLabToken() (token, source string, err error)
- func ResolveSecret(ref SecretRef) (string, error)
- func RunInteractiveEditor() error
- func RunWizard(defaults WizardAnswers, from WizardStep) (map[string]any, error)
- func SaveComposeStacks(stacks []ComposeStackEntry) error
- func SaveProjects(projects []Project) error
- func SaveProxyConfigsImpl(proxies []ProxyConfig) error
- func SelectComposeStack(stacks []ComposeStackEntry) (int, error)
- func SelectProxy(proxies []ProxyConfig) (int, error)
- func SetGitEditor(command string)
- func SetIdeURL(url string)
- func SetProxyEnvVars(proxy ProxyConfig)
- func SetTargetRepoPath(path string) error
- func SetTelemetryEnabled(enabled bool) error
- func ShouldAutoOnboard(args []string, stdinTTY, stdoutTTY, fileCreated bool) bool
- func TargetRepoCandidates(devPath string) []string
- func TargetRepoPath(devPath string) string
- func Telemetry() bool
- func TestProxyConnection(proxyURLStr, targetURLStr string) (time.Duration, error)
- func UnsetProxyEnvVars()
- func UpdateBareRepoPath()
- func UpdateBranch()
- func UpdateDotfilesRepo()
- func UpdateGitEditor() string
- func UpdateRepoURL()
- func UpdateWorktreePath()
- func ValidateComposeStackName(name string) error
- func ValidateProxyURLString(value string) error
- func Verbose() bool
- func VerifyDotfilesConfig() (string, string, string, string, error)
- func WorktreePath() string
- func XDGConfigPath() string
- type AntigravityConfig
- type ComposeStackEntry
- type ContainersConfig
- type DotfilesConfig
- type FieldError
- type GitConfig
- type Project
- type ProjectRepo
- type PromptComposeStackValuesFunc
- type PromptProxyValuesFunc
- type ProxyConfig
- func AddOrUpdateProxy() ([]ProxyConfig, int)
- func AddOrUpdateProxyWithValues(title, value, noProxy string) ([]ProxyConfig, int, error)
- func EnableProxy(index int, proxies []ProxyConfig) ([]ProxyConfig, error)
- func GetProxyConfigs() ([]ProxyConfig, int)
- func RemoveProxy(index int) ([]ProxyConfig, error)
- type ResolvedConfig
- type SaveProxyConfigsFunc
- type SecretProvider
- type SecretRef
- type TelemetryConfig
- type WizardAnswers
- type WizardStep
Constants ¶
const CurrentVersion = 2
CurrentVersion is the latest config schema version stored as the top-level `version` key. Files without a version are treated as v0.
const EnvPrefix = "ENG"
EnvPrefix is the environment variable prefix for config overrides. Dots in keys map to underscores: ENG_GIT_DEV_PATH overrides git.dev_path.
const KeychainService = "eng"
KeychainService is the OS keychain service name for eng secrets.
Variables ¶
var ( // ConfirmPrompt asks a yes/no question. ConfirmPrompt = confirmUnwired // InputPrompt asks for a line of text. InputPrompt = inputUnwired // SelectPrompt asks to pick one option. SelectPrompt = selectUnwired // MultiSelectPrompt asks to pick any number of options. MultiSelectPrompt = multiSelectUnwired )
Interactive prompt hooks consumed by this package.
config must never import presentation packages (internal/ui), so all user prompting goes through these variables. The command layer wires the real implementations at startup (see cmd/config/prompts.go); tests override them per-case. Defaults fail loudly so an unwired composition surfaces immediately instead of hanging on stdin.
var ( // DefaultAPIURL is the default OpenPanel API endpoint URL (overridable at build time via ldflags). DefaultAPIURL = "https://openpanel.gventureshq.com/api" // DefaultClientID is the default OpenPanel client ID (injected at build time via ldflags). DefaultClientID = "" // DefaultClientSecret is the default OpenPanel client secret (injected at build time via ldflags). DefaultClientSecret = "" )
var PromptComposeStackValues = PromptComposeStackValuesImpl
PromptComposeStackValues prompts for stack values; override in tests.
var PromptProxyValues = PromptProxyValuesImpl
PromptProxyValues is a variable that holds the function to prompt for proxy values. This can be overridden in tests.
var SaveProxyConfigs = SaveProxyConfigsImpl
SaveProxyConfigs is a variable that holds the function to save proxy configurations This can be overridden in tests.
Functions ¶
func AddComposeStack ¶ added in v1.62.0
func AddComposeStack(entry ComposeStackEntry) error
AddComposeStack adds a new named stack or updates the path of an existing one (case-insensitive match). Path is stored as given; expansion happens on read.
func AddProject ¶
AddProject adds a new project or updates an existing one. If a project with the same name exists, it updates it; otherwise, it appends.
func AddRepoToProject ¶
func AddRepoToProject(projectName string, repo ProjectRepo) error
AddRepoToProject adds a repository to an existing project. Returns an error if the project doesn't exist.
func BackupFile ¶ added in v1.59.0
BackupFile copies path to path.bak.<UTC timestamp> and returns the backup path.
func BareRepoPath ¶
func BareRepoPath() string
BareRepoPath checks for the bare repository path in the configuration and returns it.
func Branch ¶
func Branch() string
Branch checks for the dotfiles branch in the configuration and returns it.
func DefaultConfigPath ¶ added in v1.59.0
func DefaultConfigPath() string
DefaultConfigPath returns the primary config file path ($HOME/.eng.yaml).
func DisableAllProxies ¶
func DisableAllProxies() error
DisableAllProxies disables all proxy configurations and unsets environment variables.
func DotfilesRepo ¶
func DotfilesRepo() string
DotfilesRepo is an alias for BareRepoPath for backward compatibility with external callers.
func Email ¶
func Email() string
Email checks for the user's email in the configuration and prompts the user to confirm it. If the email is not found or the user does not confirm it, the function will call updateEmail() to update the email. It logs the start and success of the email checking process and returns the confirmed email as a string.
func EnsureProfileID ¶ added in v1.48.0
func EnsureProfileID() string
EnsureProfileID returns the configured anonymous Profile ID, or generates and saves a new one.
func ExplicitTargetRepoPath ¶ added in v1.53.0
func ExplicitTargetRepoPath() string
ExplicitTargetRepoPath returns the configured override, if any. Two keys are honored for backward compatibility; target_repo_path wins.
func FindProxyIndexByTitle ¶
func FindProxyIndexByTitle(proxies []ProxyConfig, title string) int
FindProxyIndexByTitle returns the index of the proxy matching the title (case-insensitive), or -1.
func FindUnknownKeys ¶ added in v1.60.1
FindUnknownKeys returns sorted top-level keys in the config file that are not part of the known schema. These are safe to drop with `config unset` after confirming no local tooling depends on them.
func FormatProxyOption ¶
func FormatProxyOption(proxy ProxyConfig) string
FormatProxyOption renders a single proxy as a plain option string for selection prompts and status tables. It intentionally contains no ANSI styling so callers can compare options with == and apply the shared huh/lipgloss theme at render time. Example: "★ Corp (http://proxy:8080) [ACTIVE]".
func GenerateUUIDv4 ¶ added in v1.48.0
func GenerateUUIDv4() string
GenerateUUIDv4 generates a cryptographically secure RFC 4122 version 4 UUID.
func GetActiveProxy ¶
GetActiveProxy returns the currently active proxy value and true if any proxy is enabled If no proxy is enabled, returns the first proxy value and false If no proxies exist, returns an empty string and false.
func GetDotfilesRepo ¶
func GetDotfilesRepo()
GetDotfilesRepo logs the current dotfiles repository path.
func GetEmail ¶
func GetEmail()
GetEmail retrieves the user's email from the configuration. If the email is not found in the configuration, it prompts the user to update it. Logs the process of checking and finding the email.
func GetProjectNames ¶
func GetProjectNames() []string
GetProjectNames returns a list of all configured project names.
func GitDevPath ¶
func GitDevPath() string
GitDevPath checks for the development folder path in the configuration and prompts the user to confirm it. If the path is not found or the user does not confirm it, the function will call updateGitDevPath() to update the path. It logs the start and success of the path checking process and returns the confirmed path as a string.
func GitEditor ¶ added in v1.57.0
GitEditor checks the default editor configuration and prompts to set it. An optional argument sets the value directly without prompting.
func IdeURL ¶ added in v1.40.0
IdeURL checks for the Antigravity IDE download URL in the configuration and prompts the user to confirm or set it. If an optionalURL argument is passed, it sets the URL directly.
func IsTelemetryConfigured ¶ added in v1.48.0
func IsTelemetryConfigured() bool
IsTelemetryConfigured returns true if ClientID and ClientSecret are populated.
func IsTelemetryEnabled ¶ added in v1.48.0
func IsTelemetryEnabled() bool
IsTelemetryEnabled checks if telemetry is enabled, honoring environment variables (DO_NOT_TRACK, ENG_TELEMETRY_DISABLED, ENG_TELEMETRY_ENABLED) and config settings.
func IsVerbose ¶ added in v1.15.0
func IsVerbose() bool
IsVerbose returns whether verbose mode is enabled globally via config or environment.
func MigrateConfig ¶
func MigrateConfig()
MigrateConfig handles the migration of old configuration keys to new standardized ones. It checks for old keys, moves their values to new keys if the new ones are empty, and saves the configuration if any changes were made.
func MigrateFile ¶ added in v1.59.0
MigrateFile loads a YAML config file, migrates it to the current schema, writes a timestamped backup when changes are needed, and rewrites the file. It is idempotent: a second run reports changed=false.
func MigrateMap ¶ added in v1.59.0
MigrateMap migrates a decoded config map to the current schema version. It renames legacy keys (deleting the old key only when the new key is empty), ensures `projects` exists, and stamps the current version. It returns the migrated map and whether anything changed.
func MigratePlaintextToken ¶ added in v1.59.0
func MigratePlaintextToken(provider SecretProvider, item string) error
MigratePlaintextToken moves gitlab.token from plaintext config into the given store, clears the plaintext key, and records the reference. Bitwarden stores under item and sets gitlab.token_item; keychain stores under account and sets gitlab.keychain_account.
func NewLoader ¶ added in v1.59.0
NewLoader returns an isolated viper instance with defaults, ENG_ env bindings, and the given config file preselected. It never touches the global viper singleton, so tests can load configs in parallel.
func NormalizeProxyURLString ¶
NormalizeProxyURLString adds a default http scheme when missing.
func PromptComposeStackValuesImpl ¶ added in v1.62.0
PromptComposeStackValuesImpl uses huh.NewForm to collect stack details interactively.
func PromptProxyValuesImpl ¶ added in v1.15.0
func PromptProxyValuesImpl( initialTitle, initialValue, initialNoProxy string, ) (title, value, noProxy string, err error)
PromptProxyValuesImpl uses huh.NewForm to collect proxy details interactively.
func RemoveComposeStack ¶ added in v1.62.0
RemoveComposeStack removes a registered stack by name (case-insensitive).
func RemoveProject ¶
RemoveProject removes a project from the configuration.
func RemoveRepoFromProject ¶
RemoveRepoFromProject removes a repository from a project.
func RepoURL ¶
func RepoURL() string
RepoURL checks for the dotfiles repository URL in the configuration and returns it.
func ResolveConfigPath ¶ added in v1.59.0
ResolveConfigPath returns the config file to use: explicit flag path, then XDG fallback if it exists, else the default home path.
func ResolveGitLabToken ¶ added in v1.59.0
ResolveGitLabToken resolves the GitLab token with precedence: env GITLAB_TOKEN, bitwarden item, keychain account, legacy plaintext gitlab.token (returned with a migration warning source).
func ResolveSecret ¶ added in v1.59.0
ResolveSecret returns the secret value for ref.
func RunInteractiveEditor ¶ added in v1.16.0
func RunInteractiveEditor() error
RunInteractiveEditor launches a TUI to edit the CLI's configuration.
func RunWizard ¶ added in v1.59.0
func RunWizard(defaults WizardAnswers, from WizardStep) (map[string]any, error)
RunWizard walks the prompt hooks from the given step and returns the planned key/value changes. It never writes; callers validate the result and persist once via ApplyWizardChanges.
func SaveComposeStacks ¶ added in v1.62.0
func SaveComposeStacks(stacks []ComposeStackEntry) error
SaveComposeStacks persists the registered compose stacks to the config file.
func SaveProjects ¶
SaveProjects persists the list of projects to the config file.
func SaveProxyConfigsImpl ¶
func SaveProxyConfigsImpl(proxies []ProxyConfig) error
SaveProxyConfigsImpl is the actual implementation of saving proxy configurations to viper config.
func SelectComposeStack ¶ added in v1.62.0
func SelectComposeStack(stacks []ComposeStackEntry) (int, error)
SelectComposeStack prompts to pick one registered stack and returns its index.
func SelectProxy ¶
func SelectProxy(proxies []ProxyConfig) (int, error)
SelectProxy prompts the user to select a proxy from the list and returns the index.
func SetGitEditor ¶ added in v1.57.0
func SetGitEditor(command string)
SetGitEditor persists the default editor command in viper and writes to config.
func SetIdeURL ¶ added in v1.40.0
func SetIdeURL(url string)
SetIdeURL updates the antigravity.ide_download_url setting in viper and writes to config.
func SetProxyEnvVars ¶
func SetProxyEnvVars(proxy ProxyConfig)
SetProxyEnvVars sets all proxy-related environment variables from the given proxy, including its custom NoProxy hosts.
func SetTargetRepoPath ¶ added in v1.53.0
SetTargetRepoPath validates and persists an explicit target repository path. The path must exist; a missing .git directory warns but still saves, since the copy flow re-validates at use time with an interactive fallback.
func SetTelemetryEnabled ¶ added in v1.48.0
SetTelemetryEnabled updates the enabled state of telemetry in the config file.
func ShouldAutoOnboard ¶ added in v1.52.0
ShouldAutoOnboard decides whether to offer the first-run setup wizard. fileCreated reports whether initConfig just created a fresh config file (true first run). stdinTTY/stdoutTTY are injected for testability; callers probe the real descriptors (e.g. via ui.IsTerminal).
The prompt fires at most once per machine — only on true first run — and never for meta/config commands, non-terminals (scripts, CI, pipes), or when ENG_NO_ONBOARDING is set. Later runs with missing settings rely on actionable command errors pointing at `eng config edit --interactive`.
func TargetRepoCandidates ¶ added in v1.53.0
TargetRepoCandidates lists every on-disk location under devPath that could host the dotfiles git repository, in priority order (project config match, project subdirectory scan, legacy path, deep walk). Used for interactive selection when the automatic resolution fails.
func TargetRepoPath ¶ added in v1.38.0
TargetRepoPath resolves the destination git repository path for copying dotfile changes. It checks explicit config first, then the candidate search, then project configuration (even when not yet on disk), and finally falls back to the legacy path under devPath (which may not exist — callers must verify).
func Telemetry ¶ added in v1.48.0
func Telemetry() bool
Telemetry prompts the user to verify or update their telemetry preferences.
func TestProxyConnection ¶ added in v1.29.0
TestProxyConnection tests HTTP connectivity using the specified proxy URL.
func UnsetProxyEnvVars ¶
func UnsetProxyEnvVars()
UnsetProxyEnvVars unsets all proxy-related environment variables.
func UpdateBareRepoPath ¶
func UpdateBareRepoPath()
UpdateBareRepoPath prompts the user to input their bare repository path.
func UpdateBranch ¶
func UpdateBranch()
UpdateBranch prompts the user to select their dotfiles branch.
func UpdateDotfilesRepo ¶
func UpdateDotfilesRepo()
UpdateDotfilesRepo is an alias for UpdateBareRepoPath.
func UpdateGitEditor ¶ added in v1.57.0
func UpdateGitEditor() string
UpdateGitEditor prompts to pick from PATH-detected editors and persists the choice.
func UpdateRepoURL ¶
func UpdateRepoURL()
UpdateRepoURL prompts the user to input their dotfiles repository URL.
func UpdateWorktreePath ¶
func UpdateWorktreePath()
UpdateWorktreePath prompts the user to input their worktree path.
func ValidateComposeStackName ¶ added in v1.62.0
ValidateComposeStackName reports whether name is usable as a stack name.
func ValidateProxyURLString ¶
validateTitle ensures the title is non-empty after trimming.
func Verbose ¶
func Verbose() bool
Verbose checks for the verbose setting in the configuration and prompts the user to confirm it. If the verbose setting is not found or the user does not confirm it, the function will call updateVerbose() to update the setting. It logs the start and success of the verbose checking process and returns the confirmed verbose setting as a bool.
func VerifyDotfilesConfig ¶
VerifyDotfilesConfig checks for Repo URL, Branch, and Bare Repo Path. If all are present, it offers a single multi-select to update them. If any are missing, it falls back to sequential mandatory prompts.
func WorktreePath ¶
func WorktreePath() string
WorktreePath checks for the worktree path in the configuration and returns it.
func XDGConfigPath ¶ added in v1.59.0
func XDGConfigPath() string
XDGConfigPath returns the XDG fallback path, or "" when XDG_CONFIG_HOME is unset.
Types ¶
type AntigravityConfig ¶ added in v1.40.0
type AntigravityConfig struct {
IdeDownloadURL string `mapstructure:"ide_download_url"`
}
AntigravityConfig holds Antigravity-related configuration.
func GetAntigravityConfig ¶ added in v1.40.0
func GetAntigravityConfig() AntigravityConfig
GetAntigravityConfig retrieves the Antigravity configuration from Viper.
type ComposeStackEntry ¶ added in v1.62.0
type ComposeStackEntry struct {
Name string `mapstructure:"name" yaml:"name"`
Path string `mapstructure:"path" yaml:"path"`
}
ComposeStackEntry is a user-registered named compose stack pointing at an arbitrary local root path. The compose file itself is autodetected inside Path at discovery time (docker-compose.yml/yaml, compose.yml/yaml).
func ExpandedComposeStacks ¶ added in v1.62.0
func ExpandedComposeStacks() []ComposeStackEntry
ExpandedComposeStacks returns registered stacks with paths expanded.
func GetComposeStacks ¶ added in v1.62.0
func GetComposeStacks() []ComposeStackEntry
GetComposeStacks retrieves the registered compose stacks from the config file.
type ContainersConfig ¶ added in v1.25.0
type ContainersConfig struct {
Path string `mapstructure:"path"`
// Stacks is the list of user-registered named compose stacks, each
// pointing at an arbitrary local root path containing a compose file.
Stacks []ComposeStackEntry `mapstructure:"stacks"`
}
ContainersConfig holds container-related configuration.
func GetContainersConfig ¶ added in v1.25.0
func GetContainersConfig() ContainersConfig
GetContainersConfig retrieves the containers configuration from Viper.
type DotfilesConfig ¶ added in v1.15.0
type DotfilesConfig struct {
RepoURL string `mapstructure:"repo_url"`
Branch string `mapstructure:"branch"`
BareRepoPath string `mapstructure:"bare_repo_path"`
WorktreePath string `mapstructure:"worktree_path"`
TargetRepoPath string `mapstructure:"target_repo_path"`
}
DotfilesConfig holds all dotfiles-related configuration.
func GetDotfilesConfig ¶ added in v1.15.0
func GetDotfilesConfig() DotfilesConfig
GetDotfilesConfig retrieves the dotfiles configuration from Viper.
type FieldError ¶ added in v1.59.0
FieldError describes one invalid config field with a fix hint.
func PlaintextSecretWarning ¶ added in v1.59.0
func PlaintextSecretWarning() *FieldError
PlaintextSecretWarning reports whether gitlab.token is stored in plaintext.
func (FieldError) Error ¶ added in v1.59.0
func (e FieldError) Error() string
type GitConfig ¶ added in v1.15.0
type GitConfig struct {
DevPath string `mapstructure:"dev_path"`
Editor string `mapstructure:"editor"`
}
GitConfig holds all git-related configuration.
func GetGitConfig ¶ added in v1.15.0
func GetGitConfig() GitConfig
GetGitConfig retrieves the git configuration from Viper.
type Project ¶
type Project struct {
Name string `mapstructure:"name"`
Repos []ProjectRepo `mapstructure:"repos"`
}
Project represents a collection of related repositories.
func GetProjectByName ¶
GetProjectByName retrieves a specific project by name. Returns nil if not found.
func GetProjects ¶
func GetProjects() []Project
GetProjects retrieves the list of configured projects from the config file.
type ProjectRepo ¶
type ProjectRepo struct {
URL string `mapstructure:"url"`
Path string `mapstructure:"path,omitempty"` // Optional, defaults to repo name from URL
}
ProjectRepo represents a single repository within a project.
func (*ProjectRepo) GetEffectivePath ¶
func (r *ProjectRepo) GetEffectivePath() (string, error)
GetEffectivePath returns the effective path for a git. If Path is set, it uses that; otherwise, it derives from the URL.
type PromptComposeStackValuesFunc ¶ added in v1.62.0
type PromptComposeStackValuesFunc func(initialName, initialPath string) (name, path string, err error)
PromptComposeStackValuesFunc collects a stack name and root path interactively.
type PromptProxyValuesFunc ¶ added in v1.15.0
type PromptProxyValuesFunc func(initialTitle, initialValue, initialNoProxy string) (title, value, noProxy string, err error)
ProxyConfig represents a single proxy configuration.
type ProxyConfig ¶
ProxyConfig represents a single proxy configuration.
func AddOrUpdateProxy ¶
func AddOrUpdateProxy() ([]ProxyConfig, int)
ProxyConfig represents a single proxy configuration.
func AddOrUpdateProxyWithValues ¶
func AddOrUpdateProxyWithValues(title, value, noProxy string) ([]ProxyConfig, int, error)
AddOrUpdateProxyWithValues adds or updates a proxy using provided values (non-interactive). Returns updated proxies, the affected index, or an error.
func EnableProxy ¶
func EnableProxy(index int, proxies []ProxyConfig) ([]ProxyConfig, error)
ProxyConfig represents a single proxy configuration. EnableProxy enables the proxy at index. It operates on a copy of proxies and returns the updated slice; the caller's slice is never mutated.
func GetProxyConfigs ¶
func GetProxyConfigs() ([]ProxyConfig, int)
GetProxyConfigs reads proxy settings and returns the current proxies and the index of the active proxy (-1 if none are active). It is a pure read: it never writes the config file. Legacy singular `proxy:` configs are converted in memory with a warning pointing at `eng config migrate`, which owns persistent migration.
func RemoveProxy ¶ added in v1.29.0
func RemoveProxy(index int) ([]ProxyConfig, error)
RemoveProxy removes the proxy configuration at the specified index.
type ResolvedConfig ¶ added in v1.59.0
type ResolvedConfig struct {
Version int
Email string
Verbose bool
GitDevPath string
GitEditor string
DotfilesRepo string
DotfilesBranch string
ContainersPath string
ContainersStacks []ComposeStackEntry
Proxies []ProxyConfig
Source map[string]string
}
ResolvedConfig is the fully-loaded, expanded, validated view of configuration.
func LoadResolved ¶ added in v1.59.0
func LoadResolved(v *viper.Viper) (*ResolvedConfig, error)
LoadResolved reads the config file (if present), unmarshals exactly into known keys, expands all paths once, and records the value source per key.
func (*ResolvedConfig) Validate ¶ added in v1.59.0
func (c *ResolvedConfig) Validate() []FieldError
Validate checks a ResolvedConfig and returns one FieldError per problem. Empty email/repo URL are allowed (prompt-on-empty covers first run); malformed values are reported with actionable hints.
type SaveProxyConfigsFunc ¶
type SaveProxyConfigsFunc func(proxies []ProxyConfig) error
SaveProxyConfigsFunc defines the function type for saving proxy configs.
type SecretProvider ¶ added in v1.59.0
type SecretProvider string
Secret providers supported for token storage and lookup.
const ( ProviderEnv SecretProvider = "env" ProviderBitwarden SecretProvider = "bitwarden" ProviderKeychain SecretProvider = "keychain" ProviderConfig SecretProvider = "config" )
type SecretRef ¶ added in v1.59.0
type SecretRef struct {
Provider SecretProvider
// Item names the vault item (bitwarden) or account (keychain).
Item string
// Field selects a custom field; empty means login password (bitwarden).
Field string
// EnvVar names the environment variable (env provider).
EnvVar string
}
SecretRef points at one secret value.
func GitLabTokenRef ¶ added in v1.59.0
GitLabTokenRef builds the token lookup for GitLab: explicit env first, then the configured bitwarden item (new token_item key, legacy tokenItem), then the keychain account, never plaintext.
type TelemetryConfig ¶ added in v1.48.0
type TelemetryConfig struct {
Enabled bool `mapstructure:"enabled"`
APIURL string `mapstructure:"-"`
ClientID string `mapstructure:"-"`
ClientSecret string `mapstructure:"-"`
ProfileID string `mapstructure:"profile_id"`
}
TelemetryConfig holds all telemetry and analytics related configuration.
func GetEffectiveTelemetryConfig ¶ added in v1.48.0
func GetEffectiveTelemetryConfig() TelemetryConfig
GetEffectiveTelemetryConfig returns the active telemetry configuration. Telemetry endpoint and credentials are built-in and fixed to the project servers.
func GetTelemetryConfig ¶ added in v1.48.0
func GetTelemetryConfig() TelemetryConfig
GetTelemetryConfig retrieves the telemetry configuration from Viper.
type WizardAnswers ¶ added in v1.59.0
type WizardAnswers struct {
Email string
GitDevPath string
GitEditor string
Verbose bool
DotfilesRepoURL string
DotfilesBranch string
SkipDotfiles bool
ProxyAddress string
ProxyNoProxy string
SkipProxy bool
TelemetryEnabled bool
}
WizardAnswers holds one walkthrough run. Defaults are preloaded from the current resolved config; empty means "leave unset".
func DefaultsFromResolved ¶ added in v1.59.0
func DefaultsFromResolved(rc *ResolvedConfig) WizardAnswers
DefaultsFromResolved preloads wizard defaults from the current config.
type WizardStep ¶ added in v1.59.0
type WizardStep string
WizardStep is one resumable section of the init walkthrough.
const ( WizardProfile WizardStep = "profile" WizardGit WizardStep = "git" WizardDotfiles WizardStep = "dotfiles" WizardProxy WizardStep = "proxy" WizardTelemetry WizardStep = "telemetry" )
func ParseWizardStep ¶ added in v1.59.0
func ParseWizardStep(s string) (WizardStep, error)
ParseWizardStep parses --from into a WizardStep.