kubeconfig

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MainConfigPath string

MainConfigPath is the file path to the main config

View Source
var Out zerolog.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, PartsExclude: []string{"time", "level"}})

Out is for printing to stdout using zerolog

Functions

func ContainContext

func ContainContext(element interface{}) gotypes.GomegaMatcher

ContainContext is the Gomega matcher function

func GetRestConfig

func GetRestConfig(config *KConf) (*rest.Config, error)

GetRestConfig returns a rest.Config from a KConf type

func HasPipeData

func HasPipeData() bool

HasPipeData returns true if kconf is receiving data from stdin pipe

func Read

func Read(filepath string) (*clientcmdapi.Config, error)

Read loads a kubeconfig file and returns an api.Config (client-go) type

Types

type Configurable

type Configurable interface {
	AddContext() bool
	AddCluster() bool
	AddUser() bool
	// contains filtered or unexported methods
}

Configurable can validate and modify its own kubeconfig attributes

type ContainContextMatcher

type ContainContextMatcher struct {
	Element interface{}
}

ContainContextMatcher gets returned by the matcher function

func (*ContainContextMatcher) FailureMessage

func (matcher *ContainContextMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage displays when the context is not found but should be

func (*ContainContextMatcher) Match

func (matcher *ContainContextMatcher) Match(actual interface{}) (bool, error)

Match looks in a kubeconfig for a matching Context

func (*ContainContextMatcher) NegatedFailureMessage

func (matcher *ContainContextMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage displays when the context is found but shouldn't be

type KConf

type KConf struct {
	clientcmdapi.Config
}

KConf is a kubeconfig mixed with some useful functions

func GetConfig

func GetConfig() (*KConf, error)

GetConfig reads the main kubeconfig and returns a KConf type

func (*KConf) AddCluster

func (k *KConf) AddCluster(name string, cluster *clientcmdapi.Cluster) string

AddCluster attempts to add a Cluster and return the resulting name

func (*KConf) AddContext

func (k *KConf) AddContext(name string, context *clientcmdapi.Context) string

AddContext attempts to add a Context and return the resulting name

func (*KConf) AddUser

func (k *KConf) AddUser(name string, user *clientcmdapi.AuthInfo) string

AddUser attempts to add an AuthInfo and return the resulting name

func (*KConf) Export

func (k *KConf) Export(name string) (*clientcmdapi.Config, error)

Export returns a single context's config from a kubeconfig file

func (*KConf) GetContent

func (k *KConf) GetContent(name string) ([]byte, error)

GetContent converts a single config into writeable content

func (*KConf) List

func (k *KConf) List() ([]string, string)

List returns an array of contexts

func (*KConf) Merge

func (k *KConf) Merge(config *clientcmdapi.Config, name string)

Merge takes a config and combines it into a config file

func (*KConf) MoveContext

func (k *KConf) MoveContext(oldName, newName string) error

MoveContext renames an existing context

func (*KConf) Remove

func (k *KConf) Remove(name string) error

Remove takes a context and its associated resources out of kubeconfig

func (*KConf) Save

func (k *KConf) Save() error

Save writes out the updated main config to the filesystem

func (*KConf) SetCurrentContext

func (k *KConf) SetCurrentContext(contextName string) error

SetCurrentContext sets the kubeconfig current context to `currentContext`

func (*KConf) SetNamespace

func (k *KConf) SetNamespace(contextName, namespace string) error

SetNamespace sets the namespace for the context `contextName`

Jump to

Keyboard shortcuts

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