Documentation ¶
Overview ¶
Package docker provides functionality for working with Docker containers.
Index ¶
- func ParseDockerCmd(cmd string, kind utils.CmdType, idc Client) (string, string, error)
- type Client
- type Compose
- type Impl
- func (idc *Impl) AttachNetwork(containerName string, networkNames []string) error
- func (idc *Impl) ConnectContainerToNetworks(containerName string, settings map[string]*network.EndpointSettings) error
- func (idc *Impl) CreateNetwork(networkName string) error
- func (idc *Impl) CreateVolume(ctx context.Context, volumeName string, recreate bool) error
- func (idc *Impl) ExtractNetworksForContainer(containerName string) (map[string]*network.EndpointSettings, error)
- func (idc *Impl) ForceAbsolutePath(c *Compose, basePath string) error
- func (idc *Impl) GetContainerID() string
- func (idc *Impl) GetHostWorkingDirectory() (string, error)
- func (idc *Impl) GetNetworkInfo(compose *Compose) *NetworkInfo
- func (idc *Impl) HasRelativePath(compose *Compose) bool
- func (idc *Impl) IsContainerRunning(containerName string) (bool, error)
- func (idc *Impl) MakeNetworkExternal(c *Compose) error
- func (idc *Impl) NetworkExists(networkName string) (bool, error)
- func (idc *Impl) ReadComposeFile(filePath string) (*Compose, error)
- func (idc *Impl) SetContainerID(containerID string)
- func (idc *Impl) SetKeployNetwork(c *Compose) (*NetworkInfo, error)
- func (idc *Impl) StopAndRemoveDockerContainer() error
- func (idc *Impl) WriteComposeFile(compose *Compose, path string) error
- type NetworkInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 IsContainerRunning(containerName string) (bool, error) CreateVolume(ctx context.Context, volumeName string, recreate bool) 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 (*Impl) ConnectContainerToNetworks ¶
func (*Impl) CreateNetwork ¶
CreateNetwork creates a custom docker network of type bridge.
func (*Impl) CreateVolume ¶
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 ¶
ForceAbsolutePath replaces relative paths in bind mounts with absolute paths
func (*Impl) GetContainerID ¶
GetContainerID is a Getter function for containerID
func (*Impl) GetHostWorkingDirectory ¶
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 ¶
HasRelativePath returns information about whether bind mounts if they are being used contain relative file names or not
func (*Impl) IsContainerRunning ¶
IsContainerRunning check if the container is already running or not, required for docker start command.
func (*Impl) MakeNetworkExternal ¶
MakeNetworkExternal makes the existing network of the user docker compose file external and save it to a new file
func (*Impl) NetworkExists ¶
NetworkExists checks if the given network exists locally or not
func (*Impl) SetContainerID ¶
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 ¶
StopAndRemoveDockerContainer will Stop and Remove the docker container