kubernetes: github.com/igm/kubernetes/pkg/client/clientcmd Index | Files

package clientcmd

import "github.com/igm/kubernetes/pkg/client/clientcmd"

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

Package Files

auth_loaders.go client_builder.go doc.go provided_flags.go

Constants

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"
)

type AuthLoader Uses

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 Uses

func NewDefaultAuthLoader() AuthLoader

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

func NewPromptingAuthLoader Uses

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 Uses

type BoolFlag struct {
    Default     bool
    Value       bool
    WasProvided bool
}

BoolFlag implements FlagProvider

func (*BoolFlag) Provided Uses

func (flag *BoolFlag) Provided() bool

func (*BoolFlag) Set Uses

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

func (*BoolFlag) SetDefault Uses

func (flag *BoolFlag) SetDefault(value bool)

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

func (*BoolFlag) String Uses

func (flag *BoolFlag) String() string

func (*BoolFlag) Type Uses

func (flag *BoolFlag) Type() string

type Builder Uses

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 Uses

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 Uses

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 Uses

type StringFlag struct {
    Default     string
    Value       string
    WasProvided bool
}

StringFlag implements FlagProvider

func (*StringFlag) Provided Uses

func (flag *StringFlag) Provided() bool

func (*StringFlag) Set Uses

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

func (*StringFlag) SetDefault Uses

func (flag *StringFlag) SetDefault(value string)

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

func (*StringFlag) String Uses

func (flag *StringFlag) String() string

func (*StringFlag) Type Uses

func (flag *StringFlag) Type() string

Package clientcmd imports 12 packages (graph). Updated 2018-04-17. Refresh now. Tools for package owners.