Documentation
¶
Overview ¶
Package libarcane contains shared compatibility helpers, setting utilities, and internal resource metadata used across Arcane's backend and CLI.
Index ¶
- Constants
- func ConnectContainerExtraNetworksForDockerAPI(ctx context.Context, dockerClient client.APIClient, containerID string, ...) error
- func ContainerCreateWithCompatibility(ctx context.Context, dockerClient client.APIClient, ...) (client.ContainerCreateResult, error)
- func ContainerCreateWithCompatibilityForAPIVersion(ctx context.Context, dockerClient client.APIClient, ...) (client.ContainerCreateResult, error)
- func ContainerInspectWithCompatibility(ctx context.Context, apiClient client.APIClient, containerID string, ...) (client.ContainerInspectResult, error)
- func DetectDockerAPIVersion(ctx context.Context, dockerClient client.APIClient) string
- func IsCronSettingKey(key string) bool
- func IsDockerAPIVersionAtLeast(current, minimum string) bool
- func IsInternalContainer(labels map[string]string) bool
- func IsTimeoutSettingKey(key string) bool
- func NetworkInspectWithCompatibility(ctx context.Context, apiClient client.APIClient, networkID string, ...) (client.NetworkInspectResult, error)
- func PrepareContainerCreateOptionsForDockerAPI(options client.ContainerCreateOptions, apiVersion string) (client.ContainerCreateOptions, map[string]*network.EndpointSettings)
- func SanitizeContainerCreateEndpointSettingsForDockerAPI(endpoints map[string]*network.EndpointSettings, apiVersion string) map[string]*network.EndpointSettings
- func SupportsDockerCreateMultiEndpointNetworking(apiVersion string) bool
- func SupportsDockerCreatePerNetworkMACAddress(apiVersion string) bool
- func ValidateCronSetting(key, value string) error
- func WrapDockerAPIClientForInspectCompatibility(apiClient client.APIClient) client.APIClient
- type EngineCompatibilityInfo
- type SettingUpdate
Constants ¶
const DepotTokenSettingKey = "depotToken"
const (
InternalResourceLabel = "com.getarcaneapp.internal.resource"
)
Internal containers indicate containers used for arcanes utilties, ie: temp containers used for viewing files for volumes etc
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.
const NetworkScopedMacAddressMinAPIVersion = "1.44"
Variables ¶
This section is empty.
Functions ¶
func ConnectContainerExtraNetworksForDockerAPI ¶ added in v1.16.3
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 ¶ added in v1.16.3
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 ¶ added in v1.16.3
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 ¶ added in v1.16.2
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 ¶
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 ¶ added in v1.16.0
func IsDockerAPIVersionAtLeast ¶
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 IsTimeoutSettingKey ¶ added in v1.16.0
func NetworkInspectWithCompatibility ¶ added in v1.16.2
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 PrepareContainerCreateOptionsForDockerAPI ¶ added in v1.16.3
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 ¶ added in v1.16.3
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 ¶
SupportsDockerCreatePerNetworkMACAddress reports whether the daemon API supports per-network mac-address on container create (Docker API >= 1.44).
func ValidateCronSetting ¶ added in v1.16.0
func WrapDockerAPIClientForInspectCompatibility ¶ added in v1.16.2
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 ¶ added in v1.16.2
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 ¶ added in v1.16.2
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.