pkg

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KubeConfigEnvVar      = "KUBECONFIG"
	DefaultKubeConfigPath = "~/.kube/config"
	KxConfigEnvVar        = "KXCONFIG"
	DefaultKxConfigPath   = "~/.kx.yaml"
)

Variables

This section is empty.

Functions

func GetKubeConfigPath

func GetKubeConfigPath() string

func GetKxConfigPath

func GetKxConfigPath() string

Types

type AuthProvider

type AuthProvider struct {
	Config AuthProviderConfig `yaml:"config"`
	Name   string             `yaml:"name"`
}

type AuthProviderConfig

type AuthProviderConfig struct {
	AccessToken string `yaml:"access-token,omitempty"`
	CmdArgs     string `yaml:"cmd-args,omitempty"`
	CmdPath     string `yaml:"cmd-path,omitempty"`
	Expiry      string `yaml:"expiry,omitempty"`
	ExpiryKey   string `yaml:"expiry-key,omitempty"`
	TokenKey    string `yaml:"token-key,omitempty"`
}

type CannotSetContextError

type CannotSetContextError struct {
	Message string
}

CannotSetContextError is a custom error type.

func NewCannotSetContextError

func NewCannotSetContextError(name string) CannotSetContextError

NewCannotSetContextError creates a new `CannotSetContextError`.

func (CannotSetContextError) Error

func (e CannotSetContextError) Error() string

type Cluster

type Cluster struct {
	ClusterConf ClusterConf `yaml:"cluster"`
	Name        string      `yaml:"name"`
}

type ClusterConf

type ClusterConf struct {
	CertificateAuthorityData string `yaml:"certificate-authority-data,omitempty"`
	CertificateAuthority     string `yaml:"certificate-authority,omitempty"`
	Server                   string `yaml:"server,omitempty"`
	InsecureSkipVerify       bool   `yaml:"insecure-skip-tls-verify,omitempty"`
}

type ClusterFilter

type ClusterFilter func(ctx Cluster) bool

type ClusterUserData

type ClusterUserData struct {
	User    User      `yaml:"user"`
	Cluster Cluster   `yaml:"cluster"`
	Ctx     CtxNsPair `yaml:"ctx"`
}

func (ClusterUserData) JSON

func (c ClusterUserData) JSON() ([]byte, error)

func (ClusterUserData) YAML

func (c ClusterUserData) YAML() ([]byte, error)

type Clusters

type Clusters []Cluster

func (Clusters) Filter

func (cl Clusters) Filter(filter ClusterFilter) Clusters

func (Clusters) Get

func (cl Clusters) Get(name string) (Cluster, error)

func (Clusters) Len

func (cl Clusters) Len() int

func (Clusters) Less

func (cl Clusters) Less(i, j int) bool

func (Clusters) Swap

func (cl Clusters) Swap(i, j int)

type Context

type Context struct {
	ContextConf ContextConf `yaml:"context"`
	Name        string      `yaml:"name"`
}

type ContextConf

type ContextConf struct {
	Cluster   string `yaml:"cluster"`
	Namespace string `yaml:"namespace"`
	User      string `yaml:"user"`
}

type ContextFilter

type ContextFilter func(ctx *Context) bool

type Contexts

type Contexts []*Context

func (Contexts) GetContext

func (contexts Contexts) GetContext(name string) (*Context, error)

func (Contexts) GetNamespaceForContext

func (contexts Contexts) GetNamespaceForContext(name string) (string, error)

func (Contexts) Len

func (contexts Contexts) Len() int

func (Contexts) Less

func (contexts Contexts) Less(i, j int) bool

func (Contexts) SetNamespaceForContext

func (contexts Contexts) SetNamespaceForContext(ctxName, ns string) error

func (Contexts) Swap

func (contexts Contexts) Swap(i, j int)

type CtxNsPair

type CtxNsPair struct {
	Context   string `json:"context" yaml:"context"`
	Namespace string `json:"namespace" yaml:"namespace"`
}

func (CtxNsPair) String

func (c CtxNsPair) String() string

type Exec

type Exec struct {
	APIVersion         string `yaml:"apiVersion"`
	Command            string `yaml:"command"`
	InstallHint        string `yaml:"installHint"`
	ProvideClusterInfo bool   `yaml:"provideClusterInfo"`
}

type Favorites

type Favorites map[string]CtxNsPair

func (Favorites) AddFavorite

func (favorites Favorites) AddFavorite(name, ctx, ns string)

func (Favorites) FavoritesForContext

func (favorites Favorites) FavoritesForContext(name string) Favorites

func (Favorites) GetFavorite

func (favorites Favorites) GetFavorite(name string) (CtxNsPair, bool)

func (Favorites) IsFavorite

func (favorites Favorites) IsFavorite(ctx, ns string) (string, bool)

func (Favorites) String

func (favorites Favorites) String() string

type KubeConfig

type KubeConfig struct {
	APIVersion     string      `yaml:"apiVersion"`
	Clusters       Clusters    `yaml:"clusters"`
	Contexts       Contexts    `yaml:"contexts"`
	CurrentContext string      `yaml:"current-context"`
	Kind           string      `yaml:"kind"`
	Preferences    Preferences `yaml:"preferences"`
	Users          Users       `yaml:"users"`
	// contains filtered or unexported fields
}

func GetDefaultKubeConfig

