config

package
v0.5.1-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: PostgreSQL Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config loads and saves the pgedge CLI configuration at ~/.pgedge/cli/config.yaml with named profiles carrying per-module sections.

Index

Constants

View Source
const AuthBrowser = "browser"

AuthBrowser marks a profile signed in through the browser.

Variables

This section is empty.

Functions

func DefaultCacheDir

func DefaultCacheDir() (string, error)

DefaultCacheDir returns ~/.pgedge/cli/cache, which holds the token cache and selfupdate's sigstore cache. It lives here rather than in internal/auth so the config and cache paths derive from one root.

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns ~/.pgedge/cli/config.yaml. The cli/ segment is deliberate: ~/.pgedge is shared with other pgEdge tools, and a file at its root is a file another tool may want (decided 2026-08-25).

Types

type Config

type Config struct {
	CurrentProfile string             `yaml:"current_profile,omitempty"`
	Profiles       map[string]Profile `yaml:"profiles,omitempty"`
	Output         OutputPrefs        `yaml:"output,omitempty"`
	// contains filtered or unexported fields
}

Config is the root of ~/.pgedge/cli/config.yaml.

func Load

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

Load reads the config file, resolving its path by precedence: the explicit path argument (the --config flag) > DefaultPath.

A missing DEFAULT path is not an error — first run has no config file yet — but a missing EXPLICIT one is. Falling back silently would resolve the built-in default profile, whose api_url is PRODUCTION: failing open in the dangerous direction, indistinguishable from success.

func (*Config) ControlplaneProfile

func (c *Config) ControlplaneProfile(name string) *ControlplaneProfile

ControlplaneProfile returns the controlplane section of the named profile. It never returns nil; absent profiles yield an empty struct.

func (*Config) Path

func (c *Config) Path() string

Path returns the file this config was loaded from — the --config value when one was given, DefaultPath otherwise. A caller reporting on the config reads this rather than re-deriving the default, which under --config names a file the invocation is not reading.

func (*Config) ProfileNames

func (c *Config) ProfileNames() []string

ProfileNames returns the configured profile names, sorted.

func (*Config) ResolveProfile

func (c *Config) ResolveProfile(flag string) string

ResolveProfile returns the active profile name: flag > current_profile > "default".

func (*Config) Save

func (c *Config) Save() error

Save writes the config back to its path with 0600 permissions, creating its directory (~/.pgedge/cli by default) with 0700 if needed.

func (*Config) SavePath

func (c *Config) SavePath() string

SavePath is the file Save writes: Path, else the default. It keys a profile's keychain entry, so login and every later read agree on it. A nil Config answers the default.

func (*Config) SaveTo

func (c *Config) SaveTo(path string) error

SaveTo writes the config to path and remembers path for any later Save call. It is how a test that builds a *Config by hand, rather than through Load, chooses where it lands. It shares writeTo with Save, so the 0700 directory and 0600 file hold through either entry point.

func (*Config) SetControlplaneProfile

func (c *Config) SetControlplaneProfile(name string, cp *ControlplaneProfile)

SetControlplaneProfile stores the controlplane section under the named profile, creating maps as needed.

func (*Config) SetCurrentProfile

func (c *Config) SetCurrentProfile(name string) error

SetCurrentProfile points current_profile at an existing profile. An unknown name is an error rather than a silent write, which would break every subsequent command with a confusing "no credentials" message once current_profile no longer names anything real.

func (*Config) SetStarfleetProfile

func (c *Config) SetStarfleetProfile(name string, cp *StarfleetProfile)

SetStarfleetProfile stores the starfleet section under the named profile, creating maps as needed.

func (*Config) StarfleetProfile

func (c *Config) StarfleetProfile(name string) *StarfleetProfile

StarfleetProfile returns the starfleet section of the named profile. It never returns nil; absent profiles yield an empty struct.

The result is always a fresh copy, so mutating it never persists and SetStarfleetProfile is the only write path. Handing back the live pointer would make mutate-then-Save persist on one path and not on another.

func (*Config) ValidateProfile

func (c *Config) ValidateProfile(name string) error

ValidateProfile reports an error when name is not a key of c.Profiles, and nil when it is. It is the one place the unknown-profile text is written, so every caller emits it byte-identically.

SetCurrentProfile calls this directly; the read side (the profile guard, `profile show`, `profile list`'s resolved column) goes through internal/cli.CheckProfileName, which accepts the built-in "default" first. So `--profile default` and `profile show default` succeed on a config with no `default` section while `profile use default` fails: `use` selects a CONFIGURED profile, and the built-in is the absence of configuration. llms.txt and the pgedge skill both state this exception; it is deliberate.

With no profiles configured, the message names the commands that create one rather than an empty list, and names both because this package cannot tell which applies: a controlplane-only operator has no Starfleet credentials to log in with. Creating the profile they name is also why both carry cli.AnnotationProfileExempt.

type ControlplaneProfile

type ControlplaneProfile struct {
	BaseURL            string   `yaml:"base_url,omitempty"`
	BaseURLs           []string `yaml:"base_urls,omitempty"`
	CACert             string   `yaml:"ca_cert,omitempty"`
	ClientCert         string   `yaml:"client_cert,omitempty"`
	ClientKey          string   `yaml:"client_key,omitempty"`
	InsecureSkipVerify bool     `yaml:"insecure_skip_verify,omitempty"`
	Timeout            string   `yaml:"timeout,omitempty"`
}

ControlplaneProfile holds Control Plane module settings within a profile. The Control Plane has no login/token; connection is a base URL plus optional mTLS cert file paths.

func (*ControlplaneProfile) EffectiveBaseURLs

func (p *ControlplaneProfile) EffectiveBaseURLs() []string

EffectiveBaseURLs returns the candidate Control Plane URLs for the profile: BaseURLs when set, else the legacy singular BaseURL as a one-element list, else nil (the caller applies the default).

type OutputPrefs

type OutputPrefs struct {
	Format string `yaml:"format,omitempty"`
}

OutputPrefs holds user output defaults.

type Profile

type Profile struct {
	Starfleet    *StarfleetProfile    `yaml:"starfleet,omitempty"`
	Controlplane *ControlplaneProfile `yaml:"controlplane,omitempty"`
}

Profile is a named context carrying per-module sections.

type StarfleetProfile

type StarfleetProfile struct {
	APIURL       string `yaml:"api_url,omitempty"`
	ClientID     string `yaml:"client_id,omitempty"`
	ClientSecret string `yaml:"client_secret,omitempty"`
	Auth         string `yaml:"auth,omitempty"`
	// TenantID is the tenant a browser session acts in.
	TenantID string `yaml:"tenant_id,omitempty"`
}

StarfleetProfile holds the Starfleet API connection for a profile. One product means one credential: the account-level commands, byoc and managed all read this section, exactly as they share one token on the wire.

A profile holds one kind of credential: an API client (ClientID and a secret), or a browser session (Auth set to AuthBrowser, with the user's token in the token cache).

func (*StarfleetProfile) IsBrowserSession

func (p *StarfleetProfile) IsBrowserSession() bool

IsBrowserSession reports whether the profile is a browser sign-in.

Jump to

Keyboard shortcuts

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