docker

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceKindContainer      = "container"
	ResourceKindSwarmTask      = "swarm/task"
	ResourceKindSwarmService   = "swarm/service"
	ResourceKindSwarmNamespace = "swarm/namespace"
	ResourceKindComposeProject = "compose/project"
	ResourceKindComposeService = "compose/service"
)

Variables

This section is empty.

Functions

func TagName

func TagName(kind ResourceKind) string

TagName returns the human-readable name of a tag representing the resource. Panics if ResourceKind.IsSupported returns false.

Types

type ConfigEntry added in v0.16.0

type ConfigEntry struct {
	Auth     string `json:"auth,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	Email    string `json:"email,omitempty"`
}

ConfigEntry is an entry for a specific pattern, as defined in a ConfigFile.

type ConfigFile added in v0.16.0

type ConfigFile struct {
	Auths       map[string]ConfigEntry `json:"auths"`
	HttpHeaders map[string]string      `json:"HttpHeaders,omitempty"`
}

ConfigFile implements config file format used by Docker (and Kubernetes) for registry secrets and auth.

type Container

type Container struct {
	ID      string `json:"Id"`
	Names   []string
	Image   string
	ImageID string
	Labels  map[string]string
}

Container is a container as defined by the Docker runtime API.

func (Container) Name

func (c Container) Name() string

Name returns the name of the container, or its ID if no name is found.

type GetContainersOptions

type GetContainersOptions struct {
	// All maps to the all query parameter of the containers API, returning all
	// containers no matter their state.
	All bool
	// Filters maps to the filters query parameter of the containers API,
	// filtering containers to include.
	Filters map[string][]string
}

type Image

type Image struct {
	ID          string `json:"Id"`
	RepoTags    []string
	RepoDigests []string
}

Image is an image as defined by the Docker runtime API.

type Options

type Options struct {
	// IncludeAllContainers will graph all containers, no matter their state.
	// Defaults to false - only include running containers.
	IncludeAllContainers bool
}

type Platform

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

Platform implements graphing for the Docker platform.

func NewPlatform

func NewPlatform(ctx context.Context, dockerURI string, options *Options) (*Platform, error)

NewPlatform initializes a new Platform.

  • dockerURI is the URI to the docker socket. Such as unix://docker.sock or tcp://127.0.0.1:8080.

func (*Platform) GetContainers

func (p *Platform) GetContainers(ctx context.Context, options *GetContainersOptions) ([]Container, error)

GetContainers retrieves container information from the Docker runtime.

func (*Platform) GetImage

func (p *Platform) GetImage(ctx context.Context, nameOrID string) (*Image, error)

GetImage retrieves container image information from the Docker runtime by name or id. Returns an error if the image does not exist.

func (*Platform) GetVersion

func (p *Platform) GetVersion(ctx context.Context) (string, string, error)

GetVersion returns the api version and minimum supported api version of the Docker runtime.

func (*Platform) Graph

func (p *Platform) Graph(ctx context.Context) (*graph.Graph[platform.Node], error)

Graph implements platform.Platform.

SEE: https://docs.docker.com/reference/api/engine/version/v1.47/

type Resource

type Resource interface {
	platform.Node
	// Kind returns the type of resource.
	Kind() ResourceKind
	// Name returns the name of the resource.
	Name() string
	// String returns a textual representation of the resource.
	String() string
}

Resource is a Docker resource found on the platform.

type ResourceKind

type ResourceKind string

ResourceKind defines the types of resources exposed by the platform.

func (ResourceKind) IsSupported added in v0.18.0

func (r ResourceKind) IsSupported() bool

IsSupported returns whether or not the resource is supported.

Jump to

Keyboard shortcuts

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