credentials

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 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 credentials keeps the API key the CLI signs requests with. Keys live in the operating system's keychain, and when no keychain is available (a headless Linux machine without a Secret Service, for example) in a file under the user's config directory that only the user can read.

Index

Constants

View Source
const Service = "dekka-cli"

Service is the keychain service name the CLI stores keys under. Each key is stored against the API URL it was verified with, so a key for one API is never sent to another.

Variables

View Source
var ErrNotFound = errors.New("no key stored")

ErrNotFound means no key is stored for the API URL.

Functions

This section is empty.

Types

type Saved

type Saved struct {
	Source      Source
	KeychainErr error
}

Saved says where Set put a key. KeychainErr is why the keychain refused it when the file was used instead.

type Source

type Source string

Source says where a key was found.

const (
	SourceEnv      Source = "the DEKKA_TOKEN environment variable"
	SourceKeychain Source = "the system keychain"
	SourceFile     Source = "the credentials file"
)

type Store

type Store struct {
	Dir string
}

Store reads and writes keys. Dir is where the fallback file lives; it defaults to <user config dir>/dekka.

func (Store) Delete

func (s Store) Delete(apiURL string) (bool, error)

Delete removes the key for apiURL from the keychain and the file, and reports whether there was one to remove. A machine without a keychain has nothing stored there, so a keychain error only matters for the file.

func (Store) Get

func (s Store) Get(apiURL string) (string, Source, error)

Get returns the key stored for apiURL, looking in the keychain first.

func (Store) Path

func (s Store) Path() (string, error)

Path is the fallback credentials file.

func (Store) Set

func (s Store) Set(apiURL, key string) (Saved, error)

Set stores key for apiURL, in the keychain when it accepts the key and in the file otherwise.

Jump to

Keyboard shortcuts

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