Documentation
¶
Index ¶
- Constants
- Variables
- func FindContextsByName(kc *clientcmdapi.Config, name string, filter func(string) bool) map[string]*clientcmdapi.Context
- func GetOccupiedLocalPort(srv string) (host string, port int, err error)
- func GetPortForwardingCmd(localPort int, remoteAPIAddr string, via string) string
- func Load(configPath string) (*clientcmdapi.Config, error)
- func LocalCachePath(remoteAddr string) string
- func Write(kc *clientcmdapi.Config) ([]byte, error)
- func WriteToFile(kc *clientcmdapi.Config, configPath string) error
- type ClusterInfo
- type ClusterInfos
- type ClusterKeyInfo
- type DownloadResult
- type Downloader
- type MergeOptions
- type Merger
- type PurgeOptions
- type Purger
Constants ¶
View Source
const ( SepAt = "@" SepHyphen = "-" SepColon = ":" DefaultRemotePort = 6443 )
View Source
const (
// DefaultHost is the host used to represent remote master locally
DefaultHost = "kubernetes"
)
View Source
const (
// DefaultKubeConfigPath is default kubeconfig path on remote host.
DefaultKubeConfigPath = "~/.kube/config"
)
Variables ¶
View Source
var ( ErrRemoteInvalidUser = errors.New("cube: user in remote kubeconfig is invalid") ErrRemoteInvalidCert = errors.New("cube: cert in remote kubeconfig is invalid") ErrConfigInvalid = errors.New("cube: remote kubeconfig must have only one cluster") )
View Source
var ( ErrEmptyNameSuffix = errors.New("cube: empty name-suffix for merge") ErrConfigAlreadyMerged = errors.New("cube: kubeconfig already merged") ErrClusterAlreadyExists = errors.New("cube: cluster already exists") ErrContextAlreadyExists = errors.New("cube: context already exists") ErrUserAlreadyExists = errors.New("cube: user already exists") ErrInvalidLocalPort = errors.New("cube: invalid local port for merge") )
View Source
var ( ErrClusterNotFound = errors.New("cube: cluster not found for purging") ErrMultipleClustersFound = errors.New("cube: multiple clusters found for purging") )
Functions ¶
func FindContextsByName ¶
func FindContextsByName(kc *clientcmdapi.Config, name string, filter func(string) bool) map[string]*clientcmdapi.Context
func GetOccupiedLocalPort ¶
func GetPortForwardingCmd ¶
func Load ¶
func Load(configPath string) (*clientcmdapi.Config, error)
Load reads kubeconfig from file
func LocalCachePath ¶
LocalCachePath returns cache path for remote kubectl config by convention. that's, `~/.config/cube/cache/$HOST`.
func WriteToFile ¶
func WriteToFile(kc *clientcmdapi.Config, configPath string) error
Types ¶
type ClusterInfo ¶
func ParseContext ¶
func ParseContext(kc *clientcmdapi.Config, ctxName string) (*ClusterInfo, error)
func (ClusterInfo) String ¶
func (f ClusterInfo) String() string
type ClusterInfos ¶
type ClusterInfos []ClusterInfo
func ListAllClusters ¶
func ListAllClusters() (ClusterInfos, error)
func (ClusterInfos) Len ¶
func (c ClusterInfos) Len() int
func (ClusterInfos) Less ¶
func (c ClusterInfos) Less(i, j int) bool
func (ClusterInfos) String ¶
func (c ClusterInfos) String() string
func (ClusterInfos) Swap ¶
func (c ClusterInfos) Swap(i, j int)
type ClusterKeyInfo ¶
type ClusterKeyInfo struct { Kc *clientcmdapi.Config // config where the cluster info belongs to ClusterName string Cluster *clientcmdapi.Cluster IsHTTP bool // whether the schema of cluster's server address is `HTTP` CtxName string Ctx *clientcmdapi.Context User *clientcmdapi.AuthInfo }
ClusterKeyInfo contains key info about a k8s cluster from given kubectl config.
type DownloadResult ¶
type DownloadResult struct { ClusterName string // matched cluster name Kc *clientcmdapi.Config // remote kubectl config }
DownloadResult represents the download status
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader download kubernetes config for remote cluster. also download cert files if necessary.
func NewDownloader ¶
func NewDownloader(remoteAddr string) *Downloader
NewDownloader create a new remote config downloader.
func (*Downloader) Download ¶
func (d *Downloader) Download() (DownloadResult, error)
Download fetches config and cert files.
type MergeOptions ¶
MergeOptions represents options for merge
type Merger ¶
type Merger interface { Merge() error Result() *clientcmdapi.Config LocalPort() int RemoteAPIAddr() string }
Merger merge remote cluster config into local `~/.kube/config`
func NewMerger ¶
func NewMerger(opts MergeOptions) Merger
type PurgeOptions ¶
PurgeOptions represent options for purge.
type Purger ¶
type Purger interface { Purge() error Result() *clientcmdapi.Config Deleted() []string }
Purger deletes Kubernetes configs under given conditions
func NewPurger ¶
func NewPurger(opts PurgeOptions) Purger
Source Files
¶
Click to show internal directories.
Click to hide internal directories.