client

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionFileName   string = "kl-session.yaml"
	MainCtxFileName   string = "kl-main-contexts.yaml"
	ExtraDataFileName string = "kl-extra-data.yaml"
	DeviceFileName    string = "kl-device.yaml"
	CompleteFileName  string = "kl-completion"
)
View Source
const (
	Res_config resType = "config"
	Res_secret resType = "secret"
	Res_mres   resType = "mres"
)
View Source
const (
	KL_LOCK_PATH = "/home/kl/workspace/kl.lock"
)

Variables

This section is empty.

Functions

func BackupDns

func BackupDns() ([]string, error)

func CheckPortAvailable

func CheckPortAvailable(port int) bool

func CurrentAccountName

func CurrentAccountName() (string, error)

func CurrentClusterName

func CurrentClusterName() (string, error)

func CurrentDeviceIp

func CurrentDeviceIp() (*string, error)

func CurrentDeviceName

func CurrentDeviceName() (string, error)

func DeleteDeviceContext

func DeleteDeviceContext(dName string) error

func DevBoxJsonPath

func DevBoxJsonPath() string

func DevBoxLockPath

func DevBoxLockPath() string

func EnsureAppRunning

func EnsureAppRunning() error

func ExecPackageCommand

func ExecPackageCommand(cmdString string, cmd *cobra.Command) error

func GetActiveCluster

func GetActiveCluster() (string, error)

func GetAuthSession

func GetAuthSession() (string, error)

func GetAvailablePort

func GetAvailablePort() (int, error)

func GetBaseURL

func GetBaseURL() (string, error)

func GetCompletionContext

func GetCompletionContext() (string, error)

func GetConfigFolder

func GetConfigFolder() (configFolder string, err error)

func GetConfigPath

func GetConfigPath() string

func GetCookieString

func GetCookieString(options ...fn.Option) (string, error)

func GetDns

func GetDns() ([]string, error)

func GetUserHomeDir

func GetUserHomeDir() (string, error)

func InsideBox

func InsideBox() bool

func IsLoading

func IsLoading() (bool, error)

func Logout

func Logout() error

func OnlyInsideBox

func OnlyInsideBox(cmd *cobra.Command)

func OnlyOutsideBox

func OnlyOutsideBox(cmd *cobra.Command)

func ReadFile

func ReadFile(name string) ([]byte, error)

func SaveAuthSession

func SaveAuthSession(session string) error

func SaveBaseURL

func SaveBaseURL(url string) error

func SaveExtraData

func SaveExtraData(extraData *ExtraData) error

func SelectAccount

func SelectAccount(accountName string) error

func SelectDevice

func SelectDevice(deviceName string) error

func SelectEnv

func SelectEnv(ev Env) error

func SelectEnvOnPath

func SelectEnvOnPath(ev Env, pth string) error

func SetAccountToMainCtx

func SetAccountToMainCtx(aName string) error

func SetActiveCluster

func SetActiveCluster(devCluster string) error

func SetBackupDns

func SetBackupDns(dns []string) error

func SetClusterToMainCtx

func SetClusterToMainCtx(cName string) error

func SetDns

func SetDns(dns []string) error

func SetLoading

func SetLoading(loading bool) error

func SyncDevboxShellEnvFile

func SyncDevboxShellEnvFile(cmd *cobra.Command) error

func WriteCompletionContext

func WriteCompletionContext() (io.Writer, error)

func WriteDeviceContext

func WriteDeviceContext(dc *DeviceContext) error

func WriteKLFile

func WriteKLFile(fileObj KLFileType) error

Types

type CSType

type CSType string
const (
	ConfigType CSType = "config"
	SecretType CSType = "secret"
)

type DeviceContext

type DeviceContext struct {
	DeviceName string `json:"deviceName"`

	// PrivateKey []byte `json:"privateKey"`
	DeviceIp  net.IP   `json:"deviceIp"`
	DeviceDns []string `json:"deviceDns"`

	SearchDomain string `json:"searchDomain"`
}

func GetDeviceContext

func GetDeviceContext() (*DeviceContext, error)

type Env

type Env struct {
	Name        string `json:"name"`
	TargetNs    string `json:"targetNamespace"`
	SSHPort     int    `json:"sshPort"`
	ClusterName string `json:"clusterName"`
}

func CurrentEnv

