keyring

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package keyring is a thin wrapper around github.com/zalando/go-keyring that adds timeouts (matching the pattern used by the official GitHub CLI) and provides mock helpers for testing.

This package exists so Sting can follow gh's exact storage standards and testability approach without pulling in the entire gh codebase.

Index

Constants

This section is empty.

Variables

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

Functions

func Delete

func Delete(service, user string) error

Delete removes a secret from the keyring. It times out after 3 seconds.

func Get

func Get(service, user string) (string, error)

Get retrieves a secret from the keyring. It times out after 3 seconds. Returns ErrNotFound (wrapping the underlying not-found error) when the secret does not exist.

func MockInit

func MockInit()

MockInit initializes the underlying keyring with an in-memory mock. Use this in tests.

func MockInitWithError

func MockInitWithError(err error)

MockInitWithError initializes the underlying keyring mock to always return the given error. Useful for testing error paths.

func Set

func Set(service, user, secret string) error

Set stores a secret in the keyring for the given service and user. It times out after 3 seconds to avoid hanging on unresponsive keyring backends.

Types

type TimeoutError

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

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

Jump to

Keyboard shortcuts

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