desktop

package
v5.1.4 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const EngineLabel = "com.docker.desktop.address"

EngineLabel is used to detect that Compose is running with a Docker Desktop context. When present, the value is an endpoint address for an in-memory socket (AF_UNIX or named pipe).

View Source
const FeatureLogsTab = "LogsTab"

FeatureLogsTab is the feature flag name for the Docker Desktop Logs view.

View Source
const LogsAppIDMaxLen = 256

LogsAppIDMaxLen mirrors the byte-length cap Docker Desktop's URL handler applies to the appId query parameter; values longer than this are truncated by the receiver, so we trim ahead of time to avoid emitting hyperlinks that will be silently shortened. The slice in BuildLogsURL is a byte slice — Compose project names are restricted to the ASCII set `[a-z0-9_-]` by loader.NormalizeProjectName, so a byte cap and a rune cap coincide for any value that could legitimately reach this builder.

Variables

This section is empty.

Functions

func BuildLogsURL added in v5.1.4

func BuildLogsURL(appID string) string

BuildLogsURL returns the deep link that opens Docker Desktop's Logs view, optionally pre-filtered to a Compose project. An empty appID yields the unfiltered URL.

func Endpoint added in v5.1.4

func Endpoint(ctx context.Context, apiClient client.APIClient) (string, error)

Endpoint returns the Docker Desktop API socket endpoint advertised via the engine info labels, or "" when the active engine is not Docker Desktop.

func IsFeatureActive added in v5.1.4

func IsFeatureActive(ctx context.Context, apiClient client.APIClient, feature string) bool

IsFeatureActive reports whether Docker Desktop is the active engine and the given feature flag is enabled. Returns false silently on any failure — the engine being unreachable, Desktop not being the active engine, or the flag being off — so callers can use this as a single gating check.

func IsFeatureActiveStandalone added in v5.1.4

func IsFeatureActiveStandalone(ctx context.Context, feature string) bool

IsFeatureActiveStandalone is the convenience form of IsFeatureActive for callers without an existing engine API client (e.g. the compose plugin hook subprocess). It builds a Docker CLI using the ambient environment to resolve the active context, then delegates to IsFeatureActive.

func ProxyTransport added in v5.1.4

func ProxyTransport(endpoint string) http.RoundTripper

ProxyTransport returns an http.RoundTripper that routes traffic through Docker Desktop's PAC-aware HTTP proxy when DD exposes the proxy socket, or nil when no override is needed (callers should use their own default transport in that case — for the OCI resolver this means containerd's built-in transport). Pass "" for endpoint when DD is not the active engine.

When DD is available, the returned transport is a clone of http.DefaultTransport with only Proxy and DialContext overridden, so it preserves stdlib timeout, pooling, and HTTP/2 defaults.

func ProxyTransportFor added in v5.1.4

func ProxyTransportFor(ctx context.Context, apiClient client.APIClient) http.RoundTripper

ProxyTransportFor discovers the Docker Desktop endpoint via apiClient and returns the matching transport, or nil when DD is not active or discovery fails (so callers fall back to their own default transport).

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for integration with Docker Desktop features.

func NewClient

func NewClient(apiEndpoint string) *Client

NewClient creates a Desktop integration client for the provided in-memory socket address (AF_UNIX or named pipe).

func (*Client) Close

func (c *Client) Close() error

Close releases any open connections.

func (*Client) Endpoint

func (c *Client) Endpoint() string

func (*Client) FeatureFlags

func (c *Client) FeatureFlags(ctx context.Context) (FeatureFlagResponse, error)

func (*Client) IsFeatureEnabled added in v5.1.3

func (c *Client) IsFeatureEnabled(ctx context.Context, feature string) (bool, error)

IsFeatureEnabled checks the feature flag (GET /features) for a given feature. Returns true when the feature is rolled out.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) (*PingResponse, error)

Ping is a minimal API used to ensure that the server is available.

type FeatureFlagResponse

type FeatureFlagResponse map[string]FeatureFlagValue

type FeatureFlagValue

type FeatureFlagValue struct {
	Enabled bool `json:"enabled"`
}

type PingResponse

type PingResponse struct {
	ServerTime int64 `json:"serverTime"`
}

Jump to

Keyboard shortcuts

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