docker

package module
v0.0.0-...-f9c8925 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package docker is the in-process Docker adapter: it materializes `container` resources on the Docker daemon named by DOCKER_HOST.

Package docker provides the first-party Docker adapter. Plugin wraps *Adapter as a plugin.Adapter so it can run as a separate binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

API is the subset of the Docker client the adapter uses. *client.Client satisfies it; Fake implements it for tests.

type Adapter

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

Adapter creates, updates, and deletes containers through an API. Containers are addressed by resource name, never by stored id.

func New

func New() (*Adapter, error)

New returns an Adapter for the daemon named by DOCKER_HOST (default: the local socket). No connection is made until the first call.

func NewWithAPI

func NewWithAPI(api API) *Adapter

NewWithAPI returns an Adapter backed by api.

func (*Adapter) Create

func (a *Adapter) Create(ctx context.Context, name, typ string, props map[string]any, report plugin.Reporter) (map[string]any, error)

Create materializes resource name and returns its outputs ({"id": ...}).

func (*Adapter) Delete

func (a *Adapter) Delete(ctx context.Context, name string) error

Delete removes container name. A free name, or one held by a container dex did not create, counts as deleted and is left alone.

func (*Adapter) Update

func (a *Adapter) Update(ctx context.Context, name string, desired, cur map[string]any, report plugin.Reporter) (map[string]any, error)

Update moves container name from properties cur to desired. A change to restart alone is applied in place; anything else replaces the container, pulling the new image first so a failed pull leaves the old one running.

type Fake

type Fake struct {
	Images       map[string]bool
	Containers   map[string]*FakeContainer
	Err          map[string]error
	CrashOnStart bool     // started containers exit immediately with code 1
	Calls        []string // method names, in call order
	// contains filtered or unexported fields
}

Fake is an in-memory API: a minimal daemon holding images and named containers, for tests of this package and of its callers. Set Err[method] (e.g. Err["ContainerStart"]) to make that method fail.

func NewFake

func NewFake() *Fake

NewFake returns an empty Fake.

func (*Fake) ContainerStop

func (*Fake) ImageInspect

func (*Fake) ImagePull

type FakeContainer

type FakeContainer struct {
	ID         string
	Config     *container.Config
	HostConfig *container.HostConfig
	Running    bool
	ExitCode   int
}

FakeContainer is one container held by Fake, keyed by name.

type Plugin

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

Plugin wraps *Adapter to implement plugin.Adapter, bridging the in-process docker.Adapter interface to the gRPC-facing plugin.Adapter interface.

func NewPlugin

func NewPlugin(a *Adapter) *Plugin

NewPlugin returns a Plugin wrapping a.

func (*Plugin) Apply

func (p *Plugin) Apply(ctx context.Context, req plugin.Request, r plugin.Reporter) (map[string]any, error)

Apply delegates to Create or Update based on whether req.Prior is nil. Empty Prior means create; non-nil means update.

func (*Plugin) Destroy

func (p *Plugin) Destroy(ctx context.Context, req plugin.Request, r plugin.Reporter) error

Destroy delegates to Delete.

Directories

Path Synopsis
cmd
dex-adapter-docker command
dex-adapter-docker is the gRPC adapter binary for Docker containers.
dex-adapter-docker is the gRPC adapter binary for Docker containers.

Jump to

Keyboard shortcuts

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