docker

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 33 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DockerRepoLabel     = "com.opentable.sous.repo_url"
	DockerPathLabel     = "com.opentable.sous.repo_offset"
	DockerVersionLabel  = "com.opentable.sous.version"
	DockerRevisionLabel = "com.opentable.sous.revision"
)
View Source
const (
	// AppVersionBuildArg is the name of a docker build argument used to inject
	// the version of the app being built.
	AppVersionBuildArg = "APP_VERSION"
	// AppRevisionBuildArg is the name of a docker build argument used to inject
	// the revision of the app being built.
	AppRevisionBuildArg = "APP_REVISION"
)
View Source
const BuildCacheEnv = "BUILD_CACHE"

BuildCacheEnv is an environment variable a runmount image may set

View Source
const BuildOutEnv = "BUILD_OUT"

BuildOutEnv is the other environment variable a runmount image must set

View Source
const SOUS_RUN_IMAGE_SPEC = "SOUS_RUN_IMAGE_SPEC"

SOUS_RUN_IMAGE_SPEC is the env name that build containers must declare with the path to their runspec file.

Variables

This section is empty.

Functions

func Labels

func Labels(sid sous.SourceID, rev string) map[string]string

Labels computes a map of labels that should be applied to a container image that is built based on this SourceID.

func NewBuildArtifact

func NewBuildArtifact(imageName string, qstrs strpairs) *sous.BuildArtifact

NewBuildArtifact creates a new sous.BuildArtifact representing a Docker image. XXX this should be removed in favor of sous.NewBuildArtifact

func NewBuildStrategySelector added in v1.0.1

func NewBuildStrategySelector(ls logging.LogSink, rc docker_registry.Client) sous.Selector

NewBuildStrategySelector constructs a sous.Selector that uses docker build images as its strategies

func SourceIDFromLabels

func SourceIDFromLabels(labels map[string]string) (sous.SourceID, error)

SourceIDFromLabels builds a SourceID from a map of labels, generally acquired from a Docker image.

Types

type Args

type Args interface {
	String() string
}

type ArrayArg

type ArrayArg []string

type ArrayArgs

type ArrayArgs []string

func (ArrayArgs) String

func (a ArrayArgs) String() string

type BuildTarget

type BuildTarget interface {
	BuildImage()
	BuildContainer()
}

BuildTarget represents a single target within a Build.

type Builder

type Builder struct {
	ImageMapper               sous.Inserter
	DockerRegistryHost        string
	SourceShell, ScratchShell shell.Shell
	Pack                      sous.Buildpack
	// contains filtered or unexported fields
}

Builder represents a single build of a project.

func NewBuilder

func NewBuilder(nc sous.Inserter, drh string, sourceShell, scratchShell shell.Shell, ls logging.LogSink) (*Builder, error)

NewBuilder creates a new build using source code in the working directory of sourceShell, and using the working dir of scratchShell as temporary storage.

func (*Builder) ApplyMetadata

func (b *Builder) ApplyMetadata(br *sous.BuildResult) error

ApplyMetadata implements sous.Labeller on Builder. It applies container metadata etc. to a container.

func (*Builder) Register

func (b *Builder) Register(br *sous.BuildResult) error

Register registers the build artifact to the the registry

func (*Builder) RevisionTag

func (b *Builder) RevisionTag(v sous.SourceID, rev string, kind string, time time.Time) string

RevisionTag computes an image tag from a SourceVersion's revision id

func (*Builder) VersionTag

func (b *Builder) VersionTag(v sous.SourceID, kind string) string

VersionTag computes an image tag from a SourceVersion's version

type Config

type Config struct {
	RegistryHost string `env:"SOUS_DOCKER_REGISTRY_HOST"`
}

func DefaultConfig

func DefaultConfig() Config

DefaultConfig builds a default configuration, which can be then overridden by client code.

type DBConfig

type DBConfig struct {
	Driver, Connection string
}

DBConfig is a database configuration for a NameCache.

type DockerfileBuildpack

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

DockerfileBuildpack is a simple buildpack for building projects using their own Dockerfile.

