docker

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDockerBuilder

func NewDockerBuilder(b *basher.Basher) build.Builder

Types

type Cleanup

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

func (*Cleanup) Clean

func (c *Cleanup) Clean(t *testing.T)

type Docker

type Docker struct {
	Log          io.ReadCloser
	ContainerId  string
	DockerClient *client.Client

	*basher.Basher
	// contains filtered or unexported fields
}

Docker provides an implementation of the Builder interface that utilizes docker for its building. It will start up a docker container, download code into it, add environment variables, and exec commands against it.

func CreateLivingDockerContainer

func CreateLivingDockerContainer(t *testing.T, ctx context.Context, imageName string) (d *Docker, clean func(t *testing.T))

CreateLivingDockerContainer will:

  • create a docker container with an image from imageName
  • tar up the template directory and serve it on :3333 for testing so the container can download the templates we need
  • return a cleanup function to defer in your tests

*assumes you have an internet connection and are running docker on linux or mac*

func (*Docker) AddGlobalEnvs

func (d *Docker) AddGlobalEnvs(envs []string)

func (*Docker) Close

func (d *Docker) Close() error

Close isn't relevant to the docker implementation of the Builder interface

func (*Docker) Exec

func (d *Docker) Exec(ctx context.Context, currStage string, currStageStr string, env []string, cmds []string, logout chan []byte) *pb.Result

Exec runs the equivalent of `docker exec`, sending all the logs over logout. The result of the command will be returned in a result object

func (*Docker) Execute

func (d *Docker) Execute(ctx context.Context, stage *pb.Stage, logout chan []byte, commitHash string) *pb.Result

Execute runs a command via Exec on the container, but it first will cd to the directory of the cloned repo

func (*Docker) ExecuteIntegration

func (d *Docker) ExecuteIntegration(ctx context.Context, stage *pb.Stage, stgUtil *build.StageUtil, logout chan []byte) *pb.Result

ExecuteIntegration will basically run Execute but without the cd and run cmds because we are generating the scripts in the code

func (*Docker) GetContainerId

func (d *Docker) GetContainerId() string

func (*Docker) Init

func (d *Docker) Init(ctx context.Context, hash string, logout chan []byte) *pb.Result

func (*Docker) SetGlobalEnv

func (d *Docker) SetGlobalEnv(envs []string)

func (*Docker) Setup

func (d *Docker) Setup(ctx context.Context, logout chan []byte, dockerIdChan chan string, werk *pb.WerkerTask, rc cred.CVRemoteConfig, werkerPort string) (*pb.Result, string)

Setup pulls the docker image defined in the werk task, then creates a container using that image, sending the container id over the dockerIdChan.

It mounts the docker socket to allow for docker builds within the container. It then starts the container with the initial command of downloading
all the ocelot related files and installing necessary packages, and attaches logout to the output so the logs can be stored with teh rest of the build
logs

Jump to

Keyboard shortcuts

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