client

package
v0.0.0-...-9635b33 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 38 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultLongDescriptionFormat = `` /* 355-byte string literal not displayed */
View Source
const DefaultShortDescription = "login as user and save authentication data"
View Source
const DefaultTokenFileLocation = ".knox_user_auth"
View Source
const DefaultUsageLine = "login [username]"

Variables

View Source
var ErrTimeout = errors.New("timeout waiting on lock to become available")

ErrTimeout is returned when we cannot obtain an exclusive lock on the key file.

View Source
var Version string = "devel"

Version represents the compiled version of the client binary. It can be overridden at compile time with: `go build -ldflags "-X github.com/pinterest/knox/client.Version=1.2.3" github.com/pinterest/knox/cmd/dev_client` In the above example, knox version would give you `1.2.3`. By default, the version is `devel`.

Functions

func GetVersion

func GetVersion() string

GetVersion exposes the current client version

func Run

func Run(
	client knox.APIClient,
	p *VisibilityParams,
	loginCommand *Command,
)

Run is how to execute commands. It uses global variables and isn't safe to call in parallel.

Types

type Command

type Command struct {
	// Run runs the command.
	// The args are the arguments after the command name.
	Run func(cmd *Command, args []string) *ErrorStatus

	// UsageLine is the one-line usage message.
	// The first word in the line is taken to be the command name.
	UsageLine string

	// Short is the short description shown in the 'go help' output.
	Short string

	// Long is the long message shown in the 'go help <this-command>' output.
	Long string

	// Flag is a set of flags specific to this command.
	Flag flag.FlagSet

	// CustomFlags indicates that the command will do its own
	// flag parsing.
	CustomFlags bool
}

A Command is an implementation of a go command like go build or go fix.

func NewLoginCommand

func NewLoginCommand(
	oauthTokenEndpoint string,
	oauthClientID string,
	tokenFileLocation string,
	usageLine string,
	shortDescription string,
	longDescription string) *Command

func (*Command) Name

func (c *Command) Name() string

Name returns the command's name: the first word in the usage line.

func (*Command) Runnable

func (c *Command) Runnable() bool

Runnable reports whether the command can be run; otherwise it is a documentation pseudo-command such as importpath.

func (*Command) Usage

func (c *Command) Usage()

Usage prints the help string for a command.

type ErrorStatus

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

ErrorStatus wraps the error status of knox client command execution

type Keys

type Keys interface {
	Get() ([]string, error)
	Add([]string) error
	Overwrite([]string) error
	Remove([]string) error
	Lock() error
	Unlock() error
}

Keys are an interface for storing a list of key ids (for use with the register file to provide locks)

func NewKeysFile

func NewKeysFile(fn string) Keys

NewKeysFile takes in a filename and outputs an implementation of the Keys interface

type KeysFile

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

KeysFile is an implementation of Keys based on the file system for the register file.

func (*KeysFile) Add

func (k *KeysFile) Add(ks []string) error

Add will add the key IDs to the list. It expects Lock to have been called.

func (*KeysFile) Get

func (k *KeysFile) Get() ([]string, error)

Get will get the list of key ids. It expects Lock to have been called.

func (*KeysFile) Lock

func (k *KeysFile) Lock() error

Lock performs the nonblocking syscall lock and retries until the global timeout is met.

func (*KeysFile) Overwrite

func (k *KeysFile) Overwrite(ks []string) error

Overwrite deletes all existing values in the key list and writes the input. It expects Lock to have been called.

func (*KeysFile) Remove

func (k *KeysFile) Remove(ks []string) error

Remove will remove the input key ids from the list. It expects Lock to have been called.

func (*KeysFile) Unlock

func (k *KeysFile) Unlock() error

Unlock performs the nonblocking syscall unlock and retries until the global timeout is met.

type VisibilityParams

type VisibilityParams struct {
	Logf           func(string, ...interface{})
	Errorf         func(string, ...interface{})
	SummaryMetrics func(map[string]uint64)
	InvokeMetrics  func(map[string]string)
	GetKeyMetrics  func(map[string]string)
}

VisibilityParams exposes functions for the knox client to provide information

Jump to

Keyboard shortcuts

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