config

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package config manages the CLI's on-disk configuration: named configurations (profiles, like gcloud) plus env-var overrides. It holds only non-secret settings; tokens live in the auth package's credential store (OS keychain).

Index

Constants

View Source
const (
	DefaultEndpoint = "https://api.developer.privasys.org"
	DefaultIssuer   = "https://privasys.id"
	DefaultFormat   = "table"
)

Defaults for a fresh configuration.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir returns the CLI config directory (~/.privasys), creating it if needed.

Types

type Configuration

type Configuration struct {
	Endpoint string `yaml:"endpoint"`
	Issuer   string `yaml:"issuer"`
	Account  string `yaml:"account,omitempty"`
	Format   string `yaml:"format,omitempty"`
}

Configuration is a single named profile.

type File

type File struct {
	Current        string                    `yaml:"current"`
	Configurations map[string]*Configuration `yaml:"configurations"`
	// contains filtered or unexported fields
}

File is the whole config document.

func Load

func Load() (*File, error)

Load reads the config file, returning a default document when none exists.

func (*File) Active

func (f *File) Active() *Configuration

Active returns the current configuration, applying env-var overrides (PRIVASYS_ENDPOINT, PRIVASYS_ISSUER, PRIVASYS_ACCOUNT, PRIVASYS_FORMAT). Env overrides do not mutate the saved file.

func (*File) Get

func (f *File) Get(key string) (string, error)

Get reads a key from the active (env-overridden) configuration.

func (*File) Save

func (f *File) Save() error

Save writes the config file with 0600 permissions.

func (*File) Set

func (f *File) Set(key, value string) error

Set updates a key on the current configuration. Returns the persisted value.

Jump to

Keyboard shortcuts

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