dockerlocal

package
v0.0.0-...-6e3d6eb Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2017 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmitStatus

func EmitStatus(e *core.NormalizedEmitter, r io.Reader, options *core.PipelineOptions)

EmitStatus emits the json message on r

func GenerateDockerID

func GenerateDockerID() (string, error)

GenerateDockerID will generate a cryptographically random 256 bit hex Docker identifier.

func NewDockerTransport

func NewDockerTransport(options *core.PipelineOptions, dockerOptions *DockerOptions, containerID string) (core.Transport, error)

NewDockerTransport constructor

func NewNilBuilder

func NewNilBuilder() *nilBuilder

func NewServiceBox

func NewServiceBox(config *core.BoxConfig, options *core.PipelineOptions, dockerOptions *DockerOptions, builder Builder) (core.ServiceBox, error)

func NewStep

func NewStep(config *core.StepConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (core.Step, error)

func RequireDockerEndpoint

func RequireDockerEndpoint(options *DockerOptions) error

Types

type Artificer

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

Artificer collects artifacts from containers and uploads them.

func NewArtificer

func NewArtificer(options *core.PipelineOptions, dockerOptions *DockerOptions) *Artificer

NewArtificer returns an Artificer

func (*Artificer) Collect

func (a *Artificer) Collect(artifact *core.Artifact) (*core.Artifact, error)

Collect an artifact from the container, if it doesn't have any files in the tarball return util.ErrEmptyTarball

func (*Artificer) Upload

func (a *Artificer) Upload(artifact *core.Artifact) error

Upload an artifact to S3

type Builder

type Builder interface {
	Build(context.Context, *util.Environment, *core.BoxConfig) (*DockerBox, *docker.Image, error)
}

Builder interface to create an image based on a service config kinda needed so we can break a bunch of circular dependencies with cmd

type ContainerRemover

type ContainerRemover struct {
	*docker.Container
	// contains filtered or unexported fields
}

func TempBusybox

func TempBusybox(client *DockerClient) (*ContainerRemover, error)

func (*ContainerRemover) Remove

func (c *ContainerRemover) Remove()

type DockerBox

type DockerBox struct {
	Name      string
	ShortName string
	// contains filtered or unexported fields
}

Box is our wrapper for Box operations

func NewDockerBox

func NewDockerBox(boxConfig *core.BoxConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (*DockerBox, error)

NewDockerBox from a name and other references

func (*DockerBox) AddService

func (b *DockerBox) AddService(service core.ServiceBox)

AddService needed by this Box

func (*DockerBox) Clean

func (b *DockerBox) Clean() error

Clean up the containers

func (*DockerBox) Commit

func (b *DockerBox) Commit(name, tag, message string, cleanup bool) (*docker.Image, error)

Commit the current running Docker container to an Docker image.

func (*DockerBox) ExportImage

func (b *DockerBox) ExportImage(options *ExportImageOptions) error

ExportImage will export the image to a temporary file and return the path to the file.

func (*DockerBox) Fetch

func (b *DockerBox) Fetch(ctx context.Context, env *util.Environment) (*docker.Image, error)

Fetch an image (or update the local)

func (*DockerBox) GetID

func (b *DockerBox) GetID() string

GetID gets the container ID or empty string if we don't have a container

func (*DockerBox) GetName

func (b *DockerBox) GetName() string

GetName gets the box name

func (*DockerBox) GetTag

func (b *DockerBox) GetTag() string
func (b *DockerBox) Link() string

Link gives us the parameter to Docker to link to this box

func (*DockerBox) RecoverInteractive

func (b *DockerBox) RecoverInteractive(cwd string, pipeline core.Pipeline, step core.Step) error

RecoverInteractive restarts the box with a terminal attached

func (*DockerBox) Repository

func (b *DockerBox) Repository() string

func (*DockerBox) Restart

func (b *DockerBox) Restart() (*docker.Container, error)

Restart stops and starts the box

func (*DockerBox) Run

func (b *DockerBox) Run(ctx context.Context, env *util.Environment) (*docker.Container, error)

Run creates the container and runs it.

func (*DockerBox) RunServices

func (b *DockerBox) RunServices(ctx context.Context, env *util.Environment) error

RunServices runs the services associated with this box

func (*DockerBox) Stop

func (b *DockerBox) Stop()

Stop the box and all its services

type DockerBuild

type DockerBuild struct {
	*DockerPipeline
}

func NewDockerBuild

func NewDockerBuild(name string, config *core.Config, options *core.PipelineOptions, dockerOptions *DockerOptions, builder Builder) (*DockerBuild, error)

func (*DockerBuild) CollectArtifact

func (b *DockerBuild) CollectArtifact(containerID string) (*core.Artifact, error)

CollectArtifact copies the artifacts associated with the Build.

func (*DockerBuild) DockerMessage

func (b *DockerBuild) DockerMessage() string

DockerMessage calculates our message

func (*DockerBuild) DockerRepo

func (b *DockerBuild) DockerRepo() string

DockerRepo calculates our repo name

func (*DockerBuild) DockerTag

func (b *DockerBuild) DockerTag() string

DockerTag calculates our tag

func (*DockerBuild) InitEnv

func (b *DockerBuild) InitEnv(hostEnv *util.Environment)

InitEnv sets up the internal state of the environment for the build

func (b *DockerBuild) LocalSymlink()

LocalSymlink makes an easy to use symlink to find the latest run

type DockerClient

type DockerClient struct {
	*docker.Client
	// contains filtered or unexported fields
}

DockerClient is our wrapper for docker.Client

func DockerOrSkip

func DockerOrSkip(t *testing.T) *DockerClient

DockerOrSkip checks for a docker container and skips the test if one is not available

func NewDockerClient

func NewDockerClient(options *DockerOptions) (*DockerClient, error)

NewDockerClient based on options and env

func (*DockerClient) AttachInteractive

func (c *DockerClient) AttachInteractive(containerID string, cmd []string, initialStdin []string) error

AttachInteractive starts an interactive session and runs cmd

func (*DockerClient) AttachTerminal

func (c *DockerClient) AttachTerminal(containerID string) error

AttachTerminal connects us to container and gives us a terminal

func (*DockerClient) ExecOne

func (c *DockerClient) ExecOne(containerID string, cmd []string, output io.Writer) error

ExecOne uses docker exec to run a command in the container

func (*DockerClient) ResizeTTY

func (c *DockerClient) ResizeTTY(execID string) error

ResizeTTY resizes the tty size of docker connection so output looks normal

func (*DockerClient) RunAndAttach

func (c *DockerClient) RunAndAttach(name string) error

RunAndAttach gives us a raw connection to a newly run container

type DockerDeploy

type DockerDeploy struct {
	*DockerPipeline
}

DockerDeploy is our basic wrapper for DockerDeploy operations

func NewDockerDeploy

func NewDockerDeploy(name string, config *core.Config, options *core.PipelineOptions, dockerOptions *DockerOptions, builder Builder) (*DockerDeploy, error)

ToDeploy grabs the build section from the config and configures all the instances necessary for the build

func (*DockerDeploy) CollectArtifact

func (d *DockerDeploy) CollectArtifact(containerID string) (*core.Artifact, error)

CollectArtifact copies the artifacts associated with the Deploy. Unlike a Build, this will only collect the output directory if we made a new one.

func (*DockerDeploy) DockerMessage

func (d *DockerDeploy) DockerMessage() string

DockerMessage returns the message to store this with in docker

func (*DockerDeploy) DockerRepo

func (d *DockerDeploy) DockerRepo() string

DockerRepo returns the name where we might store this in docker

func (*DockerDeploy) DockerTag

func (d *DockerDeploy) DockerTag() string

DockerTag returns the tag where we might store this in docker

func (*DockerDeploy) InitEnv

func (d *DockerDeploy) InitEnv(hostEnv *util.Environment)

InitEnv sets up the internal state of the environment for the build

func (b *DockerDeploy) LocalSymlink()

LocalSymlink makes an easy to use symlink to find the latest run

type DockerFileCollector

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

DockerFileCollector impl of FileCollector

func NewDockerFileCollector

func NewDockerFileCollector(client *DockerClient, containerID string) *DockerFileCollector

NewDockerFileCollector constructor

func (*DockerFileCollector) Collect

func (fc *DockerFileCollector) Collect(path string) (*util.Archive, chan error)

Collect grabs a path and returns an archive containing stream along with an error channel to select on

type DockerOptions

type DockerOptions struct {
	DockerHost      string
	DockerTLSVerify string
	DockerCertPath  string
	DockerDNS       []string
	DockerLocal     bool
}

DockerOptions for our docker client

func MinimalDockerOptions

func MinimalDockerOptions() *DockerOptions

func NewDockerOptions

func NewDockerOptions(c util.Settings, e *util.Environment) (*DockerOptions, error)

NewDockerOptions constructor

type DockerPipeline

type DockerPipeline struct {
	*core.BasePipeline
	// contains filtered or unexported fields
}

DockerPipeline is our docker PipelineConfigurer and Pipeline impl

func NewDockerPipeline

func NewDockerPipeline(name string, config *core.Config, options *core.PipelineOptions, dockerOptions *DockerOptions, builder Builder) (*DockerPipeline, error)

func (*DockerPipeline) CollectCache

func (p *DockerPipeline) CollectCache(containerID string) error

CollectCache extracts the cache from the container to the cachedir

type DockerPushStep

type DockerPushStep struct {
	*core.BaseStep
	// contains filtered or unexported fields
}

DockerPushStep needs to implemenet IStep

func NewDockerPushStep

func NewDockerPushStep(stepConfig *core.StepConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (*DockerPushStep, error)

NewDockerPushStep is a special step for doing docker pushes

func (*DockerPushStep) CollectArtifact

func (s *DockerPushStep) CollectArtifact(string) (*core.Artifact, error)

CollectArtifact NOP

func (*DockerPushStep) CollectFile

func (s *DockerPushStep) CollectFile(a, b, c string, dst io.Writer) error

CollectFile NOP

func (*DockerPushStep) Execute

func (s *DockerPushStep) Execute(ctx context.Context, sess *core.Session) (int, error)

Execute commits the current container and pushes it to the configured registry

func (*DockerPushStep) Fetch

func (s *DockerPushStep) Fetch() (string, error)

Fetch NOP

func (*DockerPushStep) InitEnv

func (s *DockerPushStep) InitEnv(env *util.Environment)

InitEnv parses our data into our config

func (*DockerPushStep) ReportPath

func (s *DockerPushStep) ReportPath(...string) string

ReportPath NOP

func (*DockerPushStep) ShouldSyncEnv

func (s *DockerPushStep) ShouldSyncEnv() bool

ShouldSyncEnv before running this step = TRUE

type DockerScratchPushStep

type DockerScratchPushStep struct {
	*DockerPushStep
}

DockerScratchPushStep creates a new image based on a scratch tarball and pushes it

func NewDockerScratchPushStep

func NewDockerScratchPushStep(stepConfig *core.StepConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (*DockerScratchPushStep, error)

NewDockerScratchPushStep constructorama

func (*DockerScratchPushStep) CollectArtifact

func (s *DockerScratchPushStep) CollectArtifact(containerID string) (*core.Artifact, error)

CollectArtifact is copied from the build, we use this to get the layer tarball that we'll include in the image tarball

func (*DockerScratchPushStep) Execute

func (s *DockerScratchPushStep) Execute(ctx context.Context, sess *core.Session) (int, error)

Execute the scratch-n-push

type DockerStep

type DockerStep struct {
	*core.ExternalStep
	// contains filtered or unexported fields
}

DockerStep is an external step that knows how to fetch artifacts

func NewDockerStep

func NewDockerStep(config *core.StepConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (*DockerStep, error)

NewDockerStep ctor

func (*DockerStep) CollectArtifact

func (s *DockerStep) CollectArtifact(containerID string) (*core.Artifact, error)

CollectArtifact copies the artifacts associated with the Step.

func (*DockerStep) CollectFile

func (s *DockerStep) CollectFile(containerID, path, name string, dst io.Writer) error

CollectFile gets an individual file from the container

type DockerTransport

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

DockerTransport for docker containers

func (*DockerTransport) Attach

func (t *DockerTransport) Attach(sessionCtx context.Context, stdin io.Reader, stdout, stderr io.Writer) (context.Context, error)

Attach the given reader and writers to the transport, return a context that will be closed when the transport dies

type ExportImageOptions

type ExportImageOptions struct {
	Name         string
	OutputStream io.Writer
}

ExportImageOptions are the options available for ExportImage.

type ExposedPortMap

type ExposedPortMap struct {
	ContainerPort string
	HostURI       string
}

ExposedPortMap contains port forwarding information

type ExternalServiceBox

type ExternalServiceBox struct {
	*InternalServiceBox
	// contains filtered or unexported fields
}

ExternalServiceBox wraps a box as a service

func NewExternalServiceBox

func NewExternalServiceBox(boxConfig *core.BoxConfig, options *core.PipelineOptions, dockerOptions *DockerOptions, builder Builder) (*ExternalServiceBox, error)

NewExternalServiceBox gives us an ExternalServiceBox from config

func (*ExternalServiceBox) Fetch

func (s *ExternalServiceBox) Fetch(ctx context.Context, env *util.Environment) (*docker.Image, error)

Fetch the image representation of an ExternalServiceBox this means running the ExternalServiceBox and comitting the image

type InternalServiceBox

type InternalServiceBox struct {
	*DockerBox
	// contains filtered or unexported fields
}

InternalServiceBox wraps a box as a service

func NewInternalServiceBox

func NewInternalServiceBox(boxConfig *core.BoxConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (*InternalServiceBox, error)

NewServiceBox from a name and other references

func (*InternalServiceBox) Run

func (b *InternalServiceBox) Run(ctx context.Context, env *util.Environment, links []string) (*docker.Container, error)

Run executes the service

type JSONMessageProcessor

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

A JSONMessageProcessor will process JSONMessages and generate logs.

func NewJSONMessageProcessor

func NewJSONMessageProcessor() *JSONMessageProcessor

NewJSONMessageProcessor will create a new JSONMessageProcessor and initialize it.

func (*JSONMessageProcessor) ProcessJSONMessage

func (s *JSONMessageProcessor) ProcessJSONMessage(m *jsonmessage.JSONMessage) string

ProcessJSONMessage will take JSONMessage m and generate logs based on the message and previous messages.

type ShellStep

type ShellStep struct {
	*core.BaseStep
	Code string
	Cmd  []string
	// contains filtered or unexported fields
}

ShellStep needs to implemenet IStep

func NewShellStep

func NewShellStep(stepConfig *core.StepConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (*ShellStep, error)

NewShellStep is a special step for doing docker pushes

func (*ShellStep) CollectArtifact

func (s *ShellStep) CollectArtifact(string) (*core.Artifact, error)

CollectArtifact NOP

func (*ShellStep) CollectFile

func (s *ShellStep) CollectFile(a, b, c string, dst io.Writer) error

CollectFile NOP

func (*ShellStep) Execute

func (s *ShellStep) Execute(ctx context.Context, sess *core.Session) (int, error)

Execute a shell and give it to the user

func (*ShellStep) Fetch

func (s *ShellStep) Fetch() (string, error)

Fetch NOP

func (*ShellStep) InitEnv

func (s *ShellStep) InitEnv(env *util.Environment)

InitEnv parses our data into our config

func (*ShellStep) ReportPath

func (s *ShellStep) ReportPath(...string) string

ReportPath getter

func (*ShellStep) ShouldSyncEnv

func (s *ShellStep) ShouldSyncEnv() bool

ShouldSyncEnv before running this step = TRUE

type StoreContainerStep

type StoreContainerStep struct {
	*core.BaseStep
	// contains filtered or unexported fields
}

StoreContainerStep stores the container that was built

func NewStoreContainerStep

func NewStoreContainerStep(stepConfig *core.StepConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (*StoreContainerStep, error)

NewStoreContainerStep constructor

func (*StoreContainerStep) CollectArtifact

func (s *StoreContainerStep) CollectArtifact(string) (*core.Artifact, error)

CollectArtifact return an artifact pointing at the exported thing we made

func (*StoreContainerStep) CollectFile

func (s *StoreContainerStep) CollectFile(a, b, c string, dst io.Writer) error

CollectFile NOP

func (*StoreContainerStep) DockerMessage

func (s *StoreContainerStep) DockerMessage() string

DockerMessage calculates our message

func (*StoreContainerStep) DockerRepo

func (s *StoreContainerStep) DockerRepo() string

DockerRepo calculates our repo name

func (*StoreContainerStep) DockerTag

func (s *StoreContainerStep) DockerTag() string

DockerTag calculates our tag

func (*StoreContainerStep) Execute

func (s *StoreContainerStep) Execute(ctx context.Context, sess *core.Session) (int, error)

Execute does the actual export and upload of the container

func (*StoreContainerStep) Fetch

func (s *StoreContainerStep) Fetch() (string, error)

Fetch NOP

func (*StoreContainerStep) InitEnv

func (s *StoreContainerStep) InitEnv(env *util.Environment)

InitEnv preps our env

func (*StoreContainerStep) ReportPath

func (s *StoreContainerStep) ReportPath(...string) string

ReportPath NOP

func (*StoreContainerStep) ShouldSyncEnv

func (s *StoreContainerStep) ShouldSyncEnv() bool

ShouldSyncEnv before running this step = TRUE

type WatchStep

type WatchStep struct {
	*core.BaseStep
	Code string
	// contains filtered or unexported fields
}

WatchStep needs to implemenet IStep

func NewWatchStep

func NewWatchStep(stepConfig *core.StepConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (*WatchStep, error)

NewWatchStep is a special step for doing docker pushes

func (*WatchStep) CollectArtifact

func (s *WatchStep) CollectArtifact(string) (*core.Artifact, error)

CollectArtifact NOP

func (*WatchStep) CollectFile

func (s *WatchStep) CollectFile(a, b, c string, dst io.Writer) error

CollectFile NOP

func (*WatchStep) Execute

func (s *WatchStep) Execute(ctx context.Context, sess *core.Session) (int, error)

Execute runs a command and optionally reloads it

func (*WatchStep) Fetch

func (s *WatchStep) Fetch() (string, error)

Fetch NOP

func (*WatchStep) InitEnv

func (s *WatchStep) InitEnv(env *util.Environment)

InitEnv parses our data into our config

func (*WatchStep) ReportPath

func (s *WatchStep) ReportPath(...string) string

ReportPath getter

func (*WatchStep) ShouldSyncEnv

func (s *WatchStep) ShouldSyncEnv() bool

ShouldSyncEnv before running this step = FALSE

Jump to

Keyboard shortcuts

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