Documentation
¶
Overview ¶
Package config manages the CLI's user-level configuration file.
Config file location follows XDG Base Directory Specification:
- $XDG_CONFIG_HOME/circleci/config.yml (when XDG_CONFIG_HOME is set)
- ~/.config/circleci/config.yml (default)
Index ¶
- Constants
- func ActiveTelemetryOverrides() []string
- func Path() (string, error)
- func SetHost(ctx context.Context, host string) error
- func SetTelemetry(ctx context.Context, enabled bool, path string) error
- func SetTheme(ctx context.Context, theme string) error
- type Config
- type SaveResult
- func DeleteToken(ctx context.Context, secureStorage bool) (SaveResult, error)
- func SetLogin(ctx context.Context, host, token string, userID uuid.UUID, secureStorage bool) (SaveResult, error)
- func SetLogout(ctx context.Context, secureStorage bool) (SaveResult, error)
- func SetToken(ctx context.Context, token string, secureStorage bool) (SaveResult, error)
- type TokenStorage
Constants ¶
const DefaultHost = "https://circleci.com"
DefaultHost is the CircleCI API host used when none is configured.
const DefaultTheme = "auto"
DefaultTheme is the color theme used when none is configured. It matches the default of the --theme flag and detects the terminal background.
Variables ¶
This section is empty.
Functions ¶
func ActiveTelemetryOverrides ¶
func ActiveTelemetryOverrides() []string
ActiveTelemetryOverrides returns the names of environment variables that are currently set and override the stored telemetry preference.
func SetHost ¶
SetHost persists the CircleCI server host. The host is not a secret, so it is always written to the config file and never touches secure storage (passing secureStorage here would make saveTo delete the keyring token).
func SetTelemetry ¶
SetTelemetry persists the telemetry opt-in/opt-out preference. path follows the same convention as Load (empty → XDG default).
func SetTheme ¶
SetTheme persists the color theme preference. The theme is not a secret, so it is always written to the config file and never touches secure storage (passing secureStorage here would make saveTo delete the keyring token). Validation of the value is the caller's responsibility (see iostream.IsValidTheme).
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds all persisted CLI settings.
func Load ¶
Load reads the config file from the given path. If path is empty the default XDG path is used. Returns an empty Config if the file does not exist.
func (*Config) EffectiveHost ¶
EffectiveHost returns the host, checked in priority order: CIRCLE_HOST env var → config file value → DefaultHost.
func (*Config) EffectiveTheme ¶
EffectiveTheme returns the configured color theme, or DefaultTheme when none has been set.
func (*Config) EffectiveToken ¶
EffectiveToken returns the token from the config, falling back to the CIRCLE_TOKEN environment variable (with CIRCLE_CLI_TOKEN as a legacy alias).
func (*Config) IsTelemetry ¶
IsTelemetry returns true when telemetry should be collected. Environment variables always take precedence over the stored config value. When no preference has been set, telemetry is enabled by default.
type SaveResult ¶
type SaveResult struct {
// Storage is where the token actually landed.
Storage TokenStorage
// KeyringErr is non-nil when secure storage was requested but the OS keyring
// could not be used, so the token transparently fell back to the config
// file. It wraps keyring.ErrUnavailable (and may be keyring.ErrAccessDenied
// for a denial the user can fix, such as an unconnected snap interface).
// This is NOT a fatal error — callers may inspect it to surface guidance.
KeyringErr error
}
SaveResult reports the outcome of a token-mutating call.
func DeleteToken ¶
func DeleteToken(ctx context.Context, secureStorage bool) (SaveResult, error)
DeleteToken removes the stored API token from both the config file and the system keyring (when secure storage is in use).
type TokenStorage ¶
type TokenStorage int
TokenStorage reports where a token-mutating call actually persisted (or removed from) the token, so callers can print an accurate location. When secure storage is requested but the OS keyring is unavailable, the call transparently falls back to the config file and reports StoredInFile.
const ( // StoredInFile means the token was written to (or cleared from) the // plaintext config file — either because --insecure-storage was set, or // because secure storage was requested but the keyring was unavailable. StoredInFile TokenStorage = iota // StoredInKeyring means the token was written to (or removed from) the OS // keyring. StoredInKeyring )