libarcane

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package libarcane contains shared compatibility helpers, setting utilities, and internal resource metadata used across Arcane's backend and CLI.

Index

Constants

View Source
const DepotTokenSettingKey = "depotToken"
View Source
const InternalResourceLabel = "com.getarcaneapp.internal.resource"

InternalResourceLabel marks containers used for Arcane utilities, e.g. temp containers used for viewing volume files.

View Source
const MultiEndpointContainerCreateMinAPIVersion = "1.44"

MultiEndpointContainerCreateMinAPIVersion is the first Docker API version that reliably accepts multiple entries in NetworkingConfig.EndpointsConfig on ContainerCreate.

This matters because Arcane has several in-process container creation paths (auto-update recreate, manual create, self-upgrade recreate, embedded Compose library usage). Those paths all speak to the daemon through the Moby API client, so Arcane must handle daemon API compatibility itself.

A host-side `docker compose up` command can still succeed against the same daemon because the installed Compose CLI/plugin may implement its own fallback strategy for older daemon APIs, such as creating the container on the primary network and then attaching the remaining networks with NetworkConnect. Arcane cannot assume the host CLI's fallback behavior exists in its own code paths, so the compatibility shim below applies that fallback explicitly.

View Source
const NetworkScopedMacAddressMinAPIVersion = "1.44"

Variables

This section is empty.

Functions

func ConnectContainerExtraNetworksForDockerAPI

func ConnectContainerExtraNetworksForDockerAPI(ctx context.Context, dockerClient client.APIClient, containerID string, endpoints map[string]*network.EndpointSettings) error

ConnectContainerExtraNetworksForDockerAPI attaches endpoints that were intentionally withheld from ContainerCreate for legacy daemon API compatibility.

The intended call order is: 1. create the container on the primary network 2. connect each additional user-defined network 3. start the container

Doing the attachment before start preserves the expected network topology while avoiding the legacy daemon limitation on multi-endpoint create.

func ContainerCreateWithCompatibility

func ContainerCreateWithCompatibility(ctx context.Context, dockerClient client.APIClient, options client.ContainerCreateOptions) (client.ContainerCreateResult, error)

ContainerCreateWithCompatibility applies Arcane's Docker API compatibility shims before calling ContainerCreate.

This helper exists so every in-process Arcane create/recreate path can share the same daemon-compatibility behavior instead of relying on whichever fallback logic a separate host CLI binary might have. In practice this is the guardrail that keeps Arcane aligned with older daemons such as Docker 24.x advertising API 1.43 when a container needs multiple user-defined networks.

func ContainerCreateWithCompatibilityForAPIVersion

func ContainerCreateWithCompatibilityForAPIVersion(ctx context.Context, dockerClient client.APIClient, options client.ContainerCreateOptions, apiVersion string) (client.ContainerCreateResult, error)

ContainerCreateWithCompatibilityForAPIVersion applies Arcane's Docker API compatibility shims before calling ContainerCreate when the caller has already resolved the daemon API version.

func ContainerInspectWithCompatibility

func ContainerInspectWithCompatibility(ctx context.Context, apiClient client.APIClient, containerID string, options client.ContainerInspectOptions) (client.ContainerInspectResult, error)

ContainerInspectWithCompatibility retries inspect decoding against raw daemon JSON when the primary typed decode fails on a ParseAddr-style CIDR issue.

func DetectDockerAPIVersion

func DetectDockerAPIVersion(ctx context.Context, dockerClient client.APIClient) string

DetectDockerAPIVersion returns the configured client API version when available, and falls back to the daemon-reported version only when the client version is not yet set.

func IsCronSettingKey

func IsCronSettingKey(key string) bool

func IsDockerAPIVersionAtLeast

func IsDockerAPIVersionAtLeast(current, minimum string) bool

IsDockerAPIVersionAtLeast performs numeric dot-segment comparison for Docker API versions (e.g. "1.43", "1.44.1"). Returns false when either version cannot be parsed.

func IsInternalContainer

func IsInternalContainer(labels map[string]string) bool

func IsTimeoutSettingKey

func IsTimeoutSettingKey(key string) bool

func NetworkInspectWithCompatibility

func NetworkInspectWithCompatibility(ctx context.Context, apiClient client.APIClient, networkID string, options client.NetworkInspectOptions) (client.NetworkInspectResult, error)

