containerio

package
v0.0.0-...-a79519d Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2018 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFifos

func NewFifos(id string, stdin bool) (*containerdio.FIFOSet, error)

NewFifos returns a new set of fifos for the task

func NewIOWithTerminal

func NewIOWithTerminal(stdin io.Reader, stdout, stderr io.Writer, terminal bool, stdinEnable bool) containerdio.Creation

NewIOWithTerminal creates a new io set with the provied io.Reader/Writers for use with a terminal

func Register

func Register(create func() Backend)

Register adds a backend.

func WithAttach

func WithAttach(stdin io.Reader, stdout, stderr io.Writer) containerdio.Attach

WithAttach attaches the existing io for a task to the provided io.Reader/Writers

func WithCriLogFile

func WithCriLogFile(criLogFile *os.File) func(*Option)

WithCriLogFile specified the cri log file backend.

func WithDiscard

func WithDiscard() func(*Option)

WithDiscard specified the discard backend.

func WithHijack

func WithHijack(hi http.Hijacker, upgrade bool) func(*Option)

WithHijack specified the hijack backend.

func WithID

func WithID(id string) func(*Option)

WithID specified the container's id.

func WithJSONFile

func WithJSONFile() func(*Option)

WithJSONFile specified the jsonfile backend.

func WithMuxDisabled

func WithMuxDisabled(muxDisabled bool) func(*Option)

WithMuxDisabled specified whether mux stdout & stderr of container IO.

func WithPipe

func WithPipe(pipe *io.PipeWriter) func(*Option)

WithPipe specified the pipe backend.

func WithRootDir

func WithRootDir(dir string) func(*Option)

WithRootDir specified the container's root dir.

func WithStdin

func WithStdin(stdin bool) func(*Option)

WithStdin specified whether open the container's stdin.

func WithStdinHijack

func WithStdinHijack() func(*Option)

WithStdinHijack sepcified the stdin with hijack.

func WithStdinStream

func WithStdinStream() func(*Option)

WithStdinStream specified the stdin with stream.

func WithStreams

func WithStreams(streams *remotecommand.Streams) func(*Option)

WithStreams specified the stream backend.

Types

type Backend

type Backend interface {
	// Name defines the backend's name.
	Name() string

	// Init initializes the backend io.
	Init(opt *Option) error

	// Out returns the stdout.
	Out() io.Writer

	// In returns the stdin.
	In() io.Reader

	// Err returns the stderr.
	Err() io.Writer

	// Close closes the io.
	Close() error
}

Backend defines the real output/input of the container's stdio.

type Cache

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

Cache saves the all container's io.

func NewCache

func NewCache() *Cache

NewCache creates a container's io storage.

func (*Cache) Get

func (c *Cache) Get(id string) *IO

Get reads a container's io by id.

func (*Cache) Put

func (c *Cache) Put(id string, io *IO) error

Put writes a container's io into storage.

func (*Cache) Remove

func (c *Cache) Remove(id string)

Remove removes the container's io.

type ContainerIO

type ContainerIO struct {
	Option
	// contains filtered or unexported fields
}

ContainerIO used to control the container's stdio.

func (*ContainerIO) Close

func (cio *ContainerIO) Close() error

Close implements the standard Close interface.

func (*ContainerIO) OpenStdin

func (cio *ContainerIO) OpenStdin() bool

OpenStdin returns open container's stdin or not.

func (*ContainerIO) Read

func (cio *ContainerIO) Read(p []byte) (int, error)

Read implements the standard Read interface.

func (*ContainerIO) Write

func (cio *ContainerIO) Write(data []byte) (int, error)

Write implements the standard Write interface.

type IO

type IO struct {
	Stdout *ContainerIO
	Stderr *ContainerIO
	Stdin  *ContainerIO

	// For IO backend like http, we need to mux stdout & stderr
	// if terminal is disabled.
	// But for other IO backend, it is not necessary.
	// So we should make it configurable.
	MuxDisabled bool
}

IO wraps the three container's ios of stdout, stderr, stdin.

func NewIO

func NewIO(opt *Option) *IO

NewIO creates the container's ios of stdout, stderr, stdin.

func (*IO) AddBackend

func (io *IO) AddBackend(opt *Option)

AddBackend adds more backends to container's stdio.

func (*IO) Close

func (io *IO) Close() error

Close closes the container's io.

type Option

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

Option is used to pass some data into ContainerIO.

func NewOption

func NewOption(opts ...func(*Option)) *Option

NewOption creates the Option instance.

type StreamType

type StreamType string

StreamType is the type of the stream.

const (
	// Stdin stream type.
	Stdin StreamType = "stdin"
	// Stdout stream type.
	Stdout StreamType = "stdout"
	// Stderr stream type.
	Stderr StreamType = "stderr"
)

Jump to

Keyboard shortcuts

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