dockerapi

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package dockerapi provides a way to interact with the Docker API using an adapter pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a wrapper around the Docker client.

func NewClient

func NewClient() (*Client, error)

NewClient returns a new Client.

func (*Client) ContainerList

func (c *Client) ContainerList() ([]Container, error)

ContainerList returns the list of containers from the Docker client.

func (Client) LogValue

func (c Client) LogValue() slog.Value

LogValue logs customizable properties of the Docker client. These properties can be customized by setting environment variables. Read: client.FromEnv.

type Container

type Container struct {
	Names    []string
	Networks map[string]IPAddress
}

Container represents a Docker container.

type Docker

type Docker interface {
	ContainerList() ([]Container, error)
}

Docker is an interface for interacting with the Docker API.

type IPAddress

type IPAddress string

IPAddress represents a Docker container's IP in a particular network.

func (IPAddress) URL

func (ip IPAddress) URL(port uint16) string

URL converts the IPAddress to a URL along with a port. Assumes the protocol is HTTP.

type Mock

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

Mock is a mock implementation of the Docker interface. It should be used by tests so the actual Docker API is not actually called.

func NewMock

func NewMock(outputs ...[]Container) *Mock

NewMock returns a new Mock with the given container outputs.

func (*Mock) ContainerList

func (m *Mock) ContainerList() ([]Container, error)

ContainerList returns the next container output in the list of outputs.

Jump to

Keyboard shortcuts

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