utils

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package utils contains shared Docker-specific helpers used by the updater.

Package utils provides shared updater helper utilities.

Index

Constants

View Source
const (
	// ComposeProjectLabelKey is Docker Compose's project label key.
	ComposeProjectLabelKey = "com.docker.compose.project"
	// ComposeServiceLabelKey is Docker Compose's service label key.
	ComposeServiceLabelKey = "com.docker.compose.service"
	// ComposeWorkingDirLabelKey is Docker Compose's project working directory label key.
	ComposeWorkingDirLabelKey = "com.docker.compose.project.working_dir"
	// ComposeConfigFilesLabelKey is Docker Compose's project config files label key.
	ComposeConfigFilesLabelKey = "com.docker.compose.project.config_files"
)

Variables

This section is empty.

Functions

func ComposeConfigFilesLabel added in v0.2.0

func ComposeConfigFilesLabel(labels map[string]string) []string

ComposeConfigFilesLabel returns Docker Compose project config file labels.

func ComposeProjectLabel

func ComposeProjectLabel(labels map[string]string) string

ComposeProjectLabel returns the trimmed Docker Compose project label.

func ComposeServiceLabel

func ComposeServiceLabel(labels map[string]string) string

ComposeServiceLabel returns the trimmed Docker Compose service label.

func ComposeWorkingDirLabel added in v0.2.0

func ComposeWorkingDirLabel(labels map[string]string) string

ComposeWorkingDirLabel returns the trimmed Docker Compose project working directory label.

func ConnectContainerExtraNetworksForAPI

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

ConnectContainerExtraNetworksForAPI attaches endpoints withheld from ContainerCreate.

func ContainerCreateWithCompatibility

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

ContainerCreateWithCompatibility applies Docker API compatibility shims before create.

func ContainerCreateWithCompatibilityForAPIVersion

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

ContainerCreateWithCompatibilityForAPIVersion applies Docker API compatibility shims before create.

func ContainerInspectWithCompatibility

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

ContainerInspectWithCompatibility wraps Docker inspect and validates the client.

func ContainerNameFromNames

func ContainerNameFromNames(names []string) string

ContainerNameFromNames returns Docker's first container name without the leading slash.

func ContainerSummaryName

func ContainerSummaryName(cnt container.Summary) string

ContainerSummaryName returns a displayable container name from a Docker summary.

func DetectAPIVersion

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

DetectAPIVersion returns the configured client API version or daemon API version.

func ExtractRegistryHost

func ExtractRegistryHost(imageRef string) string

ExtractRegistryHost extracts the registry host from an image reference.

func GetRegistryAddress

func GetRegistryAddress(imageRef string) (string, error)

GetRegistryAddress returns the Docker daemon auth address for an image reference.

func IsAPIVersionAtLeast

func IsAPIVersionAtLeast(current, minimum string) bool

IsAPIVersionAtLeast compares Docker API versions numerically.

func IsRegistryMatch

func IsRegistryMatch(left, right string) bool

IsRegistryMatch reports whether two registry host values describe the same registry.

func NormalizeRegistryForComparison

func NormalizeRegistryForComparison(rawURL string) string

NormalizeRegistryForComparison canonicalizes registry hosts for equality checks.

func NormalizeRegistryURL

func NormalizeRegistryURL(rawURL string) string

NormalizeRegistryURL canonicalizes registry URLs for Docker auth config lookups.

func PrepareContainerCreateOptionsForAPI

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

PrepareContainerCreateOptionsForAPI rewrites create options for older daemon APIs.

func SanitizeContainerCreateEndpointSettingsForAPI

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

SanitizeContainerCreateEndpointSettingsForAPI clones endpoint settings and strips unsupported fields.

func SortRegistryKeys

func SortRegistryKeys(values map[string]string) []string

SortRegistryKeys returns a deterministic copy of registry map keys.

func SupportsCreateMultiEndpointNetworking

func SupportsCreateMultiEndpointNetworking(apiVersion string) bool

SupportsCreateMultiEndpointNetworking reports whether create supports multiple endpoints.

func SupportsCreatePerNetworkMACAddress

func SupportsCreatePerNetworkMACAddress(apiVersion string) bool

SupportsCreatePerNetworkMACAddress reports whether Docker create supports endpoint MAC addresses.

Types

type EngineCompatibilityInfo

type EngineCompatibilityInfo struct {
	Name          string
	CgroupVersion string
}

EngineCompatibilityInfo describes recreate-time engine compatibility inputs.

func PrepareRecreateHostConfigForEngine

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

PrepareRecreateHostConfigForEngine clones hostConfig and removes incompatible fields.

Jump to

Keyboard shortcuts

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