remote_development

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetadataRemoteDevPrefix    = "remote-dev.bunnyshell.com/"
	MetadataRemoteDevEnabled   = MetadataRemoteDevPrefix + "enabled"
	MetadataRemoteDevComponent = MetadataRemoteDevPrefix + "component"
	MetadataRemoteDevContainer = MetadataRemoteDevPrefix + "container"

	// todo this should match the secret name that remote development start api is looking for
	SecretNamePattern = "%s-remote-dev"
	// todo this should match the pvc name that remote development start api created
	PVCName = "%s-remote-dev"

	SecretCertKeyName           = "cert.pem"
	SecretKeyKeyName            = "key.pem"
	SecretConfigKeyName         = "config.xml"
	SecretAuthorizedKeysKeyName = "authorized_keys"

	PortForwardMethod    = "POST"
	PortForwardInterface = "127.0.0.1"
	SSHRemotePort        = 2222
)
View Source
const (
	PrivateKeyFilename = "id_rsa"
	PublicKeyFilename  = "id_rsa.pub"

	SyncthingRemoteInterface = "127.0.0.1"
	SyncthingRemotePort      = 22000
)
View Source
const (
	SyncthingVersion             = "v1.20.4"
	SyncthingLocalConfigDirname  = "syncthing-local"
	SyncthingRemoteConfigDirname = "syncthing-remote"
)
View Source
const (
	KubeConfigFilename = "kube-config.yaml"
)

Variables

View Source
var (
	ErrNoEnvironments           = fmt.Errorf("no environments available")
	ErrNoOrganizations          = fmt.Errorf("no organizations available")
	ErrNoComponents             = fmt.Errorf("no components available")
	ErrNoComponentsWithSyncPath = fmt.Errorf("no components with remote sync path set")
	ErrNoProjects               = fmt.Errorf("no projects available")
)

Functions

This section is empty.

Types

type ComponentItem

type ComponentItem interface {
	GetId() string
	GetName() string
	GetSyncPath() string
}

type KubernetesClient

type KubernetesClient struct {
	Config     clientcmd.ClientConfig
	RESTConfig *rest.Config
	ClientSet  *kubernetes.Clientset

	SSHPortForwardOptions *PortForwardOptions
}

func NewKubernetesClient

func NewKubernetesClient(kubeConfigPath string) (*KubernetesClient, error)

func (*KubernetesClient) DeletePVC

func (k *KubernetesClient) DeletePVC(name string) error

func (*KubernetesClient) GetComponentPod

func (k *KubernetesClient) GetComponentPod(componentName string) (coreV1.Pod, error)

func (*KubernetesClient) GetDeployment

func (k *KubernetesClient) GetDeployment(name string) (*appsV1.Deployment, error)

func (*KubernetesClient) GetDeploymentContainers

func (k *KubernetesClient) GetDeploymentContainers(name string) ([]coreV1.Container, error)

func (*KubernetesClient) GetPortForwardSubresourceURL

func (k *KubernetesClient) GetPortForwardSubresourceURL(pod coreV1.Pod) *url.URL

func (*KubernetesClient) PortForwardRemoteSSH

func (k *KubernetesClient) PortForwardRemoteSSH(componentName string) (*portforward.PortForwarder, error)

func (*KubernetesClient) WatchRemoteDevPods

func (k *KubernetesClient) WatchRemoteDevPods(componentName, containerName string) error

type PortForwardOptions

type PortForwardOptions struct {
	Interface string

	RemotePort int
	LocalPort  int

	StopChannel  chan struct{}
	ReadyChannel chan struct{}
}

func NewPortForwardOptions

func NewPortForwardOptions() *PortForwardOptions

type RemoteDevelopment

type RemoteDevelopment struct {
	SSHPrivateKeyPath  string
	SSHPublicKeyPath   string
	RemoteSSHForwarder *portforward.PortForwarder
	SyncthingSSHTunnel *ssh.SSHTunnel

	SyncthingProcess *os.Process

	OrganizationId string
	ProjectId      string
	EnvironmentId  string

	LocalSyncPath  string
	RemoteSyncPath string

	ComponentId         string
	ComponentName       string
	ComponentFolderPath string

	KubeConfigPath   string
	KubernetesClient *KubernetesClient
	ContainerName    string

	StopChannel chan bool
}

