dockerresource

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dockerresource defines the canonical set of Docker resource kinds that ownership and visibility middlewares use to describe inspectable objects. Both packages must agree on the wire-format strings, so the enumeration lives here to prevent silent divergence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeID added in v3.2.0

func DecodeID(body io.Reader, kind Kind) (string, error)

DecodeID reads the top-level immutable ID out of a container, image or secret inspect body. Docker spells the field "Id" for containers and images and "ID" for secrets; encoding/json matches the key case-insensitively, so one tag covers both. Other kinds return "" because nothing pins them.

func DecodeLabels

func DecodeLabels(body io.Reader, kind Kind) (map[string]string, error)

DecodeLabels reads a Docker inspect response body and extracts the resource labels for the given kind. Ownership and visibility both decode the same JSON shapes; centralizing the logic keeps them from drifting apart.

func DecodeLibpodLabels

func DecodeLibpodLabels(body io.Reader, kind Kind) (map[string]string, error)

DecodeLibpodLabels reads a libpod-native inspect response body — as opposed to DecodeLabels' Docker-compat shapes — and extracts the resource's labels. Kept as an entirely separate function, with its own switch and no shared case arms with DecodeLabels, per #148 design doc C6: the two API families' wire shapes are pinned independently against real captures/upstream source and must never be allowed to silently reconverge into one "smart" decoder if one family drifts.

func InspectPath

func InspectPath(kind Kind, identifier string) (string, bool)

InspectPath returns the Docker API path for fetching a single resource of the given kind. The result is a server-side path, ready for "http://docker" + InspectPath. Returns ("", false) when the kind is not individually inspectable.

Ownership and visibility both build the same URLs to fetch labels for a resource; centralizing the mapping ensures they cannot drift apart.

func LibpodInspectPath

func LibpodInspectPath(kind Kind, identifier string) (string, bool)

LibpodInspectPath returns the libpod-native inspect path for kind — always shaped /libpod/<resource>/<id>/json, unlike the Docker-compat paths InspectPath returns for kinds such as KindNetwork/KindVolume (bare /networks/{id}, no /json suffix). Centralizing this the same way InspectPath is centralized keeps ownership and visibility from drifting apart on the libpod route shape, per #148 design doc C6. Returns ("", false) for any kind with no libpod-native inspect path of its own (e.g. KindVolume/KindSecret/KindContainer reuse their Docker-compat path via InspectPath instead, since Podman's compat API is a translation layer over the same underlying resource store for those kinds).

func ValidID added in v3.2.0

func ValidID(id string) bool

ValidID reports whether id is safe to splice into a request path as one path segment and to hand back to the daemon as an immutable reference. An ID that fails this check is treated as "identity could not be established".

Types

type ContainerInspect added in v3.2.0

type ContainerInspect struct {
	// ID is the top-level "Id".
	ID string
	// Labels is Config.Labels.
	Labels map[string]string
	// Names is "Names", or ["Name"] when only Name is set.
	Names []string
	// Image is the reference image_patterns match on. Docker and Podman compat
	// inspect set the top-level Image to the image ID (sha256:...) while the
	// container list reports the name, so the name comes from Config.Image (the
	// reference given at create, the same source the list uses) or, for libpod,
	// ImageName. The top-level Image is only a fallback when neither is present.
	// An empty result matches no pattern, so a body with no usable reference
	// stays hidden.
	Image string
	// Networks is the network names off NetworkSettings. Docker and Podman
	// (compat and libpod) all key NetworkSettings.Networks by network name; a
	// missing NetworkSettings or a null Networks reads as attached to nothing
	// and yields nil.
	Networks []string
}

ContainerInspect is what owner isolation and visibility read from one container inspect body.

func DecodeContainerInspect added in v3.2.0

func DecodeContainerInspect(body io.Reader) (ContainerInspect, error)

DecodeContainerInspect reads a container inspect body once so every layer that narrows on it (owner isolation, visibility) reads it the same way.

type Kind

type Kind string

Kind names a category of Docker resource (container, image, network, etc.) in the same form the Docker API uses in URL paths.

const (
	KindContainer Kind = "containers"
	KindImage     Kind = "images"
	KindNetwork   Kind = "networks"
	KindVolume    Kind = "volumes"
	KindService   Kind = "services"
	KindTask      Kind = "tasks"
	KindSecret    Kind = "secrets"
	KindConfig    Kind = "configs"
	KindNode      Kind = "nodes"
	KindSwarm     Kind = "swarm"

	// KindLibpodPod identifies Podman's native pod resource (#148). Pods have
	// no Docker-compat equivalent — there is no "/pods/{id}" endpoint on the
	// Docker Engine API a pod is also reachable through — so, unlike every
	// other kind above, a pod can only ever be inspected via the /libpod/
	// route family. See LibpodInspectPath.
	KindLibpodPod Kind = "libpod-pods"
	// KindLibpodNetwork identifies a libpod-native network *inspect request*
	// specifically — i.e. the inbound client request itself is under
	// /libpod/networks/, not "a network that happens to have been created
	// via the libpod API" (any network, regardless of which API created it,
	// is also reachable through the Docker-compat KindNetwork path, and
	// ownership's write-side checks use that path uniformly). It exists as
	// its own Kind because GET /libpod/networks/{id}/json has two wire-shape
	// differences from the Docker-compat GET /networks/{id} DecodeLabels
	// already reads for KindNetwork: a lowercase top-level "labels" key, and
	// — per #148 design doc C6 — a single-element ARRAY-wrapped response on
	// some Podman versions/endpoints. See DecodeLibpodLabels.
	KindLibpodNetwork Kind = "libpod-networks"
)

Jump to

Keyboard shortcuts

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