desktop

package
v1.125.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClientBackend = newRawClient(dialBackend)
View Source
var Paths = sync.OnceValue(func() DockerDesktopPaths {
	desktopPaths, err := getDockerDesktopPaths()
	if err != nil {
		panic(err)
	}

	return desktopPaths
})

Functions

func GetToken

func GetToken(ctx context.Context) string

GetToken returns the user's Docker access token, or "" when there is none.

func GetUUID added in v1.41.0

func GetUUID(ctx context.Context) string

func GetVersion added in v1.60.0

func GetVersion(ctx context.Context) string

GetVersion returns the running Docker Desktop version (e.g. "4.74.0") or an empty string if Docker Desktop is not running or the call fails.

The lookup is bounded by a short internal timeout so a stale or missing backend socket cannot stall callers on hot paths (it is queried on every outbound built-in tool HTTP request). ctx is used for the underlying HTTP call on a cache miss; on a cache hit the cached value is returned without consulting ctx.

func InvalidateToken added in v1.125.0

func InvalidateToken(token string)

InvalidateToken forgets token, everywhere it may be cached, so the next GetToken fetches or mints a new one. Called when Docker rejects a token we believed to be valid: only the issuer knows for sure.

func IsDockerDesktopRunning

func IsDockerDesktopRunning(ctx context.Context) bool

func IsWSL added in v1.37.0

func IsWSL() bool

Types

type DockerDesktopPaths

type DockerDesktopPaths struct {
	BackendSocket string
	ProxySocket   string
}

type DockerHubInfo

type DockerHubInfo struct {
	Username string `json:"id"`
	Email    string `json:"email,omitempty"`
}

func GetUserInfo

func GetUserInfo(ctx context.Context) DockerHubInfo

GetUserInfo returns the signed-in account. Docker Desktop knows it best, but it is not always around: the token itself carries the same information.

type RawClient

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

func (*RawClient) Get

func (c *RawClient) Get(ctx context.Context, endpoint string, v any) error

func (*RawClient) Post added in v1.114.0

func (c *RawClient) Post(ctx context.Context, endpoint string) error

type Source added in v1.125.0

type Source string

Source says where a token came from, for diagnostics.

const (
	SourceNone    Source = "none"
	SourceDesktop Source = "docker desktop"
	SourceMinted  Source = "minted from the stored access token"
)

func GetTokenWithSource added in v1.125.0

func GetTokenWithSource(ctx context.Context) (string, Source)

GetTokenWithSource returns the user's Docker access token and where it came from. Docker Desktop's newer auth stack (auth v2) serves whatever its in-memory token source holds and never refreshes on GET, so a stuck background refresher makes it return the same expired JWT forever — or nothing at all when its read-time refresh failed. When that happens we mint a token ourselves from the access token `docker login` stored, and only then fall back to nudging Desktop.

Directories

Path Synopsis
Package transport provides an HTTP transport that routes requests through the Docker Desktop proxy when available.
Package transport provides an HTTP transport that routes requests through the Docker Desktop proxy when available.

Jump to

Keyboard shortcuts

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