Documentation ¶
Index ¶
- Constants
- Variables
- func AddNameserver(nameserver string) error
- func Append(base string, inc string) string
- func BackgroundRun(cmd *exec.Cmd, name string) (err error)
- func BackgroundRunWithCtx(cmdCtx *CMDContext) (err error)
- func CanRun(cmd *exec.Cmd) bool
- func CleanRsaKeys()
- func Contains(obj interface{}, target interface{}) bool
- func CreateDirIfNotExist(dir string)
- func DropHosts()
- func DumpHosts(hostsMap map[string]string) bool
- func ExtractErrorMessage(msg string) string
- func ExtractNetMaskFromCidr(cidr string) string
- func FindBrokenPort(exposePorts string) string
- func FixFileOwner(path string)
- func GetDaemonRunning(componentName string) int
- func GetJvmrcFilePath(jvmrcDir string) string
- func GetLocalDomains() string
- func GetLocalUserName() string
- func GetOutboundIP() (address string)
- func GetRandomSSHPort() int
- func GetTimestamp() string
- func IsCmd() bool
- func IsLinux() bool
- func IsPidFileExist() bool
- func IsProcessExist(pid int) bool
- func IsWindows() bool
- func KubeConfig() string
- func MapContains(subset, fullset map[string]string) bool
- func MapPut(m map[string]string, k, v string)
- func MergeMap(m1 map[string]string, m2 map[string]string) map[string]string
- func ParsePortMapping(exposePort string) (string, string)
- func PrivateKeyPath(name string) string
- func RandomDuration(n int) time.Duration
- func RandomPort() int
- func RandomString(n int) string
- func RemoveColor(msg string) string
- func RestoreConfig() error
- func RunAndWait(cmd *exec.Cmd, name string) (err error)
- func SetupConfigMapHeartBeat(ctx context.Context, client coreV1.ConfigMapInterface, name string)
- func SetupPodHeartBeat(ctx context.Context, client coreV1.PodInterface, name string)
- func SetupPortForwardHeartBeat(port int)
- func SetupServiceHeartBeat(ctx context.Context, client coreV1.ServiceInterface, name string)
- func String2Map(str string) map[string]string
- func WaitPortBeReady(waitTime, port int) bool
- func WritePidFile(componentName string) error
- func WritePrivateKey(privateKeyPath string, data []byte) error
- type CMDContext
- type SSHCredential
- type SSHGenerator
Constants ¶
const ResourceHeartBeatIntervalMinus = 5
Variables ¶
var KtHome = fmt.Sprintf("%s/.ktctl", UserHome)
var UserHome = os.Getenv("HOME")
Functions ¶
func AddNameserver ¶ added in v0.1.2
func BackgroundRun ¶
BackgroundRun run cmd in background
func BackgroundRunWithCtx ¶ added in v0.2.4
func BackgroundRunWithCtx(cmdCtx *CMDContext) (err error)
BackgroundRunWithCtx run cmd in background with context
func Contains ¶ added in v0.1.0
func Contains(obj interface{}, target interface{}) bool
Contains check whether obj exist in target, the type of target can be an array, slice or map
func ExtractErrorMessage ¶ added in v0.2.3
ExtractErrorMessage extract error from log
func ExtractNetMaskFromCidr ¶ added in v0.1.0
ExtractNetMaskFromCidr extract net mask length (e.g. 16) from cidr (e.g. 1.2.3.4/16)
func FindBrokenPort ¶ added in v0.2.2
FindBrokenPort Check if all ports has process listening to Return empty string if all ports are listened, otherwise return the first broken port
func FixFileOwner ¶ added in v0.1.1
func FixFileOwner(path string)
FixFileOwner set owner to original user when run with sudo
func GetDaemonRunning ¶ added in v0.1.0
GetDaemonRunning fetch daemon pid if exist
func GetJvmrcFilePath ¶ added in v0.1.0
GetJvmrcFilePath get jvmrc file from jvmrc dir
func GetLocalDomains ¶ added in v0.1.2
func GetLocalDomains() string
func GetLocalUserName ¶ added in v0.2.0
func GetLocalUserName() string
GetLocalUserName get current username
func GetOutboundIP ¶
func GetOutboundIP() (address string)
GetOutboundIP Get preferred outbound ip of this machine
func IsPidFileExist ¶ added in v0.1.0
func IsPidFileExist() bool
IsPidFileExist check pid file is exist or not
func IsProcessExist ¶ added in v0.1.0
IsProcessExist check whether specified process still running
func MapContains ¶ added in v0.2.3
func ParsePortMapping ¶ added in v0.2.3
ParsePortMapping parse <port> or <localPort>:<removePort> parameter
func RandomDuration ¶ added in v0.2.3
RandomDuration Generate random duration number
func RandomPort ¶ added in v0.2.3
func RandomPort() int
RandomPort Generate random number [1024, 65535)
func RemoveColor ¶ added in v0.2.3
RemoveColor remove shell color character in text
func RestoreConfig ¶ added in v0.1.2
func RestoreConfig() error
RestoreConfig remove the nameserver which is added by ktctl.
func RunAndWait ¶ added in v0.2.4
RunAndWait run cmd
func SetupConfigMapHeartBeat ¶ added in v0.1.2
func SetupConfigMapHeartBeat(ctx context.Context, client coreV1.ConfigMapInterface, name string)
SetupConfigMapHeartBeat setup heartbeat watcher for config map
func SetupPodHeartBeat ¶ added in v0.2.0
func SetupPodHeartBeat(ctx context.Context, client coreV1.PodInterface, name string)
SetupPodHeartBeat setup heartbeat watcher for deployment
func SetupPortForwardHeartBeat ¶ added in v0.1.2
func SetupPortForwardHeartBeat(port int)
SetupPortForwardHeartBeat setup heartbeat watcher for port forward
func SetupServiceHeartBeat ¶ added in v0.1.2
func SetupServiceHeartBeat(ctx context.Context, client coreV1.ServiceInterface, name string)
SetupServiceHeartBeat setup heartbeat watcher for service
func String2Map ¶ added in v0.0.12
String2Map Convert parameter string to real map "k1=v1,k2=v2" -> {"k1":"v1","k2","v2"}
func WaitPortBeReady ¶ added in v0.1.1
WaitPortBeReady return true when port is ready It waits at most waitTime seconds, then return false.
func WritePidFile ¶ added in v0.0.12
WritePidFile write pid to file
func WritePrivateKey ¶ added in v0.1.0
WritePrivateKey write ssh private key to privateKeyPath
Types ¶
type CMDContext ¶ added in v0.2.4
type CMDContext struct { Ctx context.Context Cmd *exec.Cmd Name string Stop chan struct{} // notify parent current Cmd occur error }
CMDContext context of cmd
type SSHCredential ¶ added in v0.1.0
SSHCredential ssh info
func NewDefaultSSHCredential ¶ added in v0.1.0
func NewDefaultSSHCredential() *SSHCredential
NewDefaultSSHCredential ...
type SSHGenerator ¶ added in v0.1.0
SSHGenerator ssh key pair generator
func Generate ¶ added in v0.1.0
func Generate(privateKeyPath string) (*SSHGenerator, error)
Generate generate SSHGenerator
func NewSSHGenerator ¶ added in v0.1.0
func NewSSHGenerator(privateKey string, publicKey string, privateKeyPath string) *SSHGenerator
NewSSHGenerator create ssh generator