docker

package module
v0.0.0-...-1113af3 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

README

Libkermit

GoDoc Build Status Go Report Card License

When libkermit meet with go-check.

Note: This is experimental and not even implemented yet. You are on your own right now

Package docker

This package map the docker package but takes a *check.C struct on all methods. The idea is to write even less. Let's write the same example as above.

package yours

import (
    "testing"

	"github.com/go-check/check"
    docker "github.com/libkermit/docker-check"
)

// Hook up gocheck into the "go test" runner
func Test(t *testing.T) { check.TestingT(t) }

type CheckSuite struct{}

var _ = check.Suite(&CheckSuite{})

func (s *CheckSuite) TestItMyFriend(c *check.C) {
    project := docker.NewProjectFromEnv(c)
    container := project.Start(c, "vdemeester/myawesomeimage")

    // Do your stuff
    // […]

    // Clean the containers managed by libkermit
    project.Clean(c)
}

Documentation

Overview

Package docker aims to provide simple "helper" methods to ease the use of docker in (integration) tests using the go-check testing package.

It does support a subset of options compared to actual client api, as it is more focused on needs for integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Project

type Project struct {
	// contains filtered or unexported fields
}

Project holds docker related project attributes, like docker client, labels to put on the containers, and so on.

func NewProject

func NewProject(client client.APIClient) *Project

NewProject creates a project with the given client and the default attributes.

func NewProjectFromEnv

func NewProjectFromEnv(c *check.C) *Project

NewProjectFromEnv creates a project with a client that is build from environment variables.

func (*Project) Clean

func (p *Project) Clean(c *check.C, keep bool)

Clean stops and removes (by default, controllable with the keep) kermit containers

func (*Project) Create

func (p *Project) Create(c *check.C, image string) types.ContainerJSON

Create lets you create a container with the specified image, and default configuration.

func (*Project) CreateWithConfig

func (p *Project) CreateWithConfig(c *check.C, image string, containerConfig docker.ContainerConfig) types.ContainerJSON

CreateWithConfig lets you create a container with the specified image, and some custom simple configuration.

func (*Project) Inspect

func (p *Project) Inspect(c *check.C, containerID string) types.ContainerJSON

Inspect returns the container informations

func (*Project) IsPaused

func (p *Project) IsPaused(c *check.C, containerID string) bool

IsPaused checks if the container is running or not

func (*Project) IsRunning

func (p *Project) IsRunning(c *check.C, containerID string) bool

IsRunning checks if the container is running or not

func (*Project) IsStopped

func (p *Project) IsStopped(c *check.C, containerID string) bool

IsStopped checks if the container is running or not

func (*Project) List

func (p *Project) List(c *check.C) []types.Container

List lists the containers managed by kermit

func (*Project) Pull

func (p *Project) Pull(c *check.C, ref string)

Pull pulls the given reference (image)

func (*Project) Remove

func (p *Project) Remove(c *check.C, containerID string)

Remove removes the container

func (*Project) Start

func (p *Project) Start(c *check.C, image string) types.ContainerJSON

Start lets you create and start a container with the specified image, and default configuration.

func (*Project) StartWithConfig

func (p *Project) StartWithConfig(c *check.C, image string, containerConfig docker.ContainerConfig) types.ContainerJSON

StartWithConfig lets you create and start a container with the specified image, and some custom simple configuration.

func (*Project) Stop

func (p *Project) Stop(c *check.C, containerID string)

Stop stops the container with a default timeout.

func (*Project) StopWithTimeout

func (p *Project) StopWithTimeout(c *check.C, containerID string, timeout int)

StopWithTimeout stops the container with the specified timeout.

Jump to

Keyboard shortcuts

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