exec

package
v3.29.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewShellCommand

func NewShellCommand(command string, args ...string) *shellCommand

NewShellCommand creates a new ShellCommand. While the command is mandatory, there can be zero to n command arguments.

func NewShellCommandWithStdin

func NewShellCommandWithStdin(stdin io.Reader, command string, args ...string) *shellCommand

Types

type CommandExecutor

type CommandExecutor interface {
	// ExecCommandForDogu executes a command in a dogu.
	ExecCommandForDogu(ctx context.Context, resource *k8sv2.Dogu, command ShellCommand) (*bytes.Buffer, error)
	// ExecCommandForPod executes a command in a pod that must not necessarily be a dogu.
	ExecCommandForPod(ctx context.Context, pod *corev1.Pod, command ShellCommand) (*bytes.Buffer, error)
}

CommandExecutor is used to execute commands in pods and dogus

func NewCommandExecutor

func NewCommandExecutor(cli client.Client, restConfig *rest.Config, clientSet kubernetes.Interface, coreV1RestClient rest.Interface) CommandExecutor

NewCommandExecutor creates a new instance of NewCommandExecutor

type ExecPodFactory

type ExecPodFactory interface {
	// CreateBlocking adds a new exec pod to the cluster and waits for its creation.
	// Deprecated, as we don't want our code to block.
	CreateBlocking(ctx context.Context, doguResource *k8sv2.Dogu, dogu *core.Dogu) error
	// Create adds a new exec pod to the cluster.
	Create(ctx context.Context, doguResource *k8sv2.Dogu, dogu *core.Dogu) error
	Exists(ctx context.Context, doguResource *k8sv2.Dogu, dogu *core.Dogu) bool
	CheckReady(ctx context.Context, doguResource *k8sv2.Dogu, dogu *core.Dogu) error
	// Delete deletes the exec pod from the cluster.
	Delete(ctx context.Context, doguResource *k8sv2.Dogu, dogu *core.Dogu) error
	// Exec runs the provided command in this execPodFactory
	Exec(ctx context.Context, doguResource *k8sv2.Dogu, dogu *core.Dogu, cmd ShellCommand) (out *bytes.Buffer, err error)
}

ExecPodFactory provides methods for instantiating and removing an intermediate pod based on a Dogu container image.

func NewExecPodFactory

func NewExecPodFactory(
	client client.Client,
	executor CommandExecutor,
) ExecPodFactory

NewExecPodFactory creates a new ExecPod that enables command execution towards a pod.

type FileExtractor

type FileExtractor interface {
	// ExtractK8sResourcesFromExecPod copies files from an exec pod into map of strings.
	ExtractK8sResourcesFromExecPod(ctx context.Context, doguResource *k8sv2.Dogu, dogu *core.Dogu) (map[string]string, error)
}

FileExtractor provides functionality to get the contents of files from an exec pod.

func NewPodFileExtractor

func NewPodFileExtractor(factory ExecPodFactory) FileExtractor

NewPodFileExtractor creates a new pod file extractor that fetches files from a pod's container.

type PodStatusForExec

type PodStatusForExec string

PodStatusForExec describes a state in the lifecycle of a pod.

const (
	// ContainersStarted means that all containers of a pod were started.
	ContainersStarted PodStatusForExec = "started"
	// PodReady means that the readiness probe of the pod has succeeded.
	PodReady PodStatusForExec = "ready"
)

type ShellCommand

type ShellCommand interface {
	// CommandWithArgs returns the commands and its arguments in a way suitable for execution.
	CommandWithArgs() []string
	// Stdin returns the appropriate reader for standard input.
	Stdin() io.Reader
}

ShellCommand represents a command that can be executed in the shell of a container.

Jump to

Keyboard shortcuts

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