builder

package
v3.9.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: Apache-2.0 Imports: 59 Imported by: 0

Documentation

Overview

Package builder contains builders for STI and Docker in OpenShift Origin

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultPushOrPullRetryCount is the number of retries of pushing or pulling the built Docker image
	// into a configured repository
	DefaultPushOrPullRetryCount = 6
	// DefaultPushOrPullRetryDelay is the time to wait before triggering a push or pull retry
	DefaultPushOrPullRetryDelay = 5 * time.Second
	// RetriableErrors is a set of strings that indicate that an retriable error occurred.
	RetriableErrors = []string{
		"ping attempt failed with error",
		"is already in progress",
		"connection reset by peer",
		"transport closed before response was received",
		"connection refused",
		"no route to host",
		"unexpected end of JSON input",
		"i/o timeout",
		"TLS handshake timeout",
	}
)

Functions

func ExtractImageContent added in v3.7.0

func ExtractImageContent(ctx context.Context, dockerClient DockerClient, dir string, build *buildapiv1.Build) error

func ExtractInputBinary added in v3.7.0

func ExtractInputBinary(in io.Reader, source *buildapiv1.BinaryBuildSource, dir string) error

ExtractInputBinary processes the provided input stream as directed by BinaryBuildSource into dir.

func GetCGroupLimits

func GetCGroupLimits() (*s2iapi.CGroupLimits, error)

GetCGroupLimits returns a struct populated with cgroup limit values gathered from the local /sys/fs/cgroup filesystem. Overflow values are set to math.MaxInt64.

func GetDockerClient

func GetDockerClient() (client *docker.Client, endpoint string, err error)

GetDockerClient returns a valid Docker client, the address of the client, or an error if the client couldn't be created.

func GetSourceRevision added in v3.7.0

func GetSourceRevision(build *buildapiv1.Build, sourceInfo *git.SourceInfo) *buildapiv1.SourceRevision

GetSourceRevision returns a SourceRevision object either from the build (if it already had one) or by creating one from the sourceInfo object passed in.

func GitClone added in v3.7.0

func GitClone(ctx context.Context, gitClient GitClient, gitSource *buildapiv1.GitBuildSource, revision *buildapiv1.SourceRevision, dir string) (*git.SourceInfo, error)

GitClone clones the source associated with a build(if any) into the specified directory

func HandleBuildStatusUpdate added in v3.7.0

func HandleBuildStatusUpdate(build *buildapiv1.Build, client buildclientv1.BuildInterface, sourceRev *buildapiv1.SourceRevision)

HandleBuildStatusUpdate handles updating the build status retries occur on update conflict and unreachable api server

func ManageDockerfile added in v3.7.0

func ManageDockerfile(dir string, build *buildapiv1.Build) error

ManageDockerfile manipulates the dockerfile for docker builds. It will write the inline dockerfile to the working directory (possibly overwriting an existing dockerfile) and then update the dockerfile in the working directory (accounting for contextdir+dockerfilepath) with new FROM image information based on the imagestream/imagetrigger and also adds some env and label values to the dockerfile based on the build information.

func MergeEnv

func MergeEnv(oldEnv, newEnv []string) []string

MergeEnv will take an existing environment and merge it with a new set of variables. For variables with the same name in both, only the one in the new environment will be kept.

func RetryImageAction

func RetryImageAction(client DockerClient, opts interface{}, authConfig docker.AuthConfiguration) error

func SafeForLoggingDockerConfig

func SafeForLoggingDockerConfig(config *docker.Config) *docker.Config

SafeForLoggingDockerConfig returns a copy of a docker config struct where any proxy credentials in the env section of the config have been redacted.

func SafeForLoggingDockerCreateOptions

func SafeForLoggingDockerCreateOptions(opts *docker.CreateContainerOptions) *docker.CreateContainerOptions

SafeForLoggingDockerCreateOptions returns a copy of a docker create container options struct where any proxy credentials in the env section of the config have been redacted.

func SafeForLoggingEnvironmentList added in v3.8.0

func SafeForLoggingEnvironmentList(env s2iapi.EnvironmentList) s2iapi.EnvironmentList

SafeForLoggingEnvironmentList returns a copy of an s2i EnvironmentList array with proxy credential values redacted.

func SafeForLoggingS2IConfig added in v3.8.0

func SafeForLoggingS2IConfig(config *s2iapi.Config) *s2iapi.Config

SafeForLoggingS2IConfig returns a copy of an s2i Config with proxy credentials redacted.

Types

type DockerBuilder

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

DockerBuilder builds Docker images given a git repository URL

func NewDockerBuilder

func NewDockerBuilder(dockerClient DockerClient, buildsClient buildclientv1.BuildInterface, build *buildapiv1.Build, cgLimits *s2iapi.CGroupLimits) *DockerBuilder

NewDockerBuilder creates a new instance of DockerBuilder

func (*DockerBuilder) Build

func (d *DockerBuilder) Build() error

Build executes a Docker build

type DockerClient

type DockerClient interface {
	AttachToContainerNonBlocking(opts docker.AttachToContainerOptions) (docker.CloseWaiter, error)
	BuildImage(opts docker.BuildImageOptions) error
	PushImage(opts docker.PushImageOptions, auth docker.AuthConfiguration) error
	RemoveImage(name string) error
	CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error)
	DownloadFromContainer(id string, opts docker.DownloadFromContainerOptions) error
	PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
	RemoveContainer(opts docker.RemoveContainerOptions) error
	InspectImage(name string) (*docker.Image, error)
	StartContainer(id string, hostConfig *docker.HostConfig) error
	WaitContainer(id string) (int, error)
	Logs(opts docker.LogsOptions) error
	TagImage(name string, opts docker.TagImageOptions) error
}

DockerClient is an interface to the Docker client that contains the methods used by the common builder

type GitClient

type GitClient interface {
	CloneWithOptions(dir string, url string, args ...string) error
	Fetch(dir string, url string, ref string) error
	Checkout(dir string, ref string) error
	PotentialPRRetryAsFetch(dir string, url string, ref string, err error) error
	SubmoduleUpdate(dir string, init, recursive bool) error
	TimedListRemote(timeout time.Duration, url string, args ...string) (string, string, error)
	GetInfo(location string) (*git.SourceInfo, []error)
}

GitClient performs git operations

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

KeyValue can be used to build ordered lists of key-value pairs.

type S2IBuilder

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

S2IBuilder performs an STI build given the build object

func NewS2IBuilder

func NewS2IBuilder(dockerClient DockerClient, dockerSocket string, buildsClient buildclientv1.BuildInterface, build *buildapiv1.Build,
	cgLimits *s2iapi.CGroupLimits) *S2IBuilder

NewS2IBuilder creates a new STIBuilder instance

func (*S2IBuilder) Build

func (s *S2IBuilder) Build() error

Build executes S2I build based on configured builder, S2I builder factory and S2I config validator

Directories

Path Synopsis
cmd
Package cmd contains the main entry point for the docker and STI builders
Package cmd contains the main entry point for the docker and STI builders
dockercfg
Package dockercfg contains a command helper to read .dockercfg files
Package dockercfg contains a command helper to read .dockercfg files
scmauth
Package scmauth provides SCM authentication methods based on secret files
Package scmauth provides SCM authentication methods based on secret files
dockerfile
Package dockerfile has utilities that complement Docker's official Dockerfile parser.
Package dockerfile has utilities that complement Docker's official Dockerfile parser.

Jump to

Keyboard shortcuts

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