secrets

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 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 secrets keeps Blitz's secrets (API keys) out of its settings files: in the macOS Keychain, in the Secret Service on Linux (GNOME Keyring, KWallet), or, where neither is available, in an owner-only file beside the settings. A settings file refers to a stored secret as "keychain:<name>" (Ref); config resolves the reference when it loads.

Index

Constants

View Source
const RefPrefix = "keychain:"

RefPrefix marks a settings value that names a stored secret.

View Source
const Service = "dev.blitz"

Service is the name secrets are stored under (the keychain item's service, the Secret Service attribute).

Variables

View Source
var ErrNotFound = errors.New("no such secret")

ErrNotFound means no secret is stored under the name.

Functions

func ParseRef

func ParseRef(v string) (string, bool)

ParseRef returns the secret a settings value names, if it names one.

func Ref

func Ref(name string) string

Ref is the settings value that names the secret name.

func SetDefault

func SetDefault(s Store)

SetDefault replaces the store Default returns (tests, and the service once it knows its settings directory).

Types

type FileStore

type FileStore struct {
	Path string
	// contains filtered or unexported fields
}

FileStore keeps secrets in a TOML file.

func (*FileStore) Delete

func (f *FileStore) Delete(name string) error

Delete removes name's secret; a missing one isn't an error.

func (*FileStore) Get

func (f *FileStore) Get(name string) (string, error)

Get returns the secret stored under name, or ErrNotFound.

func (*FileStore) Kind

func (f *FileStore) Kind() string

Kind names the store and its file.

func (*FileStore) Set

func (f *FileStore) Set(name, value string) error

Set stores value under name, rewriting the file atomically.

type Memory

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

Memory keeps secrets in memory, for tests.

func (*Memory) Delete

func (s *Memory) Delete(name string) error

Delete removes name's secret; a missing one isn't an error.

func (*Memory) Get

func (s *Memory) Get(name string) (string, error)

Get returns the secret stored under name, or ErrNotFound.

func (*Memory) Kind

func (s *Memory) Kind() string

Kind is "memory".

func (*Memory) Set

func (s *Memory) Set(name, value string) error

Set stores value under name.

type Store

type Store interface {
	// Kind says where secrets go, for people ("macOS Keychain").
	Kind() string
	Get(name string) (string, error)
	Set(name, value string) error
	Delete(name string) error
}

Store keeps secrets by name.

func Default

func Default(dir string) Store

Default is this machine's store: the Keychain on macOS, the Secret Service on Linux when secret-tool can reach one, else a file in dir (the settings directory).

Jump to

Keyboard shortcuts

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