func NewDockerfileBuildpack

func NewDockerfileBuildpack(ls logging.LogSink) *DockerfileBuildpack

NewDockerfileBuildpack creates a Dockerfile buildpack

func (*DockerfileBuildpack) Build

func (d *DockerfileBuildpack) Build(c *sous.BuildContext) (*sous.BuildResult, error)

Build implements Buildpack.Build

func (*DockerfileBuildpack) Detect

func (d *DockerfileBuildpack) Detect(c *sous.BuildContext) (*sous.DetectResult, error)

Detect detects if c has a Dockerfile or not.

type File

type File struct {
	From, Maintainer string
	Instructions     Instructions
}

func (*File) ADD

func (f *File) ADD(target string, files ...string)

func (*File) CMD

func (f *File) CMD(args ...string)

func (*File) COPY

func (f *File) COPY(target string, files ...string)

func (*File) ENTRYPOINT

func (f *File) ENTRYPOINT(args ...string)

func (*File) ENV

func (f *File) ENV(m map[string]string)

func (*File) LABEL

func (f *File) LABEL(m map[string]string)

func (*File) RUN

func (f *File) RUN(args ...string)

func (File) String

func (f File) String() string

func (*File) USER

func (f *File) USER(username string)

func (*File) WORKDIR

func (f *File) WORKDIR(path string)

type Instruction

type Instruction struct {
	Name string
	Args Args
}

func (Instruction) String

func (i Instruction) String() string

type Instructions

type Instructions []Instruction

func (*Instructions) Add

func (is *Instructions) Add(name string, args Args)

func (Instructions) String

func (is Instructions) String() string

type KeyValueArgs

type KeyValueArgs map[string]string

func (KeyValueArgs) Flatten

func (kv KeyValueArgs) Flatten() []string

func (KeyValueArgs) String

func (kv KeyValueArgs) String() string

type MultiImageRunSpec added in v1.0.1

type MultiImageRunSpec struct {
	*SplitImageRunSpec `json:",omitempty"`
	Images             []SplitImageRunSpec `json:"images"`
}

A MultiImageRunSpec is the JSON structure that build containers emit in order that their associated deploy containers can be assembled It *can* parse the same structure as SplitImageRunSpec, because there are a few builds that already use that format.

func (MultiImageRunSpec) Normalized added in v1.0.1

func (ms MultiImageRunSpec) Normalized() MultiImageRunSpec

Normalized returns a MultiImageRunSpec where all the SplitImageRunSpecs are in Images.

func (*MultiImageRunSpec) Validate added in v1.0.1

func (ms *MultiImageRunSpec) Validate() []sous.Flaw

Validate implements Flawed on MultiImageRunSpec

type NameCache

type NameCache struct {
	sync.Mutex
	RegistryClient     docker_registry.Client
	DB                 *sql.DB
	DockerRegistryHost string
	// contains filtered or unexported fields
}

NameCache is a database for looking up SourceIDs based on Docker image names and vice versa.

func NewNameCache

func NewNameCache(drh string, cl docker_registry.Client, ls logging.LogSink, db *sql.DB) (*NameCache, error)

NewNameCache builds a new name cache. XXX remove error return value

func (*NameCache) GetArtifact

func (nc *NameCache) GetArtifact(sid sous.SourceID) (*sous.BuildArtifact, error)

GetArtifact implements sous.Registry.GetArtifact.

func (*NameCache) GetCanonicalName

func (nc *NameCache) GetCanonicalName(in string) (string, error)

GetCanonicalName returns the canonical name for an image given any known name

func (*NameCache) GetSourceID

func (nc *NameCache) GetSourceID(a *sous.BuildArtifact) (sous.SourceID, error)

GetSourceID looks up the source ID for a given image name.

xxx consider un-exporting

func (*NameCache) ImageLabels added in v0.0.3

func (nc *NameCache) ImageLabels(in string) (map[string]string, error)

ImageLabels gets the labels for an image name.

func (*NameCache) Insert added in v0.0.3

func (nc *NameCache) Insert(sid sous.SourceID, ba sous.BuildArtifact) error

