credstore

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package credstore holds the CLI's secrets: one item per key in the OS keyring, or one 0600 file per key when no keyring is available.

Index

Constants

View Source
const KeyringService = "norcube"

KeyringService is the service name of every keyring item. Single word so Keychain Access shows "norcube"; changing it orphans users' sessions.

Variables

View Source
var ErrNotFound = errors.New("secret not found")

ErrNotFound is returned by Store.Get for a missing key.

View Source
var ErrTooBig = errors.New("secret too big for the credential store")

ErrTooBig is returned by Set when the value exceeds what the store can hold (the Windows Credential Manager caps an item at 2.5 KB).

Functions

func Available

func Available() bool

Available reports whether the OS keyring can be used here. A Linux box without a Secret Service (containers, CI, SSH sessions without D-Bus) can't.

Types

type File

type File struct{ Dir string }

File stores each key in its own 0600 file under Dir (0700).

func (File) Delete

func (f File) Delete(key string) error

func (File) Get

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

func (File) Set

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

type Keyring

type Keyring struct{}

Keyring is the OS keyring (macOS Keychain, Secret Service, Windows Credential Manager).

func (Keyring) Delete

func (Keyring) Delete(key string) error

func (Keyring) Get

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

func (Keyring) Set

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

type Store

type Store interface {
	Get(key string) (string, error) // ErrNotFound when absent
	Set(key, value string) error
	Delete(key string) error // nil when absent
}

Store is a small secret key-value store.

func Open

func Open(kind, dir string, warn io.Writer) (Store, string, error)

Open returns the store a profile asked for. "keyring" falls back to the file store, with a one-time warning on warn, when no keyring is available. dir is the file store's directory.

Jump to

Keyboard shortcuts

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