config

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: MPL-2.0, MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Parse returns a Config based on the contents of the namedfile.
	Parse(filename string) (*File, error)

	// UpsertUserToken adds/updates a user's bearer token.
	UpsertUserToken(ctx context.Context, parsed *File, user string, token []byte) error

	// UpsertContext adds or updates a context.
	UpsertContext(ctx context.Context, parsed *File, name, cluster, ns, user string) error
}

Client provides an interface to kubectl config files.

type DefaultClient

type DefaultClient struct {
	// Executor provides an os/exec.Command API for running the kubectl CLI.
	Executor cage_exec.Executor
}

DefaultClient implementation of Client operates on real config files.

func NewDefaultClient

func NewDefaultClient() *DefaultClient

func (*DefaultClient) Parse

func (c *DefaultClient) Parse(filename string) (*File, error)

NewDefaultClient returns a DefaultClient initialized by the config file named by the input or, if the latter is empty, by the default from k8s.io/client-go.

func (*DefaultClient) UpsertContext

func (c *DefaultClient) UpsertContext(ctx context.Context, file *File, name, cluster, ns, user string) error

UpsertContext adds or updates a context.

It implements Client.

func (*DefaultClient) UpsertUserToken

func (c *DefaultClient) UpsertUserToken(ctx context.Context, file *File, user string, token []byte) error

UpsertUserToken adds/updates a user's bearer token.

It implements Client.

type File

type File struct {
	// Name is the path to the kubectl config file.
	Name string

	// ClientCmdConfig represents the parsed config file.
	//
	// It is derived from the kubectl config file by client-go.
	ClientCmdConfig clientcmdapi.Config

	// RestConfig is the REST client config derived from clientCmdConfig.
	RestConfig *rest.Config
}

File represents a kubectl config file parsed by a Client implementation.

func (*File) GetCurrentCluster

func (f *File) GetCurrentCluster() (name string, _ *clientcmdapi.Cluster, _ error)

GetCurrentCluster returns the cluster selected by the current context.

func (*File) GetCurrentContext

func (f *File) GetCurrentContext() (name string, _ *clientcmdapi.Context, _ error)

GetCurrentContext returns the context selected in the config.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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