cmd

package
v0.0.0-...-49fa6d7 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout    = errors.New("timeout")
	ErrUnexpected = errors.New("unexpected data")
)

Functions

func PodWrite

func PodWrite(pod *corev1.Pod, container, filename string, data []byte) error

PodWrite is a shortcut for NewPodWriter(), Write(), Close()

func PodWriter

func PodWriter(pod *corev1.Pod, container, filename string) (io.WriteCloser, error)

PodWriter returns an io.WriteCloser that appends to a file in a pod container.

Types

type Reader

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

Reader reads from a running exec.Cmd.

func FileReader

func FileReader(pod *corev1.Pod, path string) (*Reader, error)

FileReader returns a CmdReader that reads the current contents of path on pod.file

It returns io.EOF at the end of the file.

func NewReader

func NewReader(cmd *exec.Cmd) (*Reader, error)

NewReader starts an exec.Cmd and returns a Reader for its stdout.

func TailReader

func TailReader(pod *corev1.Pod, path string) (*Reader, error)

TailReader returns a CmdReader that tails file at path on pod.

It uses "tail -F" which will wait for the file to exist if it does not, and will wait for it to be re-created if it is deleted. It will continue to tail until Close() is called.

func TailReaderForContainer

func TailReaderForContainer(pod *corev1.Pod, containerName, path string) (*Reader, error)

TailReaderForContainer returns a CmdReader that tails file at path on pod.

It uses "tail -F" which will wait for the file to exist if it does not, and will wait for it to be re-created if it is deleted. It will continue to tail until Close() is called.

func (*Reader) Close

func (r *Reader) Close() error

Close kills the underlying process, if running. This closes the stdout pipe, so Read or ReadLine will return an error. Returns the error returned by the sub-process.

func (*Reader) Read

func (r *Reader) Read(b []byte) (int, error)

Read is the usual io.Reader, no timeout.

func (*Reader) ReadLine

func (r *Reader) ReadLine() (string, error)

ReadLine reads a line of text (with newline) as a string. Times out after test.DefaultSuccessTimeout.

func (*Reader) ReadLineContext

func (r *Reader) ReadLineContext(ctx context.Context) (string, error)

ReadLineContext returns on success or when the context is cancelled or times out.

type Writer

type Writer struct {
	io.WriteCloser // Pipe to stdin
	*exec.Cmd
	// contains filtered or unexported fields
}

Writer writes to stdin of a running exec.Cmd.

func NewWriter

func NewWriter(cmd *exec.Cmd) (*Writer, error)

NewWriter starts an exec.Cmd and returns an io.WriteCloser for its stdin.

func (*Writer) Close

func (w *Writer) Close() error

Close the writer's stdin and wait for its command to exit.

Jump to

Keyboard shortcuts

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