containerio

package
v0.0.0-...-2812ca0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(create func() Backend)

Register adds a backend.

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 WithMemBuffer

func WithMemBuffer(memBuffer *bytes.Buffer) func(*Option)

WithMemBuffer specified the memory buffer backend.

func WithRawFile

func WithRawFile() func(*Option)

WithRawFile specified the raw-file backend.

func WithRootDir

func WithRootDir(dir string) func(*Option)

WithRootDir specified the container's root dir.

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
}

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