build

package
v0.6.1-0...-ac866f0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package build defines methods for building a v1.Image reference from a Go binary reference.

Index

Constants

View Source
const StrictScheme = "ko://"

StrictScheme is a prefix that can be placed on import paths that users think MUST be supported references.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caching

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

Caching wraps a builder implementation in a layer that shares build results for the same inputs using a simple "future" implementation. Cached results may be invalidated by calling Invalidate with the same input passed to Build.

func NewCaching

func NewCaching(inner Interface) (*Caching, error)

NewCaching wraps the provided build.Interface in an implementation that shares build results for a given path until the result has been invalidated.

func (*Caching) Build

func (c *Caching) Build(ctx context.Context, ip string) (Result, error)

Build implements Interface

func (*Caching) Invalidate

func (c *Caching) Invalidate(ip string)

Invalidate removes an import path's cached results.

func (*Caching) IsSupportedReference

func (c *Caching) IsSupportedReference(ip string) error

IsSupportedReference implements Interface

type GetBase

type GetBase func(string) (Result, error)

GetBase takes an importpath and returns a base image.

type Interface

type Interface interface {
	// IsSupportedReference determines whether the given reference is to an
	// importpath reference that Ko supports building, returning an error
	// if it is not.
	// TODO(mattmoor): Verify that some base repo: foo.io/bar can be suffixed with this reference and parsed.
	IsSupportedReference(string) error

	// Build turns the given importpath reference into a v1.Image containing the Go binary
	// (or a set of images as a v1.ImageIndex).
	Build(context.Context, string) (Result, error)
}

Interface abstracts different methods for turning a supported importpath reference into a v1.Image.

func NewGo

func NewGo(options ...Option) (Interface, error)

NewGo returns a build.Interface implementation that:

  1. builds go binaries named by importpath,
  2. containerizes the binary on a suitable base,

type Limiter

type Limiter struct {
	Builder Interface
	// contains filtered or unexported fields
}

Limiter composes with another Interface to limit the number of concurrent builds.

func NewLimiter

func NewLimiter(b Interface, n int) *Limiter

NewLimiter returns a new builder that only allows n concurrent builds of b.

func (*Limiter) Build

func (l *Limiter) Build(ctx context.Context, ip string) (Result, error)

Build implements Interface

func (*Limiter) IsSupportedReference

func (l *Limiter) IsSupportedReference(ip string) error

IsSupportedReference implements Interface

type Option

type Option func(*gobuildOpener) error

Option is a functional option for NewGo.

func WithBaseImages

func WithBaseImages(gb GetBase) Option

WithBaseImages is a functional option for overriding the base images that are used for different images.

func WithCreationTime

func WithCreationTime(t v1.Time) Option

WithCreationTime is a functional option for overriding the creation time given to images.

func WithDisabledOptimizations

func WithDisabledOptimizations() Option

WithDisabledOptimizations is a functional option for disabling optimizations when compiling.

type Recorder

type Recorder struct {
	ImportPaths []string
	Builder     Interface
	// contains filtered or unexported fields
}

Recorder composes with another Interface to record the built import paths.

func (*Recorder) Build

func (r *Recorder) Build(ctx context.Context, ip string) (Result, error)

Build implements Interface

func (*Recorder) IsSupportedReference

func (r *Recorder) IsSupportedReference(ip string) error

IsSupportedReference implements Interface

type Result

type Result interface {
	MediaType() (types.MediaType, error)
	Size() (int64, error)
	Digest() (v1.Hash, error)
	RawManifest() ([]byte, error)
}

Result represents the product of a Build. This is usually a v1.Image or v1.ImageIndex.

Jump to

Keyboard shortcuts

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