api

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2017 License: MIT Imports: 24 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, cli MeliAPiClient, dc *DockerContainer) (string, error)

func ConnectNetwork

func ConnectNetwork(ctx context.Context, cli MeliAPiClient, dc *DockerContainer) error

func ContainerLogs

func ContainerLogs(ctx context.Context, cli MeliAPiClient, dc *DockerContainer) error

func ContainerStart

func ContainerStart(ctx context.Context, cli MeliAPiClient, dc *DockerContainer) error

func CreateContainer

func CreateContainer(ctx context.Context, cli MeliAPiClient, dc *DockerContainer) (bool, string, error)

func CreateDockerVolume

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

func FormatComposePath

func FormatComposePath(path string) []string

func FormatImageName added in v0.0.8

func FormatImageName(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, dockerComposeFile 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, cli MeliAPiClient, dc *DockerContainer) 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 ComposeService added in v0.0.8

type ComposeService 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"`
	Links       []string    `yaml:"links,omitempty"`
}

type DockerComposeConfig

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

type DockerContainer added in v0.0.8

type DockerContainer struct {
	ServiceName       string
	ComposeService    ComposeService
	NetworkID         string
	NetworkName       string
	FollowLogs        bool
	DockerComposeFile string
	ContainerID       string // this assumes that there can only be one container per docker-compose service
	LogMedium         io.Writer
}

func (*DockerContainer) UpdateContainerID added in v0.0.8

func (dc *DockerContainer) UpdateContainerID(containerID string)

type EmptyStruct

type EmptyStruct struct{}

type ImageProgress added in v0.1.1

type ImageProgress struct {
	Status         string `json:"status,omitempty"`
	Stream         string `json:"stream,omitempty"`
	Progress       string `json:"progress,omitempty"`
	ProgressDetail string `json:"progressDetail,omitempty"`
}

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

Jump to

Keyboard shortcuts

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