config

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBaseURL = "https://api.bron.org"

Variables

This section is empty.

Functions

func CaptureAPIKeyFromEnv added in v0.3.8

func CaptureAPIKeyFromEnv()

CaptureAPIKeyFromEnv reads BRON_API_KEY once at process start and unsets it from the OS env. Idempotent — only the first call captures; later calls are no-ops. Must be invoked from main() before cobra dispatch and before any code path that could spawn a subprocess.

func Path

func Path() (string, error)

Types

type Config

type Config struct {
	ActiveProfile string             `yaml:"active_profile"`
	Profiles      map[string]Profile `yaml:"profiles"`
	// contains filtered or unexported fields
}

func Load

func Load() (*Config, error)

func (*Config) FilePath

func (c *Config) FilePath() string

FilePath returns the resolved on-disk location of this config.

func (*Config) Resolve

func (c *Config) Resolve(name string) (*Profile, error)

Resolve returns the profile to use, applying env overrides on top of YAML. Precedence (highest first): explicit name → BRON_PROFILE → ActiveProfile → "default". Env vars BRON_WORKSPACE_ID, BRON_BASE_URL, BRON_API_KEY, BRON_API_KEY_FILE, BRON_PROXY override individual fields. BRON_API_KEY (raw JWK bytes) wins over BRON_API_KEY_FILE / key_file when both are set — it's the path used by secret-store wrappers like `op run -- bron …` that inject the key as env.

func (*Config) Save

func (c *Config) Save() error

Save writes the config back to disk, creating parent directories as needed. File mode is 0600 — it may contain workspace IDs and key-file paths.

type Profile

type Profile struct {
	Workspace string `yaml:"workspace,omitempty"`
	BaseURL   string `yaml:"base_url,omitempty"`
	KeyFile   string `yaml:"key_file,omitempty"`
	Proxy     string `yaml:"proxy,omitempty"`

	// APIKey is set transiently from $BRON_API_KEY in Resolve(). Never read
	// from or written to YAML — keeps the JWK out of on-disk config so secret
	// stores (1Password, Vault, sops) can pipe it via env without leaving a
	// file on disk. Takes precedence over KeyFile when both are present.
	APIKey string `yaml:"-"`
}

func (*Profile) LoadKey added in v0.3.7

func (p *Profile) LoadKey() ([]byte, error)

LoadKey returns the raw JWK bytes for the profile. Source precedence:

  1. APIKey (set from $BRON_API_KEY) — used as-is, no disk access.
  2. KeyFile — read from disk after the standard 0600 permission check.

Trailing whitespace is preserved; callers TrimSpace before handing the value to the SDK so a stray newline from `op read > file` doesn't corrupt the JWK parse.

Jump to

Keyboard shortcuts

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