func CurrentEnv() (*Env, error)

func EnvOfPath

func EnvOfPath(pth string) (*Env, error)

type EnvType

type EnvType struct {
	Key       string  `json:"key" yaml:"key"`
	Value     *string `json:"value,omitempty" yaml:"value,omitempty"`
	ConfigRef *string `json:"configRef,omitempty" yaml:"configRef,omitempty"`
	SecretRef *string `json:"secretRef,omitempty" yaml:"secretRef,omitempty"`
	MresRef   *string `json:"mresRef,omitempty" yaml:"mresRef,omitempty"`
}

type EnvVars

type EnvVars []EnvType

func (*EnvVars) AddResTypes

func (e *EnvVars) AddResTypes(rt []ResType, rtype resType)

func (*EnvVars) GetConfigs

func (e *EnvVars) GetConfigs() []ResType

func (*EnvVars) GetEnvs

func (e *EnvVars) GetEnvs() []NormalEnv

func (*EnvVars) GetMreses

func (e *EnvVars) GetMreses() []ResType

func (*EnvVars) GetSecrets

func (e *EnvVars) GetSecrets() []ResType

type ExtraData

type ExtraData struct {
	BaseUrl      string          `json:"baseUrl"`
	SelectedEnvs map[string]*Env `json:"selectedEnvs"`
	// DeviceDns    string          `json:"deviceDns"`
	// backupDns
	BackupDns    []string `json:"dns"`
	Loading      bool     `json:"loading"`
	VpnConnected bool     `json:"vpnConnected"`

	// TODO: don't have any idea about this field, needs to remove if not required
	ActiveCluster string `json:"activeCluster"`
}

func GetExtraData

func GetExtraData() (*ExtraData, error)

type FileEntry

type FileEntry struct {
	Path string `json:"path"`
	Type CSType `json:"type"`
	Name string `json:"Name"`
	Key  string `json:"key"`
}

type InfraContext

type InfraContext struct {
	Name        string `json:"name"`
	AccountName string `json:"accountName"`
	ClusterName string `json:"ClusterName"`
	DeviceName  string `json:"deviceName"`
}

type InfraContexts

type InfraContexts struct {
	InfraContexts map[string]*InfraContext `json:"infraContexts"`
	ActiveContext string                   `json:"activeContext"`
}

type KLFileType

type KLFileType struct {
	Version    string   `json:"version" yaml:"version"`
	DefaultEnv string   `json:"defaultEnv" yaml:"defaultEnv"`
	Packages   []string `json:"packages" yaml:"packages"`

	EnvVars EnvVars `json:"envVars" yaml:"envVars"`
	Mounts  Mounts  `json:"mounts" yaml:"mounts"`

	InitScripts []string `json:"initScripts" yaml:"initScripts"`
	AccountName string   `json:"accountName" yaml:"accountName"`
}

func GetKlFile

func GetKlFile(filePath string) (*KLFileType, error)

func (*KLFileType) ParseJson

func (k *KLFileType) ParseJson(b []byte) error

func (*KLFileType) ToJson

func (k *KLFileType) ToJson() ([]byte, error)

type MainContext

type MainContext struct {
	AccountName string `json:"accountName"`
	ClusterName string `json:"clusterName"`
}

func GetMainCtx

func GetMainCtx() (*MainContext, error)

type Mount

type Mount struct {
	Path      string  `json:"path"`
	ConfigRef *string `json:"configRef,omitempty" yaml:"configRef,omitempty"`
	SecretRef *string `json:"secretRef,omitempty" yaml:"secretRef,omitempty"`
}

type Mounts

type Mounts []Mount

func (*Mounts) AddMounts

func (m *Mounts) AddMounts(fes []FileEntry)

func (*Mounts) GetMounts

func (m *Mounts) GetMounts() []FileEntry

type NormalEnv

type NormalEnv struct {
	Key   string
	Value string
}

type ResEnvType

type ResEnvType struct {
	Name   string `json:"name" yaml:"name"`
	Key    string `json:"key"`
	RefKey string `json:"refKey" yaml:"refKey"`
}

type ResType

type ResType struct {
	Name string       `json:"name"`
	Env  []ResEnvType `json:"env"`
}

type Session

type Session struct {
	Session string `json:"session"`
}

Jump to

Keyboard shortcuts

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