credentials

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 8 Imported by: 376

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Name is filled at linking time
	Name = ""

	// Package is filled at linking time
	Package = "github.com/docker/docker-credential-helpers"

	// Version holds the complete version number. Filled in at linking time.
	Version = "v0.0.0+unknown"

	// Revision is filled with the VCS (e.g. git) revision being used to build
	// the program at linking time.
	Revision = ""
)
View Source
var CredsLabel = "Docker Credentials"

CredsLabel holds the way Docker credentials should be labeled as such in credentials stores that allow labelling. That label allows to filter out non-Docker credentials too at lookup/search in macOS keychain, Windows credentials manager and Linux libsecret. Default value is "Docker Credentials"

Functions

func Erase added in v0.3.0

func Erase(helper Helper, reader io.Reader) error

Erase removes credentials from the store. The reader must contain the server URL to remove.

func Get added in v0.3.0

func Get(helper Helper, reader io.Reader, writer io.Writer) error

Get retrieves the credentials for a given server url. The reader must contain the server URL to search. The writer is used to write the JSON serialization of the credentials.

func HandleCommand added in v0.3.0

func HandleCommand(helper Helper, action Action, in io.Reader, out io.Writer) error

HandleCommand runs a helper to execute a credential action.

func IsCredentialsMissingServerURL added in v0.5.1

func IsCredentialsMissingServerURL(err error) bool

IsCredentialsMissingServerURL returns true if the error was an errCredentialsMissingServerURL.

func IsCredentialsMissingServerURLMessage added in v0.5.1

func IsCredentialsMissingServerURLMessage(err string) bool

IsCredentialsMissingServerURLMessage checks for an errCredentialsMissingServerURL in the error message.

func IsCredentialsMissingUsername added in v0.5.1

func IsCredentialsMissingUsername(err error) bool

IsCredentialsMissingUsername returns true if the error was an errCredentialsMissingUsername.

func IsCredentialsMissingUsernameMessage added in v0.5.1

func IsCredentialsMissingUsernameMessage(err string) bool

IsCredentialsMissingUsernameMessage checks for an errCredentialsMissingUsername in the error message.

func IsErrCredentialsNotFound added in v0.3.0

func IsErrCredentialsNotFound(err error) bool

IsErrCredentialsNotFound returns true if the error was caused by not having a set of credentials in a store.

func IsErrCredentialsNotFoundMessage added in v0.3.0

func IsErrCredentialsNotFoundMessage(err string) bool

IsErrCredentialsNotFoundMessage returns true if the error was caused by not having a set of credentials in a store.

This function helps to check messages returned by an external program via its standard output.

func List added in v0.4.0

func List(helper Helper, writer io.Writer) error

List returns all the serverURLs of keys in the OS store as a list of strings

func NewErrCredentialsMissingServerURL added in v0.5.1

func NewErrCredentialsMissingServerURL() error

NewErrCredentialsMissingServerURL creates a new error for errCredentialsMissingServerURL.

func NewErrCredentialsMissingUsername added in v0.5.1

func NewErrCredentialsMissingUsername() error

NewErrCredentialsMissingUsername creates a new error for errCredentialsMissingUsername.

func NewErrCredentialsNotFound added in v0.3.0

func NewErrCredentialsNotFound() error

NewErrCredentialsNotFound creates a new error for when the credentials are not in the store.

func PrintVersion added in v0.5.2

func PrintVersion(writer io.Writer) error

PrintVersion outputs the current version.

func Serve

func Serve(helper Helper)

Serve initializes the credentials-helper and parses the action argument. This function is designed to be called from a command line interface. It uses os.Args[1] as the key for the action. It uses os.Stdin as input and os.Stdout as output. This function terminates the program with os.Exit(1) if there is an error.

func SetCredsLabel added in v0.5.0

func SetCredsLabel(label string)

SetCredsLabel is a simple setter for CredsLabel

func Store added in v0.3.0

func Store(helper Helper, reader io.Reader) error

Store uses a helper and an input reader to save credentials. The reader must contain the JSON serialization of a Credentials struct.

Types

type Action added in v0.8.0

type Action = string

Action defines the name of an action (sub-command) supported by a credential-helper binary. It is an alias for "string", and mostly for convenience.

const (
	ActionStore   Action = "store"
	ActionGet     Action = "get"
	ActionErase   Action = "erase"
	ActionList    Action = "list"
	ActionVersion Action = "version"
)

List of actions (sub-commands) supported by credential-helper binaries.

type Credentials

type Credentials struct {
	ServerURL string
	Username  string
	Secret    string
}

Credentials holds the information shared between docker and the credentials store.

type Helper

type Helper interface {
	// Add appends credentials to the store.
	Add(*Credentials) error
	// Delete removes credentials from the store.
	Delete(serverURL string) error
	// Get retrieves credentials from the store.
	// It returns username and secret as strings.
	Get(serverURL string) (string, string, error)
	// List returns the stored serverURLs and their associated usernames.
	List() (map[string]string, error)
}

Helper is the interface a credentials store helper must implement.

Jump to

Keyboard shortcuts

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