libarcane

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: BSD-3-Clause Imports: 22 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 LabelArcaneUpgrader = "com.getarcaneapp.arcane.upgrader"

LabelArcaneUpgrader marks the short-lived helper container that performs an Arcane self-upgrade. It carries the Arcane label too, so container lookups must skip it to avoid mistaking it for Arcane itself.

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 CurrentContainerInspectTarget added in v2.8.0

func CurrentContainerInspectTarget(currentContainerID func() (string, error), hostname func() (string, error)) (string, bool, error)

CurrentContainerInspectTarget resolves the identifier used to inspect Arcane's current container. The second return reports whether the target came from the cgroup container ID (authoritative) rather than the hostname fallback.

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 FindArcaneContainerIDByLabel added in v2.8.0

func FindArcaneContainerIDByLabel(ctx context.Context, dockerClient *client.Client) string

FindArcaneContainerIDByLabel locates Arcane's own container through the Arcane label. Running containers win; otherwise the first match is returned. The upgrader helper is never a candidate. Returns "" when nothing matches.

func InspectCurrentArcaneContainer added in v2.8.0

func InspectCurrentArcaneContainer(ctx context.Context, dockerClient *client.Client) (*container.InspectResponse, error)

InspectCurrentArcaneContainer inspects Arcane's own container, preferring cgroup/hostname self-detection and falling back to the Arcane label.

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 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 TimeoutSettingKeys added in v2.7.0

func TimeoutSettingKeys() []string

TimeoutSettingKeys returns the settings propagated to remote environments.

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 vuln drives Trivy scans: building and parsing scanner invocations, plus the container-level mechanics of running one — runtime/network detection, container spec and resources, temp files, log copy and tar extraction, and report decoding.
Package vuln drives Trivy scans: building and parsing scanner invocations, plus the container-level mechanics of running one — runtime/network detection, container spec and resources, temp files, log copy and tar extraction, and report decoding.

Jump to

Keyboard shortcuts

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