Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath returns the default config file path. Prefers the XDG-compliant ~/.config/band/config.json, but falls back to the legacy ~/.band/config.json if it exists and the new path doesn't (auto-migration).
Types ¶
type Config ¶
type Config struct {
// Active profile name
ActiveProfile string `json:"active_profile,omitempty"`
// Named profiles (keyed by profile name)
Profiles map[string]*Profile `json:"profiles,omitempty"`
// Global settings
Format string `json:"format,omitempty"`
// Legacy fields — kept for backward compatibility during migration.
// If present and Profiles is empty, auto-migrate to a "default" profile.
ClientID string `json:"client_id,omitempty"`
AccountID string `json:"account_id,omitempty"`
Accounts []string `json:"accounts,omitempty"`
Environment string `json:"environment,omitempty"`
}
Config holds the CLI configuration values persisted to ~/.band/config.json.
func Load ¶
Load reads config from path and returns defaults if the file does not exist. The default format is "json". BW_* env overlays are applied at read time by ActiveProfileConfig, never mutated into stored fields here — otherwise a later Save would persist the session value onto disk.
func (*Config) ActiveProfileConfig ¶
ActiveProfileConfig returns the active profile with BW_* env overlays applied. The returned *Profile is always a fresh copy — mutating it does not affect stored profiles, so writers (Load → Save flows) cannot accidentally leak session env values onto disk.
func (*Config) HasMultipleEnvironments ¶
HasMultipleEnvironments reports whether the configured profiles span more than one distinct environment. This is used to decide whether to surface the active environment in CLI output — a customer with only prod credentials doesn't need to see "Environment: production" on every command.
func (*Config) ProfileNames ¶
ProfileNames returns sorted profile names.
func (*Config) SetProfile ¶
SetProfile stores a profile and sets it as active.
type Profile ¶
type Profile struct {
ClientID string `json:"client_id,omitempty"`
AccountID string `json:"account_id,omitempty"`
Accounts []string `json:"accounts,omitempty"`
Environment string `json:"environment,omitempty"` // prod, test
// Roles lists the JWT-granted role names on this credential. Used to
// gate commands locally and produce capability hints in `auth status`.
Roles []string `json:"roles,omitempty"`
// Build is true when the credential is for a Bandwidth Build account
// (voice-only, credit-based).
Build bool `json:"build,omitempty"`
}
Profile holds credentials and account info for a single set of API credentials.