config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCredentialNotFound = errors.New("credential not found")

Functions

func Save

func Save(dir string, c *Config) error

Save replaces the file atomically so readers never observe a partial write.

func ValidName

func ValidName(name string) bool

Types

type Config

type Config struct {
	CurrentContext     string             `json:"current_context"`
	Contexts           map[string]Context `json:"contexts"`
	PendingCredentials []string           `json:"pending_credentials,omitempty"`
}

func Load

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

type Context

type Context struct {
	URL        string `json:"url"`
	Credential string `json:"credential,omitempty"`
}

type Credentials

type Credentials interface {
	Get(id string) (string, error)
	Set(id, key string) error
	Delete(id string) error
}

type Error

type Error struct {
	Code, Message string
	Cause         error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Keyring

type Keyring struct{}

func (Keyring) Delete

func (Keyring) Delete(id string) error

func (Keyring) Get

func (Keyring) Get(id string) (string, error)

func (Keyring) Set

func (Keyring) Set(id, key string) error

type Store

type Store struct {
	Dir         string
	Credentials Credentials
}

Store owns read-modify-write operations across configuration and credentials. Pending references form a write-ahead cleanup journal, never storing secrets.

func (Store) Delete

func (s Store) Delete(ctx context.Context, name string) error

func (Store) Load

func (s Store) Load() (*Config, error)

func (Store) Logout

func (s Store) Logout(ctx context.Context, name string) error

func (Store) Replace

func (s Store) Replace(ctx context.Context, name, url, key string) error

func (Store) Use

func (s Store) Use(ctx context.Context, name string) error

Jump to

Keyboard shortcuts

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