client

package
v0.0.0-...-6c8c028 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package client is a containerz grpc client.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNotFound indicates that the specified image was not found on the target system.
	ErrNotFound = status.Error(codes.NotFound, "resource was not found")

	// ErrRunning indicates that there is a container running this image.
	ErrRunning = status.Error(codes.FailedPrecondition, "resource is running")
)
View Source
var (
	// Dial is the dailer to use to read containerz
	Dial = grpc.DialContext
)

Functions

This section is empty.

Types

type Client

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

Client is a grpc containerz client.

func NewClient

func NewClient(ctx context.Context, addr string) (*Client, error)

NewClient builds a new containerz client.

func NewClientWithConn

func NewClientWithConn(conn *grpc.ClientConn) *Client

NewClientWithConn creates a client given a ClientConn.

func (*Client) CreateVolume

func (c *Client) CreateVolume(ctx context.Context, name, driver string, labels, options map[string]string) (string, error)

CreateVolume creates a volume. If the name is empty, the target system will create one. The driver default to the target defined option.

func (*Client) ListContainer

func (c *Client) ListContainer(ctx context.Context, all bool, limit int32, filter map[string][]string) (<-chan *ContainerInfo, error)

ListContainer implements the client logic for listing the existing containers on the target system.

func (*Client) ListImage

func (c *Client) ListImage(ctx context.Context, limit int32, filter map[string][]string) (<-chan *ImageInfo, error)

ListImage implements the client logic for listing the existing images on the target system.

func (*Client) ListPlugin

func (c *Client) ListPlugin(ctx context.Context, instance string) ([]*cpb.Plugin, error)

ListPlugin lists the plugins present on the target.

func (*Client) ListVolume

func (c *Client) ListVolume(ctx context.Context, filter map[string][]string) (<-chan *VolumeInfo, error)

ListVolume implements the client logic for listing the existing volumes on the target system.

func (*Client) Logs

func (c *Client) Logs(ctx context.Context, instance string, follow bool) (<-chan *LogMessage, error)

Logs retrieves the logs for a given container. It can optionally follow the logs as they are being produced.

func (*Client) PullImage

func (c *Client) PullImage(ctx context.Context, image string, tag string, creds *tpb.Credentials) (<-chan *Progress, error)

PullImage implements the client logic for the target to pull an image from a remote location.

func (*Client) PushImage

func (c *Client) PushImage(ctx context.Context, image string, tag string, file string, isPlugin bool) (<-chan *Progress, error)

PushImage implements the client logic to push an image to the target containerz server.

func (*Client) RemoveContainer

func (c *Client) RemoveContainer(ctx context.Context, cnt string, forceopt ...bool) error

RemoveContainer removes an image from the target system. It returns nil upon success. Otherwise it returns an error indicating whether the image was not found or is associated to running container.

Deprecated -- Use ImageRemove instead.

func (*Client) RemoveImage

func (c *Client) RemoveImage(ctx context.Context, image string, tag string, force bool) error

RemoveImage removes an image from the target system. It returns nil upon success. Otherwise it returns an error indicating whether the image was not found or is associated to running container.

func (*Client) RemovePlugin

func (c *Client) RemovePlugin(ctx context.Context, instance string) error

RemovePlugin removes the requested plugin identified by instance.

func (*Client) RemoveVolume

func (c *Client) RemoveVolume(ctx context.Context, name string, force bool) error

func (*Client) StartContainer

func (c *Client) StartContainer(ctx context.Context, image string, tag string, cmd string, instance string, opts ...StartOption) (string, error)

StartContainer starts a container with the provided configuration and returns its instance name if the operation succeeded or an error otherwise.

func (*Client) StartPlugin

func (c *Client) StartPlugin(ctx context.Context, name, instance, configFile string) error

StartPlugin starts the requested plugin identified by instance.

func (*Client) StopContainer

func (c *Client) StopContainer(ctx context.Context, instance string, force bool) error

StopContainer stops the requested instance. Stop can also force termination.

func (*Client) StopPlugin

func (c *Client) StopPlugin(ctx context.Context, instance string) error

StopPlugin stops the requested plugin identified by instance.

func (*Client) UpdateContainer

func (c *Client) UpdateContainer(ctx context.Context, image string, tag string, cmd string, instance string, async bool, opts ...StartOption) (string, error)

UpdateContainer updates an existing container with the provided configuration and returns its instance name if the operation succeeded or an error otherwise.

type ContainerInfo

type ContainerInfo struct {
	ID        string
	Name      string
	ImageName string
	State     string

	Error error
}

ContainerInfo contains information about a container on the target system.

type ImageInfo

type ImageInfo struct {
	ID        string
	ImageName string
	ImageTag  string

	Error error
}

ImageInfo contains information about an image on the target system.

type LogMessage

type LogMessage struct {
	Msg string

	Error error
}

LogMessage contains the log message retrieved from the target system as well as any error that may have occurred

type Progress

type Progress struct {
	Finished      bool
	Image         string
	Tag           string
	BytesReceived uint64
	Error         error
}

Progress contains progress information about this operation.

type StartOption

type StartOption func(*startOptions)

StartOption is an option passed to a start container call.

func WithCPUs

func WithCPUs(cpus float64) StartOption

WithCPUs sets the CPU limit to be passed to the start operation.

func WithCapabilities

func WithCapabilities(add, remove []string) StartOption

WithCapabilities sets the capablities to be passed to the start operation.

func WithEnv

func WithEnv(envs []string) StartOption

WithEnv sets the environment to be passed to the start operation.

func WithHardLimit

func WithHardLimit(mem int64) StartOption

WithHardLimit sets the hard memory limit to be passed to the start operation.

func WithLabels

func WithLabels(labels map[string]string) StartOption

WithLabels sets the labels to be passed to the start operation.

func WithNetwork

func WithNetwork(network string) StartOption

WithNetwork sets the network to be passed to the start operation.

func WithPorts

func WithPorts(ports []string) StartOption

WithPorts sets the ports to be passed to the start operation.

func WithRestartPolicy

func WithRestartPolicy(policy string) StartOption

WithRestartPolicy sets the restart policy to be passed to the start operation.

func WithRunAs

func WithRunAs(runAs string) StartOption

WithRunAs sets the run user and group to be passed to the start operation.

func WithSoftLimit

func WithSoftLimit(mem int64) StartOption

WithSoftLimit sets the soft memory limit to be passed to the start operation.

func WithVolumes

func WithVolumes(volumes []string) StartOption

WithVolumes sets the volumes to be passed to the start operation.

type State

type State int

State represents the state of the state machine

type VolumeInfo

type VolumeInfo struct {
	Name         string
	Driver       string
	Labels       map[string]string
	Options      map[string]string
	CreationTime time.Time
	Error        error
}

VolumeInfo contains information about a volume on the target system.

Jump to

Keyboard shortcuts

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