Documentation
¶
Index ¶
- Variables
- func NormalizeNameservers(raw []string) ([]string, error)
- func ValidateRunOptions(image string, opts CreateOptions) error
- type BuildOptions
- type Client
- type ContainerClient
- func (c *ContainerClient) Delete(ctx context.Context, opts DeleteOptions) (string, error)
- func (c *ContainerClient) InspectDetails(ctx context.Context, ids []string) ([]ContainerDetails, error)
- func (c *ContainerClient) List(ctx context.Context, opts ListOptions) (string, error)
- func (c *ContainerClient) ListSummaries(ctx context.Context, opts ListOptions) ([]ContainerSummary, error)
- func (c *ContainerClient) Logs(ctx context.Context, opts LogsOptions, out io.Writer) (string, error)
- func (c *ContainerClient) Run(ctx context.Context, image string, opts CreateOptions) (bool, error)
- func (c *ContainerClient) RunStreaming(ctx context.Context, image string, opts CreateOptions, out io.Writer) (bool, error)
- func (c *ContainerClient) Start(ctx context.Context, id string) (string, error)
- func (c *ContainerClient) Stop(ctx context.Context, opts StopOptions) (string, error)
- type ContainerDetails
- type ContainerMount
- type ContainerSummary
- type CreateOptions
- type DeleteOptions
- type ImageClient
- func (i *ImageClient) Build(ctx context.Context, opts BuildOptions, out io.Writer) (string, error)
- func (i *ImageClient) Exists(ctx context.Context, reference string) (bool, error)
- func (i *ImageClient) InspectSummary(ctx context.Context, reference string) (ImageSummary, bool, error)
- func (i *ImageClient) List(ctx context.Context, quiet bool) (string, error)
- type ImageSummary
- type ListOptions
- type LogsOptions
- type Mount
- type MountType
- type NetworkAttachment
- type NetworkClient
- func (n *NetworkClient) Create(ctx context.Context, opts NetworkCreateOptions) (string, error)
- func (n *NetworkClient) Delete(ctx context.Context, names []string) (string, error)
- func (n *NetworkClient) Exists(ctx context.Context, name string) (bool, error)
- func (n *NetworkClient) Inspect(ctx context.Context, names []string) (string, error)
- func (n *NetworkClient) InspectSummary(ctx context.Context, name string) (NetworkSummary, bool, error)
- func (n *NetworkClient) List(ctx context.Context) (string, error)
- func (n *NetworkClient) ListSummaries(ctx context.Context) ([]NetworkSummary, error)
- type NetworkCreateOptions
- type NetworkSummary
- type PortMapping
- type Protocol
- type Signal
- type StopOptions
- type SystemClient
- type VolumeClient
- func (v *VolumeClient) Create(ctx context.Context, opts VolumeCreateOptions) (string, error)
- func (v *VolumeClient) Delete(ctx context.Context, opts VolumeDeleteOptions) (string, error)
- func (v *VolumeClient) Exists(ctx context.Context, name string) (bool, error)
- func (v *VolumeClient) Inspect(ctx context.Context, names []string) (string, error)
- func (v *VolumeClient) InspectSummary(ctx context.Context, name string) (VolumeSummary, bool, error)
- func (v *VolumeClient) List(ctx context.Context) (string, error)
- func (v *VolumeClient) ListSummaries(ctx context.Context) ([]VolumeSummary, error)
- func (v *VolumeClient) Prune(ctx context.Context) (string, error)
- type VolumeCreateOptions
- type VolumeDeleteOptions
- type VolumeSummary
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NormalizeNameservers ¶
NormalizeNameservers validates literal DNS server addresses and returns their canonical string forms. Loopback, unspecified, multicast, and link-local addresses cannot identify a nameserver reachable from another container.
func ValidateRunOptions ¶
func ValidateRunOptions(image string, opts CreateOptions) error
ValidateRunOptions checks the same create-time arguments that Run passes to the external CLI, without starting a container.
Types ¶
type BuildOptions ¶
type BuildOptions struct {
// The build context path. Defaults to current directory when empty.
ContextDir string
// Name and optionally a tag in the name:tag format.
Tag string
// Name of the Dockerfile (Default is "Dockerfile").
File string
// Do not use cache when building the image.
NoCache bool
// Target OS for the image.
OS string
// Target architecture for the image: amd64 or arm64
Arch []string
// Target platform for the image in the format os/arch[/variant].
Platform string
// Build arguments in the format key=val.
BuildArgs map[string]string
// Tries to pull the latest base image from the registry.
Pull bool
}
BuildOptions defines the options for building an image.
type Client ¶
type Client struct {
Bin string
Container ContainerClient
System SystemClient
Images ImageClient
Volumes VolumeClient
Networks NetworkClient
}
type ContainerClient ¶
type ContainerClient struct {
// contains filtered or unexported fields
}
func NewContainerClient ¶
func (*ContainerClient) Delete ¶
func (c *ContainerClient) Delete(ctx context.Context, opts DeleteOptions) (string, error)
Delete deletes one or more containers based on the provided options. Returns the ID of the deleted container(s) and an error if the operation fails.
func (*ContainerClient) InspectDetails ¶
func (c *ContainerClient) InspectDetails(ctx context.Context, ids []string) ([]ContainerDetails, error)
InspectDetails returns the volume and network metadata needed by higher-level clients. It intentionally exposes only typed fields rather than the runtime's full inspect response.
func (*ContainerClient) List ¶
func (c *ContainerClient) List(ctx context.Context, opts ListOptions) (string, error)
List returns a list of containers based on the provided options
func (*ContainerClient) ListSummaries ¶
func (c *ContainerClient) ListSummaries(ctx context.Context, opts ListOptions) ([]ContainerSummary, error)
ListSummaries returns typed container metadata from the list command.
func (*ContainerClient) Logs ¶
func (c *ContainerClient) Logs(ctx context.Context, opts LogsOptions, out io.Writer) (string, error)
Logs streams container logs to the provided writer.
func (*ContainerClient) Run ¶
func (c *ContainerClient) Run(ctx context.Context, image string, opts CreateOptions) (bool, error)
Run creates and starts a new container based on the provided image and options. Returns true if the container was successfully created and started, or an error if the operation fails.
func (*ContainerClient) RunStreaming ¶ added in v0.1.2
func (c *ContainerClient) RunStreaming(ctx context.Context, image string, opts CreateOptions, out io.Writer) (bool, error)
RunStreaming creates and starts a container while forwarding runtime output, including automatic image-pull progress, to out. Output is also retained for command errors. Without a streaming runner, captured output is forwarded when the command finishes.
func (*ContainerClient) Stop ¶
func (c *ContainerClient) Stop(ctx context.Context, opts StopOptions) (string, error)
Stop stops one or more running containers based on the provided options. Returns the ID of the stopped container(s) and an error if the operation fails.
type ContainerDetails ¶
type ContainerDetails struct {
ID string
ImageDigest string
VolumeNames []string
Mounts []ContainerMount
Networks []NetworkAttachment
}
ContainerDetails is the container metadata needed by higher-level clients after inspecting a container.
type ContainerMount ¶
ContainerMount describes one configured container mount returned by inspect.
type ContainerSummary ¶
ContainerSummary is the information returned for a container by the list command.
type CreateOptions ¶
type CreateOptions struct {
// Name of the container to create
Name string
// Number of CPUs to allocate to the container
CPUs uint
// Amount of memory (1MiByte granularity), with optional K, M, G, T, or P suffix
Memory string
// Remove the container after it exits
Rm bool
// Port mappings
Publish []PortMapping
// Environment variables in KEY=VALUE (or KEY) format.
Environment []string
// Labels associates metadata with the container as KEY=VALUE pairs.
Labels map[string]string
// Nameservers identifies DNS server IP addresses to pass through repeated
// --dns flags. Their order is preserved.
Nameservers []string
// Networks identifies the networks to attach when creating the container.
Networks []string
// Mounts configures filesystem mounts for the container.
Mounts []Mount
// Container init Process arguments, if any
Arguments []string
}
CreateOptions defines the options for creating a container
type DeleteOptions ¶
type ImageClient ¶
type ImageClient struct {
// contains filtered or unexported fields
}
func NewImageClient ¶
func (*ImageClient) Build ¶
func (i *ImageClient) Build(ctx context.Context, opts BuildOptions, out io.Writer) (string, error)
Build builds an image, streams command output to the provided writer, and returns the image id created.
func (*ImageClient) Exists ¶
Exists reports whether an image reference is available in the local image store.
func (*ImageClient) InspectSummary ¶
func (i *ImageClient) InspectSummary(ctx context.Context, reference string) (ImageSummary, bool, error)
InspectSummary returns the descriptor digest for a local image and whether the reference exists. It uses image inspect and therefore never pulls.
type ImageSummary ¶
type ImageSummary struct {
Digest string
}
ImageSummary is the stable local image identity needed by higher-level clients when deciding whether an existing container uses the current image.
type ListOptions ¶
type ListOptions struct {
// Display both running and stopped containers
All bool
// Return only container IDs
Quiet bool
}
ListOptions defines the options for listing containers
type LogsOptions ¶
type LogsOptions struct {
// Follow streams logs continuously until context cancellation or process exit.
Follow bool
// IDs are container IDs or names to fetch logs for.
IDs []string
}
LogsOptions defines options for streaming or fetching container logs.
type Mount ¶
type Mount struct {
// Type identifies the storage backing for the mount.
Type MountType
// Source is the absolute host path for a bind mount or a volume name for a
// named-volume mount. Tmpfs mounts do not have a source.
Source string
// Target is the absolute path where the mount appears in the container.
Target string
// ReadOnly prevents writes through the mount.
ReadOnly bool
// TmpfsSize is the tmpfs capacity in bytes. Zero uses the runtime default.
TmpfsSize uint64
// TmpfsMode is the tmpfs file mode expressed as an octal Unix-permission
// string. An empty value uses the runtime default.
TmpfsMode string
}
Mount configures one filesystem mount for a container.
type MountType ¶
type MountType string
MountType identifies the storage backing used by a container mount.
type NetworkAttachment ¶
NetworkAttachment describes a container's assigned addresses on one runtime network. Addresses do not include the CIDR prefixes reported by the container CLI's inspect output.
type NetworkClient ¶
type NetworkClient struct {
// contains filtered or unexported fields
}
NetworkClient manages user-defined networks through the container CLI.
func NewNetworkClient ¶
NewNetworkClient creates a NetworkClient using the supplied command runner.
func (*NetworkClient) Create ¶
func (n *NetworkClient) Create(ctx context.Context, opts NetworkCreateOptions) (string, error)
Create creates a user-defined network and returns the CLI output.
func (*NetworkClient) InspectSummary ¶
func (n *NetworkClient) InspectSummary(ctx context.Context, name string) (NetworkSummary, bool, error)
InspectSummary returns metadata for a network and whether it exists.
func (*NetworkClient) List ¶
func (n *NetworkClient) List(ctx context.Context) (string, error)
List returns the JSON description of all networks.
func (*NetworkClient) ListSummaries ¶
func (n *NetworkClient) ListSummaries(ctx context.Context) ([]NetworkSummary, error)
ListSummaries returns names and labels for every network.
type NetworkCreateOptions ¶
type NetworkCreateOptions struct {
// Name is the name of the network to create.
Name string
// Labels associates metadata with the network as KEY=VALUE pairs.
Labels map[string]string
}
NetworkCreateOptions configures user-defined network creation.
type NetworkSummary ¶
NetworkSummary is the network metadata used by higher-level clients to identify an ACC-managed network.
type PortMapping ¶
type PortMapping struct {
HostIP string
HostPort uint16
ContainerPort uint16
Protocol Protocol // "tcp" or "udp"
}
PortMapping defines a mapping from a host port to a container port as taken by the container cli
type Protocol ¶
type Protocol string
Protocol types accepted by the container cli defined in the container package: TCP and UDP
type Signal ¶
type Signal string
Signal defines the signal types accepted by the container cli defined under container package
type StopOptions ¶
type StopOptions struct {
// Stop all running containers
All bool
// List of container IDs or names to stop, should be empty if All flag is true
IDs []string
// Seconds to wait before killing the containers (default: 5)
Time uint
// Signal to send to the containers (default: SIGTERM)
Signal Signal
}
StopOptions defines the options for stopping containers
type SystemClient ¶
type SystemClient struct {
// contains filtered or unexported fields
}
func NewSystemClient ¶
type VolumeClient ¶
type VolumeClient struct {
// contains filtered or unexported fields
}
VolumeClient manages named volumes through the container CLI.
func NewVolumeClient ¶
NewVolumeClient creates a VolumeClient using the supplied command runner.
func (*VolumeClient) Create ¶
func (v *VolumeClient) Create(ctx context.Context, opts VolumeCreateOptions) (string, error)
Create creates a named volume and returns the CLI output.
func (*VolumeClient) Delete ¶
func (v *VolumeClient) Delete(ctx context.Context, opts VolumeDeleteOptions) (string, error)
Delete deletes the requested named volumes.
func (*VolumeClient) InspectSummary ¶
func (v *VolumeClient) InspectSummary(ctx context.Context, name string) (VolumeSummary, bool, error)
InspectSummary returns metadata for a named volume and whether it exists.
func (*VolumeClient) List ¶
func (v *VolumeClient) List(ctx context.Context) (string, error)
List returns the JSON description of all named volumes.
func (*VolumeClient) ListSummaries ¶
func (v *VolumeClient) ListSummaries(ctx context.Context) ([]VolumeSummary, error)
ListSummaries returns names and labels for every named volume.
type VolumeCreateOptions ¶
type VolumeCreateOptions struct {
// Name is the name of the volume to create.
Name string
// Labels associates metadata with the volume as KEY=VALUE pairs.
Labels map[string]string
// Options contains volume driver options as KEY=VALUE pairs.
Options map[string]string
}
VolumeCreateOptions configures named-volume creation.
type VolumeDeleteOptions ¶
type VolumeDeleteOptions struct {
// Names identifies the volumes to delete. It must be empty when All is set.
Names []string
// All deletes every volume.
All bool
}
VolumeDeleteOptions configures named-volume deletion.
type VolumeSummary ¶
VolumeSummary is the metadata returned by volume list operations.