client

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 8 Imported by: 182

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Erase

func Erase(program ProgramFunc, serverURL string) error

Erase executes a program to remove the server credentials from the native store.

Example
p := NewShellProgramFunc("docker-credential-pass")

if err := Erase(p, "https://registry.example.com"); err != nil {
	_, _ = fmt.Println(err)
}
Output:

func Get

func Get(program ProgramFunc, serverURL string) (*credentials.Credentials, error)

Get executes an external program to get the credentials from a native store.

Example
p := NewShellProgramFunc("docker-credential-pass")

creds, err := Get(p, "https://registry.example.com")
if err != nil {
	_, _ = fmt.Println(err)
}

_, _ = fmt.Printf("Got credentials for user `%s` in `%s`\n", creds.Username, creds.ServerURL)
Output:

func List added in v0.4.0

func List(program ProgramFunc) (map[string]string, error)

List executes a program to list server credentials in the native store.

func Store

func Store(program ProgramFunc, creds *credentials.Credentials) error

Store uses an external program to save credentials.

Example
p := NewShellProgramFunc("docker-credential-pass")

c := &credentials.Credentials{
	ServerURL: "https://registry.example.com",
	Username:  "exampleuser",
	Secret:    "my super secret token",
}

if err := Store(p, c); err != nil {
	_, _ = fmt.Println(err)
}
Output:

Types

type Program

type Program interface {
	Output() ([]byte, error)
	Input(in io.Reader)
}

Program is an interface to execute external programs.

type ProgramFunc

type ProgramFunc func(args ...string) Program

ProgramFunc is a type of function that initializes programs based on arguments.

func NewShellProgramFunc

func NewShellProgramFunc(name string) ProgramFunc

NewShellProgramFunc creates programs that are executed in a Shell.

func NewShellProgramFuncWithEnv added in v0.6.0

func NewShellProgramFuncWithEnv(name string, env *map[string]string) ProgramFunc

NewShellProgramFuncWithEnv creates programs that are executed in a Shell with environment variables

type Shell

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

Shell invokes shell commands to talk with a remote credentials-helper.

func (*Shell) Input

func (s *Shell) Input(in io.Reader)

Input sets the input to send to a remote credentials-helper.

func (*Shell) Output

func (s *Shell) Output() ([]byte, error)

Output returns responses from the remote credentials-helper.

Jump to

Keyboard shortcuts

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