docker

package
v2.1.0-alpha9 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package docker provides functionality for working with Docker containers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	client.APIClient
	ExtractNetworksForContainer(containerName string) (map[string]*network.EndpointSettings, error)
	ConnectContainerToNetworks(containerName string, settings map[string]*network.EndpointSettings) error
	AttachNetwork(containerName string, networkName []string) error
	StopAndRemoveDockerContainer() error
	GetContainerID() string
	SetContainerID(containerID string)
	NetworkExists(network string) (bool, error)

	HasRelativePath(c *Compose) bool
	ForceAbsolutePath(c *Compose, basePath string) error

	GetNetworkInfo(compose *Compose) *NetworkInfo

	CreateNetwork(network string) error
	MakeNetworkExternal(c *Compose) error
	SetKeployNetwork(c *Compose) (*NetworkInfo, error)
	ReadComposeFile(filePath string) (*Compose, error)
	WriteComposeFile(compose *Compose, path string) error
}

func New

func New(logger *zap.Logger) (Client, error)

type Compose

type Compose struct {
	Version  string    `yaml:"version,omitempty"`
	Services yaml.Node `yaml:"services,omitempty"`
	Networks yaml.Node `yaml:"networks,omitempty"`
	Volumes  yaml.Node `yaml:"volumes,omitempty"`
	Configs  yaml.Node `yaml:"configs,omitempty"`
	Secrets  yaml.Node `yaml:"secrets,omitempty"`
}

Compose structure to represent all the fields of a Docker Compose file

type Impl

type Impl struct {
	nativeDockerClient.APIClient
	// contains filtered or unexported fields
}

func (*Impl) AttachNetwork

func (idc *Impl) AttachNetwork(containerName string, networkNames []string) error

func (*Impl) ConnectContainerToNetworks

func (idc *Impl) ConnectContainerToNetworks(containerName string, settings map[string]*network.EndpointSettings) error

func (*Impl) CreateNetwork

func (idc *Impl) CreateNetwork(networkName string) error

CreateNetwork creates a custom docker network of type bridge.

func (*Impl) ExtractNetworksForContainer

func (idc *Impl) ExtractNetworksForContainer(containerName string) (map[string]*network.EndpointSettings, error)

ExtractNetworksForContainer returns the list of all the networks that the container is a part of. Note that if a user did not explicitly attach the container to a network, the Docker daemon attaches it to a network called "bridge".

func (*Impl) ForceAbsolutePath

func (idc *Impl) ForceAbsolutePath(c *Compose, basePath string) error

ForceAbsolutePath replaces relative paths in bind mounts with absolute paths

func (*Impl) GetContainerID

func (idc *Impl) GetContainerID() string

GetContainerID is a Getter function for containerID

func (*Impl) GetHostWorkingDirectory

func (idc *Impl) GetHostWorkingDirectory() (string, error)

GetHostWorkingDirectory Inspects Keploy docker container to get bind mount for current directory

func (*Impl) GetNetworkInfo

func (idc *Impl) GetNetworkInfo(compose *Compose) *NetworkInfo

GetNetworkInfo CheckNetworkInfo returns information about network name and also about whether the network is external or not in a docker-compose file.

func (*Impl) HasRelativePath

func (idc *Impl) HasRelativePath(compose *Compose) bool

HasRelativePath returns information about whether bind mounts if they are being used contain relative file names or not

func (*Impl) MakeNetworkExternal

func (idc *Impl) MakeNetworkExternal(c *Compose) error

MakeNetworkExternal makes the existing network of the user docker compose file external and save it to a new file

func (*Impl) NetworkExists

func (idc *Impl) NetworkExists(networkName string) (bool, error)

NetworkExists checks if the given network exists locally or not

func (*Impl) ReadComposeFile

func (idc *Impl) ReadComposeFile(filePath string) (*Compose, error)

func (*Impl) SetContainerID

func (idc *Impl) SetContainerID(containerID string)

SetContainerID is a Setter function for containerID

func (*Impl) SetKeployNetwork

func (idc *Impl) SetKeployNetwork(c *Compose) (*NetworkInfo, error)

SetKeployNetwork adds the keploy-network network to the new docker compose file and copy rest of the contents from existing user docker compose file

func (*Impl) StopAndRemoveDockerContainer

func (idc *Impl) StopAndRemoveDockerContainer() error

StopAndRemoveDockerContainer will Stop and Remove the docker container

func (*Impl) WriteComposeFile

func (idc *Impl) WriteComposeFile(compose *Compose, path string) error

type NetworkInfo

type NetworkInfo struct {
	External bool
	Name     string
}

Jump to

Keyboard shortcuts

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