NetworkInspectWithCompatibility retries inspect decoding against raw daemon JSON when the primary typed decode fails on a ParseAddr-style CIDR issue.

func NetworkListWithCompatibility

func NetworkListWithCompatibility(ctx context.Context, apiClient client.APIClient, options client.NetworkListOptions) (client.NetworkListResult, error)

NetworkListWithCompatibility retries list decoding against raw daemon JSON when the primary typed decode fails on a ParseAddr-style CIDR issue.

func PrepareContainerCreateOptionsForDockerAPI

func PrepareContainerCreateOptionsForDockerAPI(options client.ContainerCreateOptions, apiVersion string) (client.ContainerCreateOptions, map[string]*network.EndpointSettings)

PrepareContainerCreateOptionsForDockerAPI rewrites a container create request for older daemon APIs that cannot accept multiple endpoint attachments in the initial ContainerCreate call.

For API versions below MultiEndpointContainerCreateMinAPIVersion, Arcane keeps only the primary network in NetworkingConfig.EndpointsConfig and returns the remaining endpoints so the caller can attach them with NetworkConnect after create but before start. This mirrors the compatibility behavior that a newer host-side Compose CLI may apply internally, which explains why a shell `docker compose up` can succeed while Arcane's embedded or manual create paths fail unless we perform the split ourselves.

func SanitizeContainerCreateEndpointSettingsForDockerAPI

func SanitizeContainerCreateEndpointSettingsForDockerAPI(endpoints map[string]*network.EndpointSettings, apiVersion string) map[string]*network.EndpointSettings

SanitizeContainerCreateEndpointSettingsForDockerAPI clones endpoint settings for container recreate and removes per-network mac-address when daemon API does not support it (API < 1.44).

func SupportsDockerCreateMultiEndpointNetworking

func SupportsDockerCreateMultiEndpointNetworking(apiVersion string) bool

SupportsDockerCreateMultiEndpointNetworking reports whether the connected daemon API supports attaching multiple endpoints during ContainerCreate.

On older daemon APIs, sending multiple EndpointsConfig entries can fail with daemon-side networking errors even though newer Compose CLIs may appear to "work" by using a different fallback sequence under the hood.

func SupportsDockerCreatePerNetworkMACAddress

func SupportsDockerCreatePerNetworkMACAddress(apiVersion string) bool

SupportsDockerCreatePerNetworkMACAddress reports whether the daemon API supports per-network mac-address on container create (Docker API >= 1.44).

func ValidateCronSetting

func ValidateCronSetting(key, value string) error

func WrapDockerAPIClientForInspectCompatibility

func WrapDockerAPIClientForInspectCompatibility(apiClient client.APIClient) client.APIClient

WrapDockerAPIClientForInspectCompatibility wraps a Docker API client so inspect calls can recover from daemon responses that encode address fields with CIDR suffixes that newer typed Moby structs reject.

Types

type EngineCompatibilityInfo

type EngineCompatibilityInfo struct {
	// Name is the normalized engine identifier, such as "docker" or "podman".
	Name string
	// CgroupVersion is the daemon-reported cgroup version, such as "1" or "2".
	CgroupVersion string
}

EngineCompatibilityInfo describes the container engine details Arcane uses to decide whether recreate-time HostConfig sanitization is required.

func PrepareRecreateHostConfigForEngine

func PrepareRecreateHostConfigForEngine(ctx context.Context, dockerClient *client.Client, hostConfig *containertypes.HostConfig) (*containertypes.HostConfig, bool, EngineCompatibilityInfo, error)

PrepareRecreateHostConfigForEngine clones hostConfig and removes recreate options that are known to be incompatible with the connected engine.

The returned HostConfig is a shallow copy, so field reassignment is isolated from the caller's original value, but content-level mutation of shared slice or map fields is not. The boolean result reports whether the helper removed any incompatible fields. EngineCompatibilityInfo reports the daemon details used to make that decision.

type SettingUpdate

type SettingUpdate struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Directories

Path Synopsis
Package logstream captures the application's own slog output into a bounded in-memory ring buffer and fans it out to live subscribers.
Package logstream captures the application's own slog output into a bounded in-memory ring buffer and fans it out to live subscribers.
Package system encapsulates host-level resource probing used by the WebSocket system stats endpoint: cgroup limits and GPU detection/stats.
Package system encapsulates host-level resource probing used by the WebSocket system stats endpoint: cgroup limits and GPU detection/stats.

Jump to

Keyboard shortcuts

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