config

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 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 the shared Python/Go CLI configuration.

Index

Constants

View Source
const DefaultHost = "https://api.avrea.com"

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir(getenv func(string) string, home, platform string) string

ConfigDir preserves the Python CLI's platformdirs conventions.

func IsOrgBound added in v0.9.0

func IsOrgBound(token string) bool

IsOrgBound reports a token bound to one organization with no user behind it: /users/me routes and stored organization defaults do not apply.

func IsScoped

func IsScoped(token string) bool

func IsService added in v0.9.0

func IsService(token string) bool

func ValidateHost

func ValidateHost(host string) error

Types

type Config

type Config struct {
	// HostSource records resolution provenance for composed CLI configuration.
	HostSource       string
	StoreUnavailable bool
	Host             string
	Token            string
	Org              string
	Repo             string
}

func Load

func Load(store *Store, getenv func(string) string) (Config, error)

type CredentialKind added in v0.9.0

type CredentialKind int

CredentialKind is what a token authenticates as, decided by its prefix.

const (
	// PersonalKey belongs to a user, who may belong to several organizations.
	PersonalKey CredentialKind = iota
	// ScopedToken (avs_) is minted by a member and bound to one organization.
	ScopedToken
	// ServiceToken (avt_) is owned by a group, has no user and is bound to one
	// organization. It is supplied only through AVR_TOKEN.
	ServiceToken
)

func Kind added in v0.9.0

func Kind(token string) CredentialKind

func (CredentialKind) String added in v0.9.0

func (k CredentialKind) String() string

String names the kind in user-facing messages.

type Hosts

type Hosts struct {
	DefaultHost string
	Entries     map[string]any
	Order       []string
}

Hosts preserves insertion order, including when promoting a new default.

func (Hosts) Value

func (h Hosts) Value(host, key string) string

type Store

type Store struct{ Path string }

Store is shared with Python. All credentials belong to the caller's resolved host.

func DefaultStore

func DefaultStore() (*Store, error)

func (*Store) Clear

func (s *Store) Clear(host string) (bool, error)

func (*Store) ClearDefaultOrg

func (s *Store) ClearDefaultOrg(host string) (bool, error)

ClearDefaultOrg removes only the active host's stored organization override. Tokens, unknown fields, host ordering and the selected default host survive.

func (*Store) Read

func (s *Store) Read() Hosts

Read is a convenience for callers that have already loaded configuration.

func (*Store) ReadChecked

func (s *Store) ReadChecked() (Hosts, error)

ReadChecked distinguishes an absent store from an unreadable one.

func (*Store) Set

func (s *Store) Set(host, key, value string) error

func (*Store) Switch

func (s *Store) Switch(host string) error

func (*Store) ValidateMutation

func (s *Store) ValidateMutation() error

ValidateMutation refuses to discard a present but unreadable or malformed store. Reads remain lenient for commands that do not change credentials.

func (*Store) Write

func (s *Store) Write(h Hosts) error

Write updates the file directly, preserving symlinks and mounted-file behavior. Existing per-host fields and insertion order are retained.

Jump to

Keyboard shortcuts

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