Insert puts a given SourceID/image name pair into the name cache used by Builder at the moment to register after a build

func (*NameCache) ListSourceIDs

func (nc *NameCache) ListSourceIDs() ([]sous.SourceID, error)

ListSourceIDs lists all the known SourceIDs.

func (*NameCache) Warmup

func (nc *NameCache) Warmup(r string) error

Warmup warms up the cache.

type NoImageNameFound

type NoImageNameFound struct {
	sous.SourceID
}

NoImageNameFound is returned when we cannot find an image name for a given SourceID.

func (NoImageNameFound) Error

func (e NoImageNameFound) Error() string

type NoSourceIDFound

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

NoSourceIDFound is returned when we cannot find a SourceID for a given image name

func (NoSourceIDFound) Error

func (e NoSourceIDFound) Error() string

type NotModifiedErr

type NotModifiedErr struct{}

NotModifiedErr is returned when an HTTP server returns Not Modified in response to a conditional request

func (NotModifiedErr) Error

func (e NotModifiedErr) Error() string

type RunmountBuildpack added in v1.0.1

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

RunmountBuildpack builds a container, runs it seperately to use docker mounts for cache and output, and builds final deploy container

func NewRunmountBuildpack added in v1.0.1

func NewRunmountBuildpack(r docker_registry.Client, ls logging.LogSink) *RunmountBuildpack

NewRunmountBuildpack returns a new RunmountBuildpack

func (*RunmountBuildpack) Build added in v1.0.1

func (rmbp *RunmountBuildpack) Build(ctx *sous.BuildContext) (*sous.BuildResult, error)

Build implements Buildpack on RunmountBuildpack

func (*RunmountBuildpack) Detect added in v1.0.1

func (rmbp *RunmountBuildpack) Detect(ctx *sous.BuildContext) (*sous.DetectResult, error)

Detect implements Buildpack on SplitBuildpack

type SingleArg

type SingleArg string

func (SingleArg) String

func (s SingleArg) String() string

type SpaceSeparatedArgs

type SpaceSeparatedArgs []string

func (SpaceSeparatedArgs) String

func (s SpaceSeparatedArgs) String() string

type SplitBuildpack added in v1.0.1

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

A SplitBuildpack implements the pattern of using a build container and producing a separate deploy container

func NewSplitBuildpack added in v1.0.1

func NewSplitBuildpack(r docker_registry.Client, ls logging.LogSink) *SplitBuildpack

NewSplitBuildpack returns a new SplitBuildpack

func (*SplitBuildpack) Build added in v1.0.1

func (sbp *SplitBuildpack) Build(ctx *sous.BuildContext) (*sous.BuildResult, error)

Build implements Buildpack on SplitBuildpack

func (*SplitBuildpack) Detect added in v1.0.1

func (sbp *SplitBuildpack) Detect(ctx *sous.BuildContext) (*sous.DetectResult, error)

Detect implements Buildpack on SplitBuildpack

type SplitImageRunSpec added in v1.0.1

type SplitImageRunSpec struct {
	// Kind is used to denote that the image isn't a "normal" i.e. deployable
	// service image, but instead some other kind. Examples include "builder" or
	// "test" or "uploader"
	Kind string `json:"kind"`

	// Offset is the usual Sous offset: the path relative to the root of the
	// project that selects one of several services built from the same codebase.
	Offset string `json:"offset"`

	// Image describes the base of the deploy image. type should be "docker" and
	// from should be a suitable FROM image.
	Image sbmImage `json:"image"`

	// Files maps directories of built files in the build container to their
	// destination in the deploy container.
	Files []sbmInstall `json:"files"`

	// Exec describes the command to ultimately run in the deploy container -
	// essentially a Docker ENTRYPOINT
	Exec []string `json:"exec"`
}

A SplitImageRunSpec is the JSON structure that describes an individual deploy container.

func (*SplitImageRunSpec) Validate added in v1.0.1

func (rs *SplitImageRunSpec) Validate() []sous.Flaw

Validate implements Flawed on SplitImageRunSpec

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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