func NewRemoteDevelopment

func NewRemoteDevelopment() *RemoteDevelopment

func (*RemoteDevelopment) Close

func (r *RemoteDevelopment) Close()

func (*RemoteDevelopment) CloseOnSignal

func (r *RemoteDevelopment) CloseOnSignal(signals chan os.Signal)

func (*RemoteDevelopment) DeleteRemoteDevK8sPVC

func (r *RemoteDevelopment) DeleteRemoteDevK8sPVC() error

func (*RemoteDevelopment) EnsureComponentFolder

func (r *RemoteDevelopment) EnsureComponentFolder() error

func (*RemoteDevelopment) EnsureEnvironmentKubeConfig

func (r *RemoteDevelopment) EnsureEnvironmentKubeConfig() error

func (*RemoteDevelopment) EnsureRemoteDevK8sSecret

func (r *RemoteDevelopment) EnsureRemoteDevK8sSecret() error

func (*RemoteDevelopment) EnsureRemoteSSHPortForward

func (r *RemoteDevelopment) EnsureRemoteSSHPortForward() error

func (*RemoteDevelopment) EnsureSSHConfigEntry

func (r *RemoteDevelopment) EnsureSSHConfigEntry() error

func (*RemoteDevelopment) EnsureSSHKeys

func (r *RemoteDevelopment) EnsureSSHKeys() error

func (*RemoteDevelopment) EnsureSyncthingPortForward

func (r *RemoteDevelopment) EnsureSyncthingPortForward() error

func (*RemoteDevelopment) PrepareSyncthing

func (r *RemoteDevelopment) PrepareSyncthing() error

func (*RemoteDevelopment) SelectComponent

func (r *RemoteDevelopment) SelectComponent(defaultComponentId string) error

func (*RemoteDevelopment) SelectContainer

func (r *RemoteDevelopment) SelectContainer() error

func (*RemoteDevelopment) SelectEnvironment

func (r *RemoteDevelopment) SelectEnvironment(defaultEnvironmentId string) error

func (*RemoteDevelopment) SelectLocalSyncFolder

func (r *RemoteDevelopment) SelectLocalSyncFolder(defaultLocalSyncPath string) error

func (*RemoteDevelopment) SelectOrganization

func (r *RemoteDevelopment) SelectOrganization(defaultOrganizationId string) error

func (*RemoteDevelopment) SelectProject

func (r *RemoteDevelopment) SelectProject(defaultProjectId string) error

func (*RemoteDevelopment) StartLocalSyncthing

func (r *RemoteDevelopment) StartLocalSyncthing() error

@todo add restart/stop management

func (*RemoteDevelopment) StartRemoteDevelopment

func (r *RemoteDevelopment) StartRemoteDevelopment() error

func (*RemoteDevelopment) StartSSHTerminal

func (r *RemoteDevelopment) StartSSHTerminal() error

func (*RemoteDevelopment) StopRemoteDevelopment

func (r *RemoteDevelopment) StopRemoteDevelopment() error

func (*RemoteDevelopment) UpdateLocalSyncthingConfig

func (r *RemoteDevelopment) UpdateLocalSyncthingConfig() error

func (*RemoteDevelopment) Wait

func (r *RemoteDevelopment) Wait()

func (*RemoteDevelopment) WithComponent

func (r *RemoteDevelopment) WithComponent(component ComponentItem) *RemoteDevelopment

func (*RemoteDevelopment) WithKubernetesClient

func (r *RemoteDevelopment) WithKubernetesClient(kubeConfigPath string) *RemoteDevelopment

func (*RemoteDevelopment) WithSSH

func (r *RemoteDevelopment) WithSSH(sshPrivateKeyPath, sshPublicKeyPath string) *RemoteDevelopment

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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