config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config manages ~/.flexprice/config.toml. It holds no secrets: keys live in the keyring and are referenced by KeyRef.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath is ~/.flexprice/config.toml.

func ProfileName

func ProfileName(label string) string

Punctuation-only or non-ASCII input collapses to "", which falls back to "default" rather than an unusable TOML key.

func Save

func Save(path string, cfg *Config) error

Atomic: encodes to a temp file and renames into place, so a crash mid-write cannot leave a truncated config.

Types

type Config

type Config struct {
	DefaultProfile string             `toml:"default_profile"`
	Profiles       map[string]Profile `toml:"profiles"`
}

func Load

func Load(path string) (*Config, error)

func (*Config) Resolve

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

Resolve returns the named profile, or the default when name is empty.

type Overrides

type Overrides struct {
	Profile string
	APIKey  string
	BaseURL string
	Region  string
	Regions map[string]string
}

Overrides carries per-invocation flags. Regions maps a region key to its base URL and comes from the embedded spec's servers[].

type Profile

type Profile struct {
	Region  string `toml:"region"`
	BaseURL string `toml:"base_url"`
	Label   string `toml:"label"` // free text, set by the user; purely informational
	KeyRef  string `toml:"key_ref"`
}

A key is scoped to one environment, so region, base URL and key move together. No environment name or live flag, since no endpoint reveals it.

type RuntimeContext

type RuntimeContext struct {
	ProfileName string
	Profile     Profile
	APIKey      string
	BaseURL     string
}

RuntimeContext is everything a command needs to build a client.

func ResolveContext

func ResolveContext(cfg *Config, store Store, o Overrides) (RuntimeContext, error)

ResolveContext applies credential precedence: flag, environment variable, keyring, config file. Design doc §6.

type Store

type Store interface {
	Set(profile, key string) error
	Get(profile string) (string, error)
	Delete(profile string) error
	Name() string
}

Store mirrors keyring.Store. It is redeclared here so that config does not import keyring, keeping the dependency one-directional and the tests stubbable.

Jump to

Keyboard shortcuts

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