environment

package
v0.0.0-...-53f4a92 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListEnvironments

func ListEnvironments(logger *zap.SugaredLogger, tableData pterm.TableData) (pterm.TableData, error)

List Environments in available contexts

func SwitchContext

func SwitchContext(name string) (err error)

Types

type Environment

type Environment struct {
	// contains filtered or unexported fields
}

func New

func New(engine string, name string) *Environment

New Environment entity

func (*Environment) CopyEnvironment

func (e *Environment) CopyEnvironment(ctx context.Context, logger *zap.SugaredLogger, source string, destination string) error

Copy Environment from source to destination contexts

func (*Environment) Create

func (e *Environment) Create(ctx context.Context, logger *zap.SugaredLogger) error

Create environment

func (*Environment) CreateK3dEnvironment

func (e *Environment) CreateK3dEnvironment(logger *zap.SugaredLogger) (string, error)

func (*Environment) CreateK3sDockerEnvironment

func (e *Environment) CreateK3sDockerEnvironment(logger *zap.SugaredLogger) (_ string, retErr error)

CreateK3sDockerEnvironment creates a k3s cluster running inside a Docker container using the Docker Go client directly (no external CLI required).

func (*Environment) CreateK3sEnvironment

func (e *Environment) CreateK3sEnvironment(logger *zap.SugaredLogger) (string, error)

func (*Environment) CreateKindEnvironment

func (e *Environment) CreateKindEnvironment(logger *zap.SugaredLogger) (string, error)

func (*Environment) CreateNode

func (e *Environment) CreateNode(ctx context.Context, nodeName string, scopes []string, taints []string, remote *SSHClient, logger *zap.SugaredLogger) error

CreateNode creates a new K3s agent node as a Docker container that joins the existing K3s server for this environment. Only supported for the k3s-docker engine. When remote is non-nil, the Docker container is created on the remote host via SSH.

func (*Environment) Delete

func (e *Environment) Delete(f bool, logger *zap.SugaredLogger) error

Delete environment cluster

func (*Environment) DeleteK3dEnvironment

func (e *Environment) DeleteK3dEnvironment(logger *zap.SugaredLogger) error

func (*Environment) DeleteK3sDockerEnvironment

func (e *Environment) DeleteK3sDockerEnvironment(logger *zap.SugaredLogger) error

DeleteK3sDockerEnvironment stops and removes the k3s-docker server and all agent node containers for this environment.

func (*Environment) DeleteK3sEnvironment

func (e *Environment) DeleteK3sEnvironment(logger *zap.SugaredLogger) error

func (*Environment) DeleteKindEnvironment

func (e *Environment) DeleteKindEnvironment(logger *zap.SugaredLogger) error

func (*Environment) DeleteNode

func (e *Environment) DeleteNode(ctx context.Context, nodeName string, scopes []string, remote *SSHClient, logger *zap.SugaredLogger) error

DeleteNode stops and removes the K3s agent node container. When the engine scope was applied, this also clears nodeSelector and tolerations from engine-related Helm charts. Only supported for the k3s-docker engine. When remote is non-nil, the Docker container is removed on the remote host via SSH.

func (*Environment) GetContextName

func (e *Environment) GetContextName() string

Get contect name specially for engine

func (*Environment) K3dContextName

func (e *Environment) K3dContextName() string

func (*Environment) K3sContextName

func (e *Environment) K3sContextName() string

func (*Environment) K3sDockerContextName

func (e *Environment) K3sDockerContextName() string

K3sDockerContextName returns the kubeconfig context name for this engine.

func (*Environment) KindContextName

func (e *Environment) KindContextName() string

func (*Environment) Setup

func (e *Environment) Setup(ctx context.Context, logger *zap.SugaredLogger) error

Setup environment

func (*Environment) Start

func (e *Environment) Start(ctx context.Context, switcher bool, logger *zap.SugaredLogger) error

Start Environment

func (*Environment) Stop

func (e *Environment) Stop(ctx context.Context, logger *zap.SugaredLogger) error

Stop Environment

func (*Environment) Upgrade

func (e *Environment) Upgrade(ctx context.Context, logger *zap.SugaredLogger) error

Upgrade environment with options or new features

func (*Environment) WithAdminServiceAccount

func (e *Environment) WithAdminServiceAccount(create bool, name string) *Environment

func (*Environment) WithConfigurations

func (e *Environment) WithConfigurations(configurations []string) *Environment

func (*Environment) WithContext

func (e *Environment) WithContext(context string) *Environment

func (*Environment) WithCpu

func (e *Environment) WithCpu(cpu string) *Environment

func (*Environment) WithDisabledPorts

func (e *Environment) WithDisabledPorts(disablePorts bool) *Environment

func (*Environment) WithEngineConfig

func (e *Environment) WithEngineConfig(engineConfig string) *Environment

func (*Environment) WithFunctions

func (e *Environment) WithFunctions(functions []string) *Environment

func (*Environment) WithHttpPort

func (e *Environment) WithHttpPort(port int) *Environment

func (*Environment) WithHttpsPort

func (e *Environment) WithHttpsPort(port int) *Environment

func (*Environment) WithMaxReconcileRate

func (e *Environment) WithMaxReconcileRate(rate int) *Environment

func (*Environment) WithMounts

func (e *Environment) WithMounts(mounts []string) *Environment

func (*Environment) WithProviders

func (e *Environment) WithProviders(providers []string) *Environment

type EnvironmentOptions

type EnvironmentOptions struct {
	// contains filtered or unexported fields
}

type KindCluster

type KindCluster struct {
	Kind       string     `yaml:"kind"`
	APIVersion string     `yaml:"apiVersion"`
	Nodes      []KindNode `yaml:"nodes"`
}

type KindMount

type KindMount struct {
	HostPath      string `yaml:"hostPath"`
	ContainerPath string `yaml:"containerPath"`
}

type KindNode

type KindNode struct {
	Role                 string            `yaml:"role"`
	ExtraMounts          []KindMount       `yaml:"extraMounts,omitempty"`
	KubeadmConfigPatches []string          `yaml:"kubeadmConfigPatches,omitempty"`
	ExtraPortMappings    []KindPortMapping `yaml:"extraPortMappings,omitempty"`
}

type KindPortMapping

type KindPortMapping struct {
	ContainerPort int    `yaml:"containerPort"`
	HostPort      int    `yaml:"hostPort"`
	Protocol      string `yaml:"protocol"`
}

type SSHClient

type SSHClient struct {
	Host string
	User string
	Port int
	Key  string // path to private key
	// contains filtered or unexported fields
}

SSHClient wraps an SSH connection to a remote host for executing Docker commands remotely.

func NewSSHClient

func NewSSHClient(host, user string, port int, keyPath string) (*SSHClient, error)

NewSSHClient creates and connects an SSH client to the remote host. If keyPath is empty, ~/.ssh/id_rsa is used.

func (*SSHClient) Close

func (s *SSHClient) Close()

Close closes the underlying SSH connection.

func (*SSHClient) Run

func (s *SSHClient) Run(cmd string) (string, error)

Run executes a command on the remote host and returns its combined output.

func (*SSHClient) RunWithStdin

func (s *SSHClient) RunWithStdin(cmd, stdin string) (string, error)

RunWithStdin executes a command on the remote host, writing stdin as input, and returns the combined output. Used to send shell scripts to remote Docker containers via: docker run --rm -i ... sh

Jump to

Keyboard shortcuts

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