clientcmd

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2014 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package cmd provides one stop shopping for a command line executable to bind the correct flags, build the client config, and create a working client. The code for usage looks like this:

clientBuilder := clientcmd.NewBuilder(clientcmd.NewDefaultAuthLoader())
clientBuilder.BindFlags(cmds.PersistentFlags())
apiClient, err := clientBuilder.Client()

Index

Constants

View Source
const (
	FlagApiServer       = "server"
	FlagMatchApiVersion = "match-server-version"
	FlagApiVersion      = "api-version"
	FlagAuthPath        = "auth-path"
	FlagInsecure        = "insecure-skip-tls-verify"
	FlagCertFile        = "client-certificate"
	FlagKeyFile         = "client-key"
	FlagCAFile          = "certificate-authority"
	FlagBearerToken     = "token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthLoader

type AuthLoader interface {
	// LoadAuth takes a path to a config file and can then do anything it needs in order to return a valid clientauth.Info
	LoadAuth(path string) (*clientauth.Info, error)
}

AuthLoaders are used to build clientauth.Info objects.

func NewDefaultAuthLoader

func NewDefaultAuthLoader() AuthLoader

NewDefaultAuthLoader returns a default implementation of an AuthLoader that only reads from a config file

func NewPromptingAuthLoader

func NewPromptingAuthLoader(reader io.Reader) AuthLoader

NewDefaultAuthLoader is an AuthLoader that parses an AuthInfo object from a file path. It prompts user and creates file if it doesn't exist.

type BoolFlag

type BoolFlag struct {
	Default     bool
	Value       bool
	WasProvided bool
}

BoolFlag implements FlagProvider

func (*BoolFlag) Provided

func (flag *BoolFlag) Provided() bool

func (*BoolFlag) Set

func (flag *BoolFlag) Set(value string) error

func (*BoolFlag) SetDefault

func (flag *BoolFlag) SetDefault(value bool)

SetDefault sets a default value for a flag while keeping Provided() false

func (*BoolFlag) String

func (flag *BoolFlag) String() string

func (*BoolFlag) Type

func (flag *BoolFlag) Type() string

type Builder

type Builder interface {
	// BindFlags must bind and keep track of all the flags required to build a client config object
	BindFlags(flags *pflag.FlagSet)
	// Config uses the values of the bound flags and builds a complete client config
	Config() (*client.Config, error)
	// Client calls BuildConfig under the covers and uses that config to return a client
	Client() (*client.Client, error)
}

Builder are used to bind and interpret command line flags to make it easy to get an api server client

func NewBuilder

func NewBuilder(authLoader AuthLoader) Builder

NewBuilder returns a valid Builder that uses the passed authLoader. If authLoader is nil, the NewDefaultAuthLoader is used.

type FlagProvider

type FlagProvider interface {
	// Provided returns true iff .Set was called on this flag
	Provided() bool
	pflag.Value
}

FlagProvider adds a check for whether .Set was called on this flag variable

type StringFlag

type StringFlag struct {
	Default     string
	Value       string
	WasProvided bool
}

StringFlag implements FlagProvider

func (*StringFlag) Provided

func (flag *StringFlag) Provided() bool

func (*StringFlag) Set

func (flag *StringFlag) Set(value string) error

func (*StringFlag) SetDefault

func (flag *StringFlag) SetDefault(value string)

SetDefault sets a default value for a flag while keeping Provided() false

func (*StringFlag) String

func (flag *StringFlag) String() string

func (*StringFlag) Type

func (flag *StringFlag) Type() string

Jump to

Keyboard shortcuts

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