Help us shape the future of Go! Take the 2026 Go Developer Survey

kubernetes

package
v2.37.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FakeNewSPDYExecutor = func(_ *rest.Config, method string, url *url.URL) (remotecommand.Executor, error) {
	return &FakeExecutor{method: method, url: url}, nil
}

FakeNewSPDYExecutor can be used for unit testing. Current this will do nothing and will be extended in the future.

View Source
var NewSPDYExecutor = remotecommand.NewSPDYExecutor

NewSPDYExecutor defines the NewSPDYExecutor method used for this package. For normal code you don't have to change it. For unit testing you can set NewSPDYExecutor = FakeNewSPDYExecutor.

Functions

func DownloadFile

func DownloadFile(
	ctx context.Context,
	kubeClient client.Client,
	config *rest.Config,
	target *corev1.Pod,
	container string,
	src string,
	dst io.Writer) error

DownloadFile will download the file from the provided Pod/container into dst.

func ExecuteCommand

func ExecuteCommand(
	ctx context.Context,
	kubeClient client.Client,
	config *rest.Config,
	namespace string,
	name string,
	container string,
	command string,
	printOutput bool,
) (string, string, error)

ExecuteCommand executes command in the default container of a Pod with shell, returns stdout and stderr.

func ExecuteCommandOnPod

func ExecuteCommandOnPod(
	ctx context.Context,
	kubeClient client.Client,
	config *rest.Config,
	pod *corev1.Pod,
	container string,
	command string,
	printOutput bool,
) (string, string, error)

ExecuteCommandOnPod runs a command on the provided Pod. The command will be executed inside a bash -c ”.

func ExecuteCommandRaw

func ExecuteCommandRaw(
	ctx context.Context,
	kubeClient client.Client,
	config *rest.Config,
	namespace string,
	name string,
	container string,
	command []string,
	stdin io.Reader,
	stdout io.Writer,
	stderr io.Writer,
	isTty bool,
) error

ExecuteCommandRaw will run the command without putting it into a shell.

func GetLogsFromPod

func GetLogsFromPod(
	ctx context.Context,
	kubeClient client.Client,
	config *rest.Config,
	pod *corev1.Pod,
	container string,
	since *int64) (string, error)

GetLogsFromPod will fetch the logs for the specified Pod and container since the provided seconds.

func PickRandomPod

func PickRandomPod(pods *corev1.PodList) (*corev1.Pod, error)

PickRandomPod will return a random Pod from the provided list

func UploadFile

func UploadFile(
	ctx context.Context,
	kubeClient client.Client,
	config *rest.Config,
	target *corev1.Pod,
	container string,
	src io.Reader,
	dst string) error

UploadFile uploads a file from src into the Pod/container dst.

Types

type FakeExecutor

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

FakeExecutor used for unit testing.

func (*FakeExecutor) Stream

func (fakeExecutor *FakeExecutor) Stream(options remotecommand.StreamOptions) error

Stream opens a protocol streamer to the server and streams until a client closes the connection or the server disconnects.

func (*FakeExecutor) StreamWithContext

func (fakeExecutor *FakeExecutor) StreamWithContext(
	_ context.Context,
	options remotecommand.StreamOptions,
) error

StreamWithContext opens a protocol streamer to the server and streams until a client closes the connection or the server disconnects or the context is done.

Jump to

Keyboard shortcuts

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