package io
import "github.com/containerd/containerd/pkg/cri/io"
Index ¶
- Constants
- func NewCRILogger(path string, w io.Writer, stream StreamType, maxLen int) (io.WriteCloser, <-chan struct{})
- func NewDiscardLogger() io.WriteCloser
- type AttachOptions
- type ContainerIO
- func NewContainerIO(id string, opts ...ContainerIOOpts) (_ *ContainerIO, err error)
- func (c *ContainerIO) AddOutput(name string, stdout, stderr io.WriteCloser) (io.WriteCloser, io.WriteCloser)
- func (c *ContainerIO) Attach(opts AttachOptions)
- func (c *ContainerIO) Cancel()
- func (c *ContainerIO) Close() error
- func (c *ContainerIO) Config() cio.Config
- func (c *ContainerIO) Pipe()
- func (c *ContainerIO) Wait()
- type ContainerIOOpts
- func WithFIFOs(fifos *cio.FIFOSet) ContainerIOOpts
- func WithNewFIFOs(root string, tty, stdin bool) ContainerIOOpts
- type ExecIO
- func NewExecIO(id, root string, tty, stdin bool) (*ExecIO, error)
- func (e *ExecIO) Attach(opts AttachOptions) <-chan struct{}
- func (e *ExecIO) Cancel()
- func (e *ExecIO) Close() error
- func (e *ExecIO) Config() cio.Config
- func (e *ExecIO) Wait()
- type StreamType
Constants ¶
const ( // Stdin stream type. Stdin StreamType = "stdin" // Stdout stream type. Stdout = StreamType(runtime.Stdout) // Stderr stream type. Stderr = StreamType(runtime.Stderr) )
Functions ¶
func NewCRILogger ¶
func NewCRILogger(path string, w io.Writer, stream StreamType, maxLen int) (io.WriteCloser, <-chan struct{})
NewCRILogger returns a write closer which redirect container log into log file, and decorate the log line into CRI defined format. It also returns a channel which indicates whether the logger is stopped. maxLen is the max length limit of a line. A line longer than the limit will be cut into multiple lines.
func NewDiscardLogger ¶
func NewDiscardLogger() io.WriteCloser
NewDiscardLogger creates logger which discards all the input.
Types ¶
type AttachOptions ¶
type AttachOptions struct { Stdin io.Reader Stdout io.WriteCloser Stderr io.WriteCloser Tty bool StdinOnce bool // CloseStdin is the function to close container stdin. CloseStdin func() error }
AttachOptions specifies how to attach to a container.
type ContainerIO ¶
type ContainerIO struct {
// contains filtered or unexported fields
}
ContainerIO holds the container io.
func NewContainerIO ¶
func NewContainerIO(id string, opts ...ContainerIOOpts) (_ *ContainerIO, err error)
NewContainerIO creates container io.
func (*ContainerIO) AddOutput ¶
func (c *ContainerIO) AddOutput(name string, stdout, stderr io.WriteCloser) (io.WriteCloser, io.WriteCloser)
AddOutput adds new write closers to the container stream, and returns existing write closers if there are any.
func (*ContainerIO) Attach ¶
func (c *ContainerIO) Attach(opts AttachOptions)
Attach attaches container stdio. TODO(random-liu): Use pools.Copy in docker to reduce memory usage?
func (*ContainerIO) Cancel ¶
func (c *ContainerIO) Cancel()
Cancel cancels container io.
func (*ContainerIO) Close ¶
func (c *ContainerIO) Close() error
Close closes all FIFOs.
func (*ContainerIO) Config ¶
func (c *ContainerIO) Config() cio.Config
Config returns io config.
func (*ContainerIO) Pipe ¶
func (c *ContainerIO) Pipe()
Pipe creates container fifos and pipe container output to output stream.
func (*ContainerIO) Wait ¶
func (c *ContainerIO) Wait()
Wait waits container io to finish.
type ContainerIOOpts ¶
type ContainerIOOpts func(*ContainerIO) error
ContainerIOOpts sets specific information to newly created ContainerIO.
func WithFIFOs ¶
func WithFIFOs(fifos *cio.FIFOSet) ContainerIOOpts
WithFIFOs specifies existing fifos for the container io.
func WithNewFIFOs ¶
func WithNewFIFOs(root string, tty, stdin bool) ContainerIOOpts
WithNewFIFOs creates new fifos for the container io.
type ExecIO ¶
type ExecIO struct {
// contains filtered or unexported fields
}
ExecIO holds the exec io.
func NewExecIO ¶
NewExecIO creates exec io.
func (*ExecIO) Attach ¶
func (e *ExecIO) Attach(opts AttachOptions) <-chan struct{}
Attach attaches exec stdio. The logic is similar with container io attach.
func (*ExecIO) Cancel ¶
func (e *ExecIO) Cancel()
Cancel cancels exec io.
func (*ExecIO) Close ¶
Close closes all FIFOs.
func (*ExecIO) Config ¶
Config returns io config.
func (*ExecIO) Wait ¶
func (e *ExecIO) Wait()
Wait waits exec io to finish.
type StreamType ¶
type StreamType string
StreamType is the type of the stream, stdout/stderr.
Source Files ¶
container_io.go exec_io.go helpers.go helpers_unix.go logger.go metrics.go
- Version
- v1.7.24
- Published
- Nov 21, 2024
- Platform
- js/wasm
- Imports
- 20 packages
- Last checked
- 11 minutes ago –
Tools for package owners.