exec

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommandExecutor

func NewCommandExecutor(cli client.Client, clientSet kubernetes.Interface, coreV1RestClient rest.Interface) *defaultCommandExecutor

NewCommandExecutor creates a new instance of NewCommandExecutor

func NewExecPod

func NewExecPod(
	client client.Client,
	executor commandExecutor,
	factoryMode PodVolumeMode,
	doguResource *k8sv1.Dogu,
	dogu *core.Dogu,
	podName string,
) (*execPod, error)

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

func NewExecPodFactory

func NewExecPodFactory(client client.Client, config *rest.Config, executor commandExecutor) *defaultExecPodFactory

NewExecPodFactory creates a new ExecPodFactory.

func NewPodFileExtractor

func NewPodFileExtractor(k8sClient client.Client, restConfig *rest.Config, clientSet kubernetes.Interface) *podFileExtractor

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

Types

type CommandExecutor

type CommandExecutor struct {
	mock.Mock
}

CommandExecutor is an autogenerated mock type for the CommandExecutor type

func NewCommandExecutorMock

func NewCommandExecutorMock(t mockConstructorTestingTNewCommandExecutor) *CommandExecutor

NewCommandExecutor creates a new instance of CommandExecutor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*CommandExecutor) ExecCommandForDogu

func (_m *CommandExecutor) ExecCommandForDogu(ctx context.Context, resource *v1.Dogu, command *ShellCommand, expectedStatus PodStatus) (*bytes.Buffer, error)

ExecCommandForDogu provides a mock function with given fields: ctx, resource, command, expectedStatus

func (*CommandExecutor) ExecCommandForPod

func (_m *CommandExecutor) ExecCommandForPod(ctx context.Context, pod *corev1.Pod, command *ShellCommand, expectedStatus PodStatus) (*bytes.Buffer, error)

ExecCommandForPod provides a mock function with given fields: ctx, pod, command, expectedStatus

type ExecPod

type ExecPod interface {
	// Create adds a new exec pod to the cluster.
	Create(ctx context.Context) error
	// Delete deletes the exec pod from the cluster.
	Delete(ctx context.Context) error
	// PodName returns the name of the pod.
	PodName() string
	// ObjectKey returns the ExecPod's K8s object key.
	ObjectKey() *client.ObjectKey
	// Exec runs the provided command in this execPod
	Exec(ctx context.Context, cmd *ShellCommand) (out string, err error)
}

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

type ExecPodMock

type ExecPodMock struct {
	mock.Mock
}

ExecPodMock is an autogenerated mock type for the ExecPod type

func NewExecPodMock

func NewExecPodMock(t mockConstructorTestingTNewExecPod) *ExecPodMock

NewExecPod creates a new instance of ExecPod. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*ExecPodMock) Create

func (_m *ExecPodMock) Create(ctx context.Context) error

Create provides a mock function with given fields: ctx

func (*ExecPodMock) Delete

func (_m *ExecPodMock) Delete(ctx context.Context) error

Delete provides a mock function with given fields: ctx

func (*ExecPodMock) Exec

func (_m *ExecPodMock) Exec(ctx context.Context, cmd *ShellCommand) (string, error)

Exec provides a mock function with given fields: ctx, cmd

func (*ExecPodMock) ObjectKey

func (_m *ExecPodMock) ObjectKey() *types.NamespacedName

ObjectKey provides a mock function with given fields:

func (*ExecPodMock) PodName

func (_m *ExecPodMock) PodName() string

PodName provides a mock function with given fields:

type PodStatus

type PodStatus string

PodStatus describes a state in the lifecycle of a pod.

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

type PodVolumeMode

type PodVolumeMode int

PodVolumeMode indicates whether to mount a dogu's PVC (which only makes sense when the dogu was already installed).

const (
	// PodVolumeModeInstall indicates to not mount a dogu's PVC.
	PodVolumeModeInstall PodVolumeMode = iota
	// PodVolumeModeUpgrade indicates to mount a dogu's PVC.
	PodVolumeModeUpgrade
)

type ShellCommand

type ShellCommand struct {
	// Command states the actual executable that is supposed to be executed in the container.
	Command string
	// Args contains any parameters, switches etc. that the command needs to run properly.
	Args []string
}

ShellCommand represents all necessary arguments to execute a command inside a container.

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 (*ShellCommand) String

func (sc *ShellCommand) String() string

type SuffixGenerator

type SuffixGenerator struct {
	mock.Mock
}

SuffixGenerator is an autogenerated mock type for the SuffixGenerator type

func NewSuffixGeneratorMock

func NewSuffixGeneratorMock(t mockConstructorTestingTNewSuffixGenerator) *SuffixGenerator

NewSuffixGenerator creates a new instance of SuffixGenerator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*SuffixGenerator) String

func (_m *SuffixGenerator) String(length int) string

String provides a mock function with given fields: length

Jump to

Keyboard shortcuts

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