helpers

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Overview

Package helpers offers functions to simplify dealing with kubernetes resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Helpers

type Helpers interface {
	JobHelper
	PodHelper
	ServiceHelper
}

Helpers offers Helper functions grouped by the objects they handle

func NewHelper

func NewHelper(
	ctx context.Context,
	clientset k8s.Interface,
	client *resources.Client,
	config *rest.Config,
	namespace string,
) Helpers

NewHelper creates a set of helper functions on the specified namespace

type JobHelper added in v0.4.0

type JobHelper interface {
	// WaitJobCompleted waits for the Job to be completed for up to the given timeout (in seconds) and returns
	// a boolean indicating if the status was reached. If the job is Failed an error is returned.
	WaitJobCompleted(name string, timeout uint) (bool, error)
}

JobHelper defines helper functions for manipulating Jobs

type PodExecOptions added in v0.4.0

type PodExecOptions struct {
	Pod       string   // name of the Pod to execute the command in
	Container string   // name of the container to execute the command in
	Command   []string // command to be executed with its parameters
	Stdin     []byte   // stdin to be supplied to the command
	Timeout   uint     // number of seconds allowed to wait for completion
}

PodExecOptions describe the command to be executed and the target container

type PodExecResult added in v0.4.0

type PodExecResult struct {
	Stdout []byte
	Stderr []byte
}

PodExecResult contains the output obtained from the execution of a command

type PodHelper

type PodHelper interface {
	// ExecuteInPod executes a non-interactive command described in options and returns the stdout and stderr outputs
	ExecuteInPod(options PodExecOptions) (*PodExecResult, error)
	// WaitPodRunning waits for the Pod to be running for up to given timeout (in seconds) and returns
	// a boolean indicating if the status was reached. If the pod is Failed returns error.
	WaitPodRunning(name string, timeout uint) (bool, error)
}

PodHelper defines helper functions for manipulating Pods

type ServiceHelper

type ServiceHelper interface {
	// WaitServiceReady waits for the given service to have at least one endpoint available
	// or the timeout (in seconds) expires. It returns a boolean indicating if the service is ready
	WaitServiceReady(service string, timeout uint) (bool, error)
	// GetExternalIP returns one external ip for the given service. If none is assigned after the timeout
	// expires, returns an empty address "".
	GetExternalIP(service string, timeout uint) (string, error)
}

ServiceHelper implements functions for dealing with services

Jump to

Keyboard shortcuts

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