Documentation
¶
Index ¶
- Constants
- func ComposeProjectLabel(labels map[string]string) string
- func ComposeServiceLabel(labels map[string]string) string
- func ContainerNameFromNames(names []string) string
- func CurrentContainerInspectTarget(currentContainerID func() (string, error), hostname func() (string, error)) (string, error)
- func FilterContainersUsingVolume(containers []container.Summary, volumeName string) []string
- func GetContainersUsingVolume(ctx context.Context, dockerClient *client.Client, volumeName string) ([]string, error)
- func GetVolumeUsageData(ctx context.Context, dockerClient *client.Client) ([]volume.Volume, error)
- func GetVolumeUsageDataStaleWhileRevalidate(ctx context.Context, dockerClient *client.Client) mo.Option[[]volume.Volume]
- func InvalidateVolumeUsageCache(dockerClient *client.Client)
- func IsDefaultNetwork(name string) bool
- func MountForCurrentContainerSubpath(ctx context.Context, dockerCli *client.Client, containerPath, target string) (*mount.Mount, error)
- func MountForDestination(mounts []container.MountPoint, destination string, target string) *mount.Mount
- func MountForSubpath(mounts []container.MountPoint, containerPath string, target string) *mount.Mount
- func NewLogLineWriter(dst io.Writer) io.WriteCloser
- func ReadAllLogs(ctx context.Context, logs io.ReadCloser, logsChan chan<- string) error
- func RenderJSONMessageStream(reader io.Reader, out io.Writer) error
- func StreamContainerLogs(ctx context.Context, logs io.ReadCloser, logsChan chan<- string, follow bool, ...) error
- func StreamMultiplexedLogs(ctx context.Context, logs io.Reader, logsChan chan<- string) error
- type ProgressWriterKey
Constants ¶
const ( ComposeProjectLabelKey = "com.docker.compose.project" ComposeServiceLabelKey = "com.docker.compose.service" )
Docker Compose attaches these labels to every container it manages. They identify the owning project and the service within that project.
const ImageStateResyncAction events.Action = "arcane-resync"
ImageStateResyncAction identifies Arcane's synthetic image event emitted when Docker reconnects.
Variables ¶
This section is empty.
Functions ¶
func ComposeProjectLabel ¶
ComposeProjectLabel returns the trimmed Docker Compose project name from a container's labels, or "" when unset.
func ComposeServiceLabel ¶
ComposeServiceLabel returns the trimmed Docker Compose service name from a container's labels, or "" when unset.
func ContainerNameFromNames ¶
ContainerNameFromNames returns Docker's first container name without the leading slash Docker stores in container summaries.
func CurrentContainerInspectTarget ¶ added in v2.6.0
func CurrentContainerInspectTarget(currentContainerID func() (string, error), hostname func() (string, error)) (string, error)
CurrentContainerInspectTarget resolves the identifier used to inspect Arcane's current container.
func FilterContainersUsingVolume ¶
FilterContainersUsingVolume returns the IDs of containers in the provided slice that mount the named volume. Use this when checking many volumes in a row — list containers once and reuse the slice.
func GetContainersUsingVolume ¶
func GetContainersUsingVolume(ctx context.Context, dockerClient *client.Client, volumeName string) ([]string, error)
GetContainersUsingVolume lists all containers and returns IDs that mount the named volume. For batch checks (multiple volumes), prefer listing containers once via dockerClient.ContainerList and calling FilterContainersUsingVolume per volume.
func GetVolumeUsageData ¶
GetVolumeUsageData returns current volume usage data, sharing an in-flight refresh with concurrent callers while allowing each caller to honor its own context.
func GetVolumeUsageDataStaleWhileRevalidate ¶ added in v2.5.0
func GetVolumeUsageDataStaleWhileRevalidate(ctx context.Context, dockerClient *client.Client) mo.Option[[]volume.Volume]
GetVolumeUsageDataStaleWhileRevalidate returns immediately with any cached snapshot and starts a bounded refresh when the snapshot is stale or missing.
func InvalidateVolumeUsageCache ¶
InvalidateVolumeUsageCache invalidates usage data for the Docker daemon used by dockerClient.
func IsDefaultNetwork ¶
func MountForCurrentContainerSubpath ¶ added in v2.2.0
func MountForCurrentContainerSubpath(ctx context.Context, dockerCli *client.Client, containerPath, target string) (*mount.Mount, error)
MountForCurrentContainerSubpath inspects the current container, finds the existing mount whose destination covers containerPath, and returns a Mount suitable for use in another container creation that exposes the same data at target. Returns nil + no error if Arcane isn't running inside a container or no suitable mount is found — callers can fall back to a plain bind on containerPath in that case.
func MountForDestination ¶
func MountForDestination(mounts []container.MountPoint, destination string, target string) *mount.Mount
MountForDestination returns a Mount suitable for container creation that mirrors an existing container mount at the given destination.
It currently supports bind and named volume mounts. If target is empty, destination is used as the target.
func MountForSubpath ¶ added in v2.2.0
func MountForSubpath(mounts []container.MountPoint, containerPath string, target string) *mount.Mount
MountForSubpath returns a Mount that exposes a subpath of one of the current container's existing mounts at the requested target. It's a generalisation of MountForDestination for the case where the caller wants a sub-tree below an existing mount destination (e.g. "/app/data/projects/X" when "/app/data" is what the container has mounted).
The function picks the most-specific mount whose Destination is a prefix of containerPath, then constructs the Mount based on the backing type:
- TypeBind: Source = mount.Source joined with the relative subpath. Works because bind sources are real host paths the daemon can address directly.
- TypeVolume: Source = mount.Name (the volume name), and the relative subpath is set on VolumeOptions.Subpath. This lets the daemon mount the named volume directly without needing a host-side path translation — important for setups where the underlying volume storage is opaque (Docker Desktop on WSL2, Docker-in-Docker, etc.).
Returns nil if no mount destination is a prefix of containerPath or if the matching mount is of an unsupported type.
func NewLogLineWriter ¶ added in v2.6.0
func NewLogLineWriter(dst io.Writer) io.WriteCloser
NewLogLineWriter returns a writer that splits everything written to it on newlines and emits each line as a {"log":"<line>"} NDJSON frame to dst, flushing after each frame when dst supports it. Close flushes any trailing partial line as a final frame. Writers such as compose's plain progress renderer and jsonmessage.DisplayJSONMessagesStream write raw CLI text into this to put docker-CLI-parity output on the wire.
func ReadAllLogs ¶
ReadAllLogs reads a non-follow Docker multiplexed log stream and sends non-empty stdout/stderr lines to logsChan.
func RenderJSONMessageStream ¶ added in v2.6.0
RenderJSONMessageStream renders a Docker JSON message stream (image pull, push, build, load) as the raw text the docker CLI prints in non-TTY mode, writing it to out. Any daemon-reported error is returned verbatim.
func StreamContainerLogs ¶
func StreamContainerLogs(ctx context.Context, logs io.ReadCloser, logsChan chan<- string, follow bool, isTTY bool) error
StreamContainerLogs streams Docker container logs, handling TTY raw streams and non-TTY multiplexed stdout/stderr streams.
Types ¶
type ProgressWriterKey ¶ added in v2.6.0
type ProgressWriterKey struct{}
ProgressWriterKey can be set on a context to stream operation output to the client. The value must be an io.Writer (typically an activity writer wrapping the HTTP response writer).