func GetDefaultKubeConfig() (*KubeConfig, error)

func GetKubeConfig

func GetKubeConfig(path string) (*KubeConfig, error)

func (KubeConfig) FilterContexts

func (kc KubeConfig) FilterContexts(filter ContextFilter) Contexts

func (KubeConfig) GetClusterUserData

func (kc KubeConfig) GetClusterUserData(ctxName string) (*ClusterUserData, error)

func (KubeConfig) GetContext

func (kc KubeConfig) GetContext(name string) (*Context, error)

func (KubeConfig) GetCurrentContext

func (kc KubeConfig) GetCurrentContext() (*Context, error)

func (KubeConfig) GetCurrentContextAndNamespace

func (kc KubeConfig) GetCurrentContextAndNamespace() (CtxNsPair, error)

func (KubeConfig) GetCurrentContextName

func (kc KubeConfig) GetCurrentContextName() string

func (KubeConfig) GetNamespaceForContext

func (kc KubeConfig) GetNamespaceForContext(name string) (string, error)

func (KubeConfig) GetNamespaceForCurrentContext

func (kc KubeConfig) GetNamespaceForCurrentContext() (string, error)

func (KubeConfig) RenameContext

func (kc KubeConfig) RenameContext(contextName, newName string) error

func (KubeConfig) Save

func (kc KubeConfig) Save(path string) error

func (*KubeConfig) SetContext

func (kc *KubeConfig) SetContext(name string)

func (*KubeConfig) SetNamespaceForContext

func (kc *KubeConfig) SetNamespaceForContext(ctxName, ns string) error

func (*KubeConfig) UseContext

func (kc *KubeConfig) UseContext(name string) error

type KxConfig

type KxConfig struct {
	Path      string
	Prompt    Prompt    `yaml:"prompt" json:"prompt"`
	Favorites Favorites `json:"favorites" yaml:"favorites"`
	Previous  CtxNsPair `json:"previous" yaml:"previous"`
	// contains filtered or unexported fields
}

func GetKxConfig

func GetKxConfig(path string) *KxConfig

func (*KxConfig) AddFavorite

func (kx *KxConfig) AddFavorite(name, ctx, ns string) error

func (KxConfig) Changed

func (kx KxConfig) Changed() bool

func (*KxConfig) FavoritesForContext

func (kx *KxConfig) FavoritesForContext(name string) Favorites

func (*KxConfig) GetFavorite

func (kx *KxConfig) GetFavorite(name string) (CtxNsPair, bool)

func (*KxConfig) GetPrevious

func (kx *KxConfig) GetPrevious() (CtxNsPair, error)

func (*KxConfig) GetPrompt

func (kx *KxConfig) GetPrompt() *Prompt

func (*KxConfig) IsFavorite

func (kx *KxConfig) IsFavorite(ctx, ns string) (string, bool)

func (KxConfig) Save

func (kx KxConfig) Save(path string) error

func (*KxConfig) SetPrevious

func (kx *KxConfig) SetPrevious(pair CtxNsPair) error

type NoPreviousContextError

type NoPreviousContextError struct {
	Message string
}

NoPreviousContextError is a custom error type.

func NewNoPreviousContextError

func NewNoPreviousContextError() NoPreviousContextError

NewNoPreviousContextError creates a new `NoPreviousContextError`.

func (NoPreviousContextError) Error

func (e NoPreviousContextError) Error() string

type NoSuchContextError

type NoSuchContextError struct {
	Message string
}

NoSuchContextError is returned when a context cannot be found.

func NewNoSuchContextError

func NewNoSuchContextError(name string) NoSuchContextError

NewNoSuchContextError creates a new `NoSuchContextError`.

func (NoSuchContextError) Error

func (e NoSuchContextError) Error() string

type Preferences

type Preferences struct{}

type Prompt

type Prompt struct {
	Separator      string `yaml:"separator" json:"separator"`
	LeftWrapper    string `yaml:"leftWrapper" json:"leftWrapper"`
	RightWrapper   string `yaml:"rightWrapper" json:"rightWrapper"`
	ContextColor   string `yaml:"contextColor" json:"contextColor"`
	NamespaceColor string `yaml:"namespaceColor" json:"namespaceColor"`
	SeparatorColor string `yaml:"separatorColor" json:"separatorColor"`
	ColorOff       string
}

func (Prompt) FillColors

func (p Prompt) FillColors() Prompt

type User

type User struct {
	Name     string   `yaml:"name"`
	UserConf UserConf `yaml:"user"`
}

type UserConf

type UserConf struct {
	AuthProvider      AuthProvider `yaml:"auth-provider,omitempty"`
	Password          string       `yaml:"password,omitempty"`
	Username          string       `yaml:"username,omitempty"`
	Token             string       `yaml:"token,omitempty"`
	ClientCertificate string       `yaml:"client-certificate,omitempty"`
	ClientKey         string       `yaml:"client-key,omitempty"`
	Exec              Exec         `yaml:"exec,omitempty"`
}

type UserFilter

type UserFilter func(ctx User) bool

type Users

type Users []User

func (Users) Filter

func (u Users) Filter(filter UserFilter) Users

func (Users) Get

func (u Users) Get(name string) (User, error)

func (Users) Len

func (u Users) Len() int

func (Users) Less

func (u Users) Less(i, j int) bool

func (Users) Swap

func (u Users) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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