transfer

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package transfer defines transfer types for container filesystem operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContainerFSTransferrer

func NewContainerFSTransferrer(ctrFS ContainerFS) ctransfer.Transferrer

NewContainerFSTransferrer returns a Transferrer that handles ContainerPath + ReadStream/WriteStream transfer pairs, running archive operations inside the container's filesystem via ctrFS.

func NewEchoTransferrer

func NewEchoTransferrer() ctransfer.Transferrer

NewEchoTransferrer returns a Transferrer that copies data from a ReadStream source to a WriteStream destination. This is useful for testing the streaming pipeline end-to-end.

Types

type ContainerFS added in v0.2.6

type ContainerFS interface {
	Do(containerID string, fn func() error) error
}

ContainerFS runs an operation with a container's filesystem as the root directory.

The operation must see the container's own view, with its mounts applied. The bundle's rootfs directory is not that view: the runtime applies the container's mounts inside the container's mount namespace, so in the bundle rootfs every mount destination is an empty directory shadowing the content the container actually sees. Copying through those shadowed entries writes files the container will never observe and reads content the container does not have.

Implementations confine the operation to the container's filesystem, so paths cannot reach anything outside it.

type ContainerPath

type ContainerPath struct {
	ContainerID       string
	Path              string
	NoWalk            bool
	PreserveOwnership bool
}

ContainerPath represents a path within a running container's filesystem. It acts as either a source or destination in a transfer operation, identifying the container and path for archive operations.

func (*ContainerPath) MarshalAny

func (cf *ContainerPath) MarshalAny(ctx context.Context, sm streaming.StreamCreator) (typeurl.Any, error)

MarshalAny marshals the ContainerPath to a typeurl.Any.

func (*ContainerPath) UnmarshalAny

func (cf *ContainerPath) UnmarshalAny(ctx context.Context, sg streaming.StreamGetter, a typeurl.Any) error

UnmarshalAny unmarshals a ContainerPath from a typeurl.Any.

type ReadStream

type ReadStream struct {
	MediaType string
	// contains filtered or unexported fields
}

ReadStream carries data from the client to the server (import direction). The client sends data through the stream and the server reads it.

func NewReadStream

func NewReadStream(r io.Reader, mediaType string) *ReadStream

NewReadStream creates a ReadStream that will send data from r to the server during marshaling.

func (*ReadStream) Close added in v0.2.6

func (s *ReadStream) Close() error

Close releases the stream without consuming it, so that a client sending on it is not left waiting when the transfer cannot be carried out.

The stream is established while the request is being unmarshalled, before any transferrer sees it, so a transfer that fails before reading has to release it explicitly. Close is safe to call once the stream has been read: consuming it closes the stream too, and the transport tolerates the second close.

func (*ReadStream) MarshalAny

func (s *ReadStream) MarshalAny(ctx context.Context, sm streaming.StreamCreator) (typeurl.Any, error)

MarshalAny marshals the ReadStream, creating a streaming connection and starting a goroutine that sends data from the reader.

func (*ReadStream) Reader

func (s *ReadStream) Reader(ctx context.Context) io.Reader

Reader returns an io.Reader that consumes data sent by the client.

func (*ReadStream) UnmarshalAny

func (s *ReadStream) UnmarshalAny(ctx context.Context, sg streaming.StreamGetter, a typeurl.Any) error

UnmarshalAny unmarshals a ReadStream from a typeurl.Any, recovering the stream from the StreamGetter.

type WriteStream

type WriteStream struct {
	MediaType string
	// contains filtered or unexported fields
}

WriteStream carries data from the server to the client (export direction). The server writes data into the stream and the client receives it.

func NewWriteStream

func NewWriteStream(w io.WriteCloser, mediaType string) *WriteStream

NewWriteStream creates a WriteStream that will receive data from the server into w during marshaling.

func (*WriteStream) Close added in v0.2.6

func (s *WriteStream) Close() error

Close releases the stream without writing to it, so that a client waiting to receive is not left waiting when the transfer cannot be carried out.

The stream is established while the request is being unmarshalled, before any transferrer sees it, so a transfer that fails before writing has to release it explicitly. Close is safe to call once the stream has been written: closing the writer closes the stream too, and the transport tolerates the second close.

func (*WriteStream) MarshalAny

func (s *WriteStream) MarshalAny(ctx context.Context, sm streaming.StreamCreator) (typeurl.Any, error)

MarshalAny marshals the WriteStream, creating a streaming connection and starting a goroutine that receives data into the writer.

func (*WriteStream) UnmarshalAny

func (s *WriteStream) UnmarshalAny(ctx context.Context, sg streaming.StreamGetter, a typeurl.Any) error

UnmarshalAny unmarshals a WriteStream from a typeurl.Any, recovering the stream from the StreamGetter.

func (*WriteStream) Writer

func (s *WriteStream) Writer(ctx context.Context) io.WriteCloser

Writer returns an io.WriteCloser that sends data to the client.

Jump to

Keyboard shortcuts

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