keyring

package
v3.67.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 17 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 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) CheckWritable added in v3.57.0

func (k *Keyring) CheckWritable() error

CheckWritable verifies that the configured credential store can persist and remove a new credential without modifying any real credentials.

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) Lock added in v3.67.0

func (k *Keyring) Lock(ctx context.Context, org string) (func(), error)

Lock serializes credential mutation for an organization, including refresh exchanges. Callers must release it before returning and must not acquire it recursively. Individual storage operations retain their short file locks.

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

func (*Keyring) SetTokens added in v3.67.0

func (k *Keyring) SetTokens(ctx context.Context, org, accessToken, refreshToken string) error

SetTokens persists a successful refresh under the caller's existing Lock. The context bounds storage lock waits, not synchronous backend I/O. Writes remain separate and are not crash-atomic. An empty refresh token preserves it.

Jump to

Keyboard shortcuts

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