cmd

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const SourceCmd = "[[ ! -f ~/.kubecm ]] || source ~/.kubecm"

SourceCmd source command

Variables

View Source
var Clouds = []CloudInfo{
	{
		Name:     "AlibabaCloud",
		Alias:    []string{"alibabacloud", "alicloud", "aliyun", "ack"},
		HomePage: "https://cs.console.aliyun.com",
		Service:  "ACK",
	},
	{
		Name:     "TencentCloud",
		Alias:    []string{"tencentcloud", "tencent", "tke"},
		HomePage: "https://console.cloud.tencent.com/tke",
		Service:  "TKE",
	},
	{
		Name:     "Rancher",
		Alias:    []string{"rancher"},
		HomePage: "https://rancher.com",
		Service:  "Rancher",
	},
	{
		Name:     "AWS",
		Alias:    []string{"aws", "eks"},
		HomePage: "https://console.aws.amazon.com/eks/home",
		Service:  "EKS",
	},
	{
		Name:     "Azure",
		Alias:    []string{"azure", "aks"},
		HomePage: "https://portal.azure.com",
		Service:  "AKS",
	},
}

Clouds date of clouds

View Source
var DOCS = "https://kubecm.cloud/"

Functions

func AddToLocal added in v0.16.0

func AddToLocal(newConfig *clientcmdapi.Config, path, newName string, cover bool) error

AddToLocal add kubeConfig to local

func BoolUI added in v0.6.7

func BoolUI(label string) string

BoolUI output bool ui

func CheckAndTransformFilePath added in v0.12.0

func CheckAndTransformFilePath(path string) (string, error)

CheckAndTransformFilePath return converted path

func CheckNamespaceExist added in v0.27.1

func CheckNamespaceExist(namespace string, clientset kubernetes.Interface) (bool, error)

CheckNamespaceExist check namespace exist

func CheckValidContext added in v0.13.0

func CheckValidContext(clear bool, config *clientcmdapi.Config) *clientcmdapi.Config

CheckValidContext check and clean mismatched AuthInfo and Cluster

func GetClientSet added in v0.27.1

func GetClientSet(configFile string) (kubernetes.Interface, error)

GetClientSet return clientset

func Hash added in v0.1.2

func Hash(data string) string

Hash returns the hex form of the sha256 of the argument.

func HashSuf added in v0.3.0

func HashSuf(config *clientcmdapi.Config) string

HashSuf return the string of kubeconfig.

func HashSufString added in v0.14.0

func HashSufString(data string) string

HashSufString return the string of HashSuf.

func MacNotifier added in v0.20.0

func MacNotifier(msg string) error

MacNotifier send notify message in macOS

func MoreInfo added in v0.15.0

func MoreInfo(clientSet kubernetes.Interface, writer io.Writer) error

MoreInfo output more info

func PrintTable added in v0.13.0

func PrintTable(config *clientcmdapi.Config) error

PrintTable generate table

func PromptUI added in v0.7.4

func PromptUI(label string, name string) string

PromptUI output prompt ui

func SelectUI added in v0.6.3

func SelectUI(kubeItems []Needle, label string) int

SelectUI output select ui

func UpdateConfigFile added in v0.13.0

func UpdateConfigFile(file string, updateConfig *clientcmdapi.Config) error

UpdateConfigFile update kubeconfig

func WriteConfig added in v0.3.0

func WriteConfig(cover bool, file string, outConfig *clientcmdapi.Config) error

WriteConfig write kubeconfig

Types

type AddCommand added in v0.7.0

type AddCommand struct {
	BaseCommand
}

AddCommand add command struct

func (*AddCommand) Init added in v0.7.0

func (ac *AddCommand) Init()

Init AddCommand

type AliasCommand added in v0.10.0

type AliasCommand struct {
	BaseCommand
}

AliasCommand alias command struct

func (*AliasCommand) Init added in v0.10.0

func (al *AliasCommand) Init()

Init AliasCommand

type BaseCommand added in v0.10.1

type BaseCommand struct {
	// contains filtered or unexported fields
}

BaseCommand struct

func NewBaseCommand added in v0.10.1

func NewBaseCommand() *BaseCommand

NewBaseCommand cmd struct

func (*BaseCommand) AddCommands added in v0.10.4

func (bc *BaseCommand) AddCommands(children ...Command)

AddCommands adds children commands to the parent command

func (*BaseCommand) CobraCmd added in v0.10.1

func (bc *BaseCommand) CobraCmd() *cobra.Command

CobraCmd returns BaseCommand

func (*BaseCommand) Init added in v0.10.1

func (bc *BaseCommand) Init()

Init BaseCommand

func (*BaseCommand) Name added in v0.10.1

func (bc *BaseCommand) Name() string

Name returns name of BaseCommand

type ClearCommand added in v0.13.0

type ClearCommand struct {
	BaseCommand
}

ClearCommand clean command struct

func (*ClearCommand) Init added in v0.13.0

func (cl *ClearCommand) Init()

Init ClearCommand

type Cli added in v0.7.0

type Cli struct {
	// contains filtered or unexported fields
}

Cli cmd struct

func NewCli added in v0.7.0

func NewCli() *Cli

NewCli returns the cli instance used to register and execute command

func (*Cli) Run added in v0.7.0

func (cli *Cli) Run() error

Run command

