dockerutil

package
v0.0.0-...-1a43f7c Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package dockerutil docket util

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateBytesUUID

func GenerateBytesUUID() []byte

GenerateBytesUUID returns a UUID based on RFC 4122 returning the generated bytes.

func GenerateSplitLogs

func GenerateSplitLogs(logName string) error

GenerateSplitLogs generates a log file named logName, formatted similarly to docker-compose logs, but without all the output from all the containers being mixed in together. Each container has all its output in one section of the log, for easy reading.

Types

type Composition

type Composition struct {
	DockerClient     *docker.Client
	APIContainers    []*docker.APIContainers
	ComposeFilesYaml string
	ProjectName      string
	Dir              string
	DockerHelper     DockerHelper
}

Composition represents a docker-compose execution and management.

func NewComposition

func NewComposition(projectName, composeFilesYaml, dir string) (composition *Composition, err error)

NewComposition create a new Composition specifying the project name (for isolation) and the compose files.

func (*Composition) Decompose

func (c *Composition) Decompose(dir string) (output string, err error)

Decompose decompose the composition. Will also remove any containers with the same ProjectName prefix (eg. chaincode containers).

func (*Composition) GenerateLogs

func (c *Composition) GenerateLogs(dir, logName string) error

GenerateLogs to file.

func (*Composition) GetAPIContainerForComposeService

func (c *Composition) GetAPIContainerForComposeService(
	composeService string) (apiContainer *docker.APIContainers, err error)

GetAPIContainerForComposeService return the docker.APIContainers with the supplied composeService name.

func (*Composition) GetContainerIDs

func (c *Composition) GetContainerIDs(dir string) (containerIDs []string, err error)

GetContainerIDs returns the container IDs for the composition. (NOTE: does NOT include those defined outside composition, eg. chaincode containers).

func (*Composition) GetIPAddressForComposeService

func (c *Composition) GetIPAddressForComposeService(composeService string) (ipAddress string, err error)

GetIPAddressForComposeService returns the IPAddress of the container with the supplied composeService name.

type DockerHelper

type DockerHelper interface {
	GetIPAddress(containerID string) (string, error)
	RemoveContainersWithNamePrefix(namePrefix string) error
}

DockerHelper helper for docker specific functions.

func NewDockerCmdlineHelper

func NewDockerCmdlineHelper() DockerHelper

NewDockerCmdlineHelper returns a new command line DockerHelper instance.

Jump to

Keyboard shortcuts

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