libdocker

package
v0.0.0-...-3876be2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(dockerEndpoint string, cfg *Config) (*Builder, *ContainerBackend, error)

Types

type Authenticator

type Authenticator interface {
	// AuthConfigs returns the auth configurations for all configured registries.
	AuthConfigs() docker.AuthConfigurations
}

Authenticator holds the configuration for docker registry authentication.

type Builder

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

Builder takes care of building docker images.

func NewBuilder

func NewBuilder(client *docker.Client, cfg *Config, auth Authenticator) *Builder

func (*Builder) BuildClientImage

func (b *Builder) BuildClientImage(ctx context.Context, client libhive.ClientDesignator) (string, error)

BuildClientImage builds a docker image of the given client.

func (*Builder) BuildImage

func (b *Builder) BuildImage(ctx context.Context, name string, fsys fs.FS) error

BuildImage creates a container by archiving the given file system, which must contain a file called "Dockerfile".

func (*Builder) BuildSimulatorImage

func (b *Builder) BuildSimulatorImage(ctx context.Context, name string) (string, error)

BuildSimulatorImage builds a docker image of a simulator.

func (*Builder) ReadFile

func (b *Builder) ReadFile(ctx context.Context, image, path string) ([]byte, error)

ReadFile returns the content of a file in the given image. To do so, it creates a temporary container, downloads the file from it and destroys the container.

type Config

type Config struct {
	Inventory libhive.Inventory

	Logger log15.Logger

	// When building containers, any client or simulator image build matching the pattern
	// will avoid the docker cache.
	NoCachePattern *regexp.Regexp

	// This forces pulling of base images when building clients and simulators.
	PullEnabled bool

	// These two are log destinations for output from docker.
	ContainerOutput io.Writer
	BuildOutput     io.Writer

	// This tells the docker client whether to authenticate requests with credential helper
	UseCredentialHelper bool
}

Config is the configuration of the docker backend.

type ContainerBackend

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

func NewContainerBackend

func NewContainerBackend(c *docker.Client, cfg *Config) *ContainerBackend

func (*ContainerBackend) Build

Build builds the hiveproxy image.

func (*ContainerBackend) ConnectContainer

func (b *ContainerBackend) ConnectContainer(containerID, networkID string) error

ConnectContainer connects the given container to a network.

func (*ContainerBackend) ContainerIP

func (b *ContainerBackend) ContainerIP(containerID, networkID string) (net.IP, error)

ContainerIP finds the IP of a container in the given network.

func (*ContainerBackend) CreateContainer

func (b *ContainerBackend) CreateContainer(ctx context.Context, imageName string, opt libhive.ContainerOptions) (string, error)

CreateContainer creates a docker container.

func (*ContainerBackend) CreateNetwork

func (b *ContainerBackend) CreateNetwork(name string) (string, error)

CreateNetwork creates a docker network.

func (*ContainerBackend) DeleteContainer

func (b *ContainerBackend) DeleteContainer(containerID string) error

DeleteContainer removes the given container. If the container is running, it is stopped.

func (*ContainerBackend) DisconnectContainer

func (b *ContainerBackend) DisconnectContainer(containerID, networkID string) error

DisconnectContainer disconnects the given container from a network.

func (*ContainerBackend) NetworkNameToID

func (b *ContainerBackend) NetworkNameToID(name string) (string, error)

NetworkNameToID finds the network ID of network by the given name.

func (*ContainerBackend) PauseContainer

func (b *ContainerBackend) PauseContainer(containerID string) error

PauseContainer pauses the given container.

func (*ContainerBackend) RemoveNetwork

func (b *ContainerBackend) RemoveNetwork(id string) error

RemoveNetwork deletes a docker network.

func (*ContainerBackend) RunProgram

func (b *ContainerBackend) RunProgram(ctx context.Context, containerID string, cmd []string) (*libhive.ExecInfo, error)

RunProgram runs a /hive-bin script in a container.

func (*ContainerBackend) ServeAPI

ServeAPI starts the API server.

func (*ContainerBackend) StartContainer

func (b *ContainerBackend) StartContainer(ctx context.Context, containerID string, opt libhive.ContainerOptions) (*libhive.ContainerInfo, error)

StartContainer starts a docker container.

func (*ContainerBackend) UnpauseContainer

func (b *ContainerBackend) UnpauseContainer(containerID string) error

UnpauseContainer unpauses the given container.

type CredHelperAuthenticator

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

func NewCredHelperAuthenticator

func NewCredHelperAuthenticator() (CredHelperAuthenticator, error)

func (CredHelperAuthenticator) AuthConfigs

AuthConfigs returns the auth configurations for all configured registries

type CredHelpers

type CredHelpers struct {
	CredHelpers map[string]string `json:"credHelpers"`
	CredsStore  string            `json:"credsStore"`
}

CredHelpers represents the data stored by default in $HOME/.docker/config.json

Jump to

Keyboard shortcuts

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