type CloudAddCommand added in v0.19.0

type CloudAddCommand struct {
	CloudCommand
}

CloudAddCommand add command struct

func (*CloudAddCommand) Init added in v0.19.0

func (ca *CloudAddCommand) Init()

Init AddCommand

type CloudCommand added in v0.16.0

type CloudCommand struct {
	BaseCommand
}

CloudCommand cloud command struct

func (*CloudCommand) Init added in v0.16.0

func (cc *CloudCommand) Init()

Init CloudCommand

type CloudInfo added in v0.16.0

type CloudInfo struct {
	Name     string
	Alias    []string
	HomePage string
	Service  string
}

CloudInfo Public cloud info

type CloudListCommand added in v0.19.0

type CloudListCommand struct {
	CloudCommand
}

CloudListCommand add command struct

func (*CloudListCommand) Init added in v0.19.0

func (cl *CloudListCommand) Init()

Init AddCommand

type ClusterStatusCheck added in v0.20.0

type ClusterStatusCheck struct {
	Version   *v.Info
	ClientSet *kubernetes.Clientset
	Config    *rest.Config
}

ClusterStatusCheck check cluster status

func ClusterStatus added in v0.2.1

func ClusterStatus(duration time.Duration) (*ClusterStatusCheck, error)

ClusterStatus output cluster status

type Command added in v0.7.0

type Command interface {
	// Init command
	Init()

	// CobraCmd
	CobraCmd() *cobra.Command
}

Command is cli command interface

type CompletionCommand added in v0.7.0

type CompletionCommand struct {
	BaseCommand
}

CompletionCommand completion cmd struct

func (*CompletionCommand) Init added in v0.7.0

func (cc *CompletionCommand) Init()

Init CompletionCommand

type CreateCommand added in v0.15.0

type CreateCommand struct {
	BaseCommand
}

CreateCommand clean command struct

func (*CreateCommand) Init added in v0.15.0

func (ce *CreateCommand) Init()

Init CreateCommand

type CreateOptions added in v0.15.0

type CreateOptions struct {
	// contains filtered or unexported fields
}

type DeleteCommand added in v0.7.0

type DeleteCommand struct {
	BaseCommand
}

DeleteCommand delete cmd struct

func (*DeleteCommand) Init added in v0.7.0

func (dc *DeleteCommand) Init()

Init DeleteCommand

type DocsCommand added in v0.27.0

type DocsCommand struct {
	BaseCommand
}

func (*DocsCommand) Init added in v0.27.0

func (dc *DocsCommand) Init()

Init DocsCommand

type ExportCommand added in v0.24.0

type ExportCommand struct {
	BaseCommand
}

AddCommand add command struct

func (*ExportCommand) Init added in v0.24.0

func (ec *ExportCommand) Init()

Init AddCommand

type KubeConfigOption added in v0.14.0

type KubeConfigOption struct {
	// contains filtered or unexported fields
}

KubeConfigOption kubeConfig option

type ListCommand added in v0.9.0

type ListCommand struct {
	BaseCommand
}

ListCommand list cmd struct

func (*ListCommand) Init added in v0.9.0

func (lc *ListCommand) Init()

Init ListCommand

type MergeCommand added in v0.7.0

type MergeCommand struct {
	BaseCommand
}

MergeCommand merge cmd struct

func (*MergeCommand) Init added in v0.7.0

func (mc *MergeCommand) Init()

Init MergeCommand

type NamespaceCommand added in v0.8.0

type NamespaceCommand struct {
	BaseCommand
}

NamespaceCommand namespace cmd struct

func (*NamespaceCommand) Init added in v0.8.0

func (nc *NamespaceCommand) Init()

Init NamespaceCommand

type Namespaces added in v0.10.1

type Namespaces struct {
	Name    string
	Default bool
}

Namespaces namespaces struct

func GetNamespaceList added in v0.8.0

func GetNamespaceList(currentNamespace string, clientset kubernetes.Interface) ([]Namespaces, error)

GetNamespaceList return namespace list

type Needle added in v0.10.1

type Needle struct {
	Name    string
	Cluster string
	User    string
	Center  string
}

Needle use for switch

func ExitOption added in v0.7.4

func ExitOption(kubeItems []Needle) ([]Needle, error)

ExitOption exit option of SelectUI

type PromptRunner added in v0.22.1

type PromptRunner interface {
	Run() (string, error)
}

PromptRunner interface - For better unit testing

type RenameCommand added in v0.7.0

type RenameCommand struct {
	BaseCommand
}

RenameCommand rename cmd struce

func (*RenameCommand) Init added in v0.7.0

func (rc *RenameCommand) Init()

Init RenameCommand

type SelectRunner added in v0.22.1

type SelectRunner interface {
	Run() (int, string, error)
}

SelectRunner interface - For better unit testing

type SwitchCommand added in v0.7.0

type SwitchCommand struct {
	BaseCommand
}

SwitchCommand switch cmd struct

func (*SwitchCommand) Init added in v0.7.0

func (sc *SwitchCommand) Init()

Init SwitchCommand

type VersionCommand added in v0.7.0

type VersionCommand struct {
	BaseCommand
}

VersionCommand version cmd struct

func (*VersionCommand) Init added in v0.7.0

func (vc *VersionCommand) Init()

Init VersionCommand

Jump to

Keyboard shortcuts

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