server

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULTMETHOD = "Exec"

DEFAULTMETHOD sub achieve Exec func

Variables

View Source
var Exec = func(c *CmdShim) {
	c.SubCmd = strings.TrimSpace(c.SubCmd)
	if strings.EqualFold(c.SubCmd, "") {
		fmt.Fprintln(os.Stderr, "subcmd is not allowed to be empty")
		return
	}
	c.SubCmd = strings.ToLower(c.SubCmd)
	if err := Trace(c); err != nil {
		fmt.Fprintln(os.Stderr, err.Error())
		os.Exit(1)
	}

}

Exec cmd

Functions

func AddCluster

func AddCluster(clusterName string) error

AddCluster mkdir cluster config dir

func CheckAllConfig

func CheckAllConfig()

CheckAllConfig check if the configuration is correct

func CheckConfig

func CheckConfig(path string) bool

CheckConfig check is correct

func CopyConfig

func CopyConfig(srcPath, desPath string) error

CopyConfig cp file

func FileCount

func FileCount(fileInfos []os.FileInfo) int

FileCount count file number

func GetClient

func GetClient(path string) (*restclient.Config, error)

GetClient get client 配置

func GetClusterNames

func GetClusterNames() map[string]bool

GetClusterNames list cluster

func GetConfigDir

func GetConfigDir(clusterName string) string

GetConfigDir get cluster config path

func GetConfigNameByClusterName

func GetConfigNameByClusterName(name string) (string, error)

GetConfigNameByClusterName get cluster config by cluster name

func GetKubeConfigPath

func GetKubeConfigPath() (string, error)

GetKubeConfigPath get kube config path

func GetSubCmd

func GetSubCmd(subCmdName string) reflect.Type

GetSubCmd get sub cmd in sub cmd pool

func IsCluster

func IsCluster(subCmd string) bool

IsCluster check cluster env true cluster already registered false is not cluster

func IsSubCmd

func IsSubCmd(subCmd string) bool

IsSubCmd check default cmd

func MKDir

func MKDir(path string) error

MKDir mkdir path

func RegisterExternalCmd

func RegisterExternalCmd(elem interface{})

RegisterExternalCmd register external cmd

func RegisterSubCmd

func RegisterSubCmd(elem interface{})

RegisterSubCmd register sub cmd

func Run

func Run(cmd *CmdShim) error

Run sub cmd

func RunExternalCmd

func RunExternalCmd(cmd *CmdShim) error

RunExternalCmd run external cmd

func Trace

func Trace(c *CmdShim) error

Trace sub cmd forward If it is not an internal command or an external command(kubectl).

func WarnConfig

func WarnConfig(path, clusteName string, fileCount int)

WarnConfig config warnnging

Types

type CmdShim

type CmdShim struct {
	SubCmd      string
	ExternalCmd string
	Args        []string
	Flags       []string
	Run         func(c *CmdShim)
}

CmdShim fields

type SubCommand

type SubCommand interface {
	Exec(cmd *CmdShim) error
}

SubCommand default sub cmd

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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