utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSH_PAUSE_IN_SECONDS  = 20
	MAX_RETRY_COUNT       = 8
	MAX_WATCH_RETRY_COUNT = 4
	CREDENTIAL_PATH       = int(0)
	CLUSTER_PATH          = int(1)
	SSH_PATH              = int(2)
	OTHER_PATH            = int(3)
	EXEC_WITH_OUTPUT      = int(1)
	EXEC_WITHOUT_OUTPUT   = int(0)

	ROLE_CP = "controlplane"
	ROLE_WP = "workerplane"
	ROLE_LB = "loadbalancer"
	ROLE_DS = "datastore"

	CLOUD_CIVO  = "civo"
	CLOUD_AZURE = "azure"
	CLOUD_LOCAL = "local"
	CLOUD_AWS   = "aws"

	K8S_K3S     = "k3s"
	K8S_KUBEADM = "kubeadm"

	STORE_LOCAL  = "local"
	STORE_REMOTE = "remote"

	OPERATION_STATE_GET    = "get"
	OPERATION_STATE_CREATE = "create"
	OPERATION_STATE_DELETE = "delete"

	CLUSTER_TYPE_HA   = "ha"
	CLUSTER_TYPE_MANG = "managed"

	// makes the fake client
	KSCTL_FAKE_FLAG = "KSCTL_FAKE_FLAG_ENABLED"
	// KSCTL_TEST_DIR_ENABLED use this as environment variable to set a different home directory for ksctl during testing
	KSCTL_TEST_DIR_ENABLED = "KSCTL_TEST_DIR_ENABLED"
)

Variables

View Source
var (
	KSCTL_CONFIG_DIR = func() string {
		if runtime.GOOS == "windows" {
			return fmt.Sprintf("%s\\.ksctl", GetUserName())
		}
		return fmt.Sprintf("%s/.ksctl", GetUserName())
	}()
)

Functions

func CreateSSHKeyPair

func CreateSSHKeyPair(storage resources.StorageFactory, provider, clusterDir string) (string, error)

func GetCred added in v0.2.1

func GetCred(storage resources.StorageFactory, provider string) (i map[string]string, err error)

func GetPath

func GetPath(flag int, provider string, subfolders ...string) string

func GetUserName

func GetUserName() string

GetUserName returns current active username

func IsValidName

func IsValidName(clusterName string) error

func SaveCred added in v0.2.1

func SaveCred(storage resources.StorageFactory, config interface{}, provider string) error

func UserInputCredentials added in v0.2.1

func UserInputCredentials(logging logger.LogFactory) (string, error)

Types

type SSHCollection

type SSHCollection interface {
	SSHExecute(resources.StorageFactory) error
	Flag(int) SSHCollection
	Script(string) SSHCollection
	FastMode(bool) SSHCollection
	Username(string)
	LocPrivateKey(string)
	GetOutput() string
	IPv4(ip string) SSHCollection
}

type SSHPayload

type SSHPayload struct {
	UserName       string
	PathPrivateKey string
	PublicIP       string
	Output         string
	// contains filtered or unexported fields
}

func (*SSHPayload) FastMode added in v1.1.0

func (ssh *SSHPayload) FastMode(mode bool) SSHCollection

func (*SSHPayload) Flag added in v1.1.0

func (ssh *SSHPayload) Flag(execMethod int) SSHCollection

func (*SSHPayload) GetOutput added in v1.1.0

func (ssh *SSHPayload) GetOutput() string

func (*SSHPayload) IPv4 added in v1.1.0

func (ssh *SSHPayload) IPv4(ip string) SSHCollection

func (*SSHPayload) LocPrivateKey added in v1.1.0

func (ssh *SSHPayload) LocPrivateKey(s string)

func (*SSHPayload) SSHExecute

func (sshPayload *SSHPayload) SSHExecute(storage resources.StorageFactory) error

func (*SSHPayload) Script added in v1.1.0

func (ssh *SSHPayload) Script(s string) SSHCollection

func (*SSHPayload) Username added in v1.1.0

func (ssh *SSHPayload) Username(s string)

Jump to

Keyboard shortcuts

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