build

package
v0.2.3 Latest Latest
Warning

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

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

Documentation

Overview

Package build implements the logic for executing a single user build.

Index

Constants

View Source
const StartStep = "-"

StartStep is a build step WaitFor dependency that is always satisfied.

Variables

View Source
var (

	// RunRm : if true, all `docker run` commands will be passed a `--rm` flag.
	RunRm = false
)

Functions

This section is empty.

Types

type Build

type Build struct {
	// Lock to update the status of a build or read/write digests.
	Mu               sync.Mutex
	Request          cb.Build
	HasMultipleSteps bool
	Tokensource      oauth2.TokenSource
	Log              *buildlog.BuildLog
	Status           BuildStatus

	Runner         runner.Runner
	Done           chan struct{}
	Times          map[BuildStatus]time.Duration
	LastStateStart time.Time

	// PushErrors tracks how many times a push got retried. This
	// field is not protected by a mutex because the worker will
	// only read it once the build is done, and the build only
	// updates it before the build is done.
	PushErrors     int
	GCRErrors      map[string]int64
	NumSourceBytes int64
	// contains filtered or unexported fields
}

Build manages a single build.

func New

func New(r runner.Runner, rq cb.Build, ts oauth2.TokenSource,
	bl *buildlog.BuildLog, hostWorkspaceDir string, local, push bool) *Build

New constructs a new Build.

func (*Build) Failbuild

func (b *Build) Failbuild(err error)

Failbuild updates the build's status to failure.

func (*Build) GetStatus

func (b *Build) GetStatus() BuildStatus

GetStatus returns the build's status in a thread-safe way.

func (*Build) SetDockerAccessToken added in v0.0.5

func (b *Build) SetDockerAccessToken(tok string) error

SetDockerAccessToken sets the initial Docker config with the credentials we use to authorize requests to GCR. https://cloud.google.com/container-registry/docs/advanced-authentication#using_an_access_token

func (*Build) Start

func (b *Build) Start()

Start executes a single build.

func (*Build) Summary

func (b *Build) Summary() BuildSummary

Summary returns the build's summary in a thread-safe way.

func (*Build) UpdateDockerAccessToken

func (b *Build) UpdateDockerAccessToken(tok string) error

UpdateDockerAccessToken updates the credentials we use to authorize requests to GCR. https://cloud.google.com/container-registry/docs/advanced-authentication#using_an_access_token

func (*Build) UpdateStatus

func (b *Build) UpdateStatus(status BuildStatus)

UpdateStatus updates the current status.

type BuildStatus

type BuildStatus string

BuildStatus is a pseudo-enum of valid build states.

const (
	// StatusFetchSource - Fetching source.
	StatusFetchSource BuildStatus = "FETCHSOURCE"
	// StatusBuild - Executing the build step images on the source.
	StatusBuild BuildStatus = "BUILD"
	// StatusPush - Pushing the resultant image to GCR.
	StatusPush BuildStatus = "PUSH"
	// StatusDone - Build completed successfully.
	StatusDone BuildStatus = "DONE"
	// StatusError - Build failed.
	StatusError BuildStatus = "ERROR"
)

type BuildSummary

type BuildSummary struct {
	Status          BuildStatus
	BuiltImages     []BuiltImage
	BuildStepImages []string // index of build step -> digest, else empty string
	FileHashes      map[string][]Hash
}

BuildSummary is the data returned by the blocking /build/status endpoint.

type BuiltImage

type BuiltImage struct {
	// Name is the full name of an image, as given to 'docker pull $NAME'.
	Name string
	// Digest is the digest reported by registry2.0, if available. If not
	// available, it will be the empty string.
	Digest string
}

BuiltImage is information about an image that resulted from this build and was pushed to an image registry.

type Hash

type Hash struct {
	// Type of the hash.
	Type HashType
	// Value of the hash.
	Value []byte
}

Hash captures a hash by HashType and Value.

type HashType

type HashType string

HashType is a pseudo-enum of valid SourceHashes.

const (
	// MD5 indicates hash type md5.
	MD5 HashType = "MD5"
	// SHA256 indicates hash type sha256.
	SHA256 HashType = "SHA256"
	// No hash requested.
	NONE HashType = "NONE"
)

These constants match those in pb cloudbuild.proto pb.Hash.HashType.

Jump to

Keyboard shortcuts

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