keyring

package
v3.46.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package keyring provides credential storage using the OS keychain, with an optional tmpfs-backed store for headless Linux hosts.

Index

Constants

View Source
const (

	// CredentialStoreEnv selects the credential store used by keyring.New.
	// Supported values are "auto", "keyring", and "shm".
	CredentialStoreEnv = "BUILDKITE_CREDENTIAL_STORE"

	// CredentialStorePathEnv overrides the tmpfs credential file path. It is
	// mainly useful for tests and controlled environments.
	CredentialStorePathEnv = "BUILDKITE_CREDENTIAL_STORE_PATH"

	StoreAuto    = "auto"
	StoreKeyring = "keyring"
	StoreSHM     = "shm"
)

Variables

This section is empty.

Functions

func ClearRefreshToken added in v3.46.0

func ClearRefreshToken(org string) error

ClearRefreshToken removes any stored OAuth refresh token for an organization. This is used when replacing OAuth credentials with a non-OAuth API token.

func MockForTesting

func MockForTesting()

MockForTesting replaces the keyring backend with an in-memory store and marks it as available so subsequent New() calls use the mock.

func ResetForTesting added in v3.35.0

func ResetForTesting()

ResetForTesting resets the availability cache so that the next call to New() re-evaluates the environment. Intended for use in tests only.

func ValidateCredentialStore added in v3.46.0

func ValidateCredentialStore(store string) error

Types

type Keyring

type Keyring struct {
	// contains filtered or unexported fields
}

Keyring provides credential storage with fallback support.

func New

func New() *Keyring

New creates a new Keyring instance using the default credential store mode.

func NewWithCredentialStore added in v3.46.0

func NewWithCredentialStore(store string) (*Keyring, error)

NewWithCredentialStore creates a keyring using the requested credential store. An empty store uses the default auto mode.

func (*Keyring) Delete

func (k *Keyring) Delete(org string) error

Delete removes a token for the given organization

func (*Keyring) DeleteRefreshToken added in v3.42.0

func (k *Keyring) DeleteRefreshToken(org string) error

DeleteRefreshToken removes a refresh token for the given organization

func (*Keyring) Description added in v3.46.0

func (k *Keyring) Description() string

Description returns a user-facing description of the active credential store.

func (*Keyring) Get

func (k *Keyring) Get(org string) (string, error)

Get retrieves a token for the given organization

func (*Keyring) GetRefreshToken added in v3.42.0

func (k *Keyring) GetRefreshToken(org string) (string, error)

GetRefreshToken retrieves a refresh token for the given organization

func (*Keyring) IsAvailable

func (k *Keyring) IsAvailable() bool

IsAvailable returns true if the configured credential store is available.

func (*Keyring) Set

func (k *Keyring) Set(org, token string) error

Set stores a token for the given organization

func (*Keyring) SetRefreshToken added in v3.42.0

func (k *Keyring) SetRefreshToken(org, token string) error

SetRefreshToken stores a refresh token for the given organization

Jump to

Keyboard shortcuts

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