api

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2017 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthInfo sync.Map

Functions

func BuildDockerImage

func BuildDockerImage(ctx context.Context, dockerFile string, cli MeliAPiClient) (string, error)

func ConnectNetwork

func ConnectNetwork(ctx context.Context, networkID, containerID string, cli MeliAPiClient) error

func ContainerLogs

func ContainerLogs(ctx context.Context, containerId string, followLogs bool, cli MeliAPiClient) error

func ContainerStart

func ContainerStart(ctx context.Context, containerId string, cli MeliAPiClient) error

func CreateContainer

func CreateContainer(ctx context.Context, s ServiceConfig, networkName, formattedImageName, dockerComposeFile string, cli MeliAPiClient) (bool, string, error)

func CreateDockerVolume

func CreateDockerVolume(ctx context.Context, name, driver string, cli MeliAPiClient) (string, error)

func FormatComposePath

func FormatComposePath(path string) []string

func FormatContainerName

func FormatContainerName(containerName string) string

func FormatLabels

func FormatLabels(label string) []string

func FormatPorts

func FormatPorts(port string) []string

func FormatRegistryAuth

func FormatRegistryAuth(auth string) []string

func FormatServiceVolumes

func FormatServiceVolumes(volume string) []string

func GetAuth

func GetAuth()

func GetCwdName

func GetCwdName(path string) string

func GetNetwork

func GetNetwork(ctx context.Context, networkName string, cli MeliAPiClient) (string, error)

GetNetwork gets or creates newtwork(if it doesn't exist yet.)

func PullDockerImage

func PullDockerImage(ctx context.Context, imageName string, cli MeliAPiClient) error

Types

type Buildstruct

type Buildstruct struct {
	// remember to use caps so that they can be exported
	Context    string `yaml:"context,omitempty"`
	Dockerfile string `yaml:"dockerfile,omitempty"`
}

type DockerComposeConfig

type DockerComposeConfig struct {
	Version  string                   `yaml:"version,omitempty"`
	Services map[string]ServiceConfig `yaml:"services"`
	Volumes  map[string]string        `yaml:"volumes,omitempty"`
}

type EmptyStruct

type EmptyStruct struct{}

type MeliAPiClient

type MeliAPiClient interface {
	// we implement this interface so that we can be able to mock it in tests
	// https://medium.com/@zach_4342/dependency-injection-in-golang-e587c69478a8
	ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)
	ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)
	ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error
	ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
	NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
	NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
	NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error
	VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error)
	ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
}

type MockDockerClient

type MockDockerClient struct{}

func (*MockDockerClient) ContainerCreate

func (m *MockDockerClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)

func (*MockDockerClient) ContainerList

func (m *MockDockerClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)

func (*MockDockerClient) ContainerLogs

func (m *MockDockerClient) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)

func (*MockDockerClient) ContainerStart

func (m *MockDockerClient) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error

func (*MockDockerClient) ImageBuild

func (m *MockDockerClient) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)

func (*MockDockerClient) ImagePull

func (m *MockDockerClient) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)

func (*MockDockerClient) NetworkConnect

func (m *MockDockerClient) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error

func (*MockDockerClient) NetworkCreate

func (m *MockDockerClient) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)

func (*MockDockerClient) NetworkList

func (*MockDockerClient) VolumeCreate

type ServiceConfig

type ServiceConfig struct {
	Image       string      `yaml:"image,omitempty"`
	Ports       []string    `yaml:"ports,omitempty"`
	Labels      []string    `yaml:"labels,omitempty"`
	Environment []string    `yaml:"environment,omitempty"`
	Command     string      `yaml:"command,flow,omitempty"`
	Restart     string      `yaml:"restart,omitempty"`
	Build       Buildstruct `yaml:"build,omitempty"`
	Volumes     []string    `yaml:"volumes,omitempty"`
}

Jump to

Keyboard shortcuts

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