buildkit

package
v0.0.0-...-4c17a3b Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommandExecutor = exec.CommandContext

Exposing this as a dependency injection for testing purposes.

View Source
var ImagePath = fmt.Sprintf("%s/%s", os.TempDir(), "image")
View Source
var MetadataPath = fmt.Sprintf("%s/%s", os.TempDir(), "metadata.json")

Functions

func ConnectRemoteDriver

func ConnectRemoteDriver(ctx context.Context) error

Connect the buildx to the buildkitd instance running on the socket (in the sidecar within this pod). Here buildx gets configured to use the remote driver. This method will block until it either see the remote driver fully connected or returns an unhandled error.

func ParseAttribute

func ParseAttribute(ctx context.Context, reader io.Reader, collection *[]Pair) error

ParseAttribute will attempt to parse the readers as JSON payload. If the parsing is successful, the content of the JSON payload will be stored in the collection pointer.

Types

type BuildOption

type BuildOption func(*Builder) error

///////////////////////////////////////////////////////////////////////// Build Options

func WithArguments

func WithArguments(arguments []Pair) BuildOption

Pair of Key/Value that will be passed as build arguments when building the image.

func WithRepository

func WithRepository(repo *source.Repository) BuildOption

Use a fully configured repository

func WithSSHKeys

func WithSSHKeys(keys []Pair) BuildOption

Pair of Key/Value that will be stored on disk and be passed to BuildKit so that the Dockerfile can mount those as ssh keys. https://docs.docker.com/build/building/secrets/#ssh-mounts

func WithSecrets

func WithSecrets(secrets []Pair) BuildOption

Pair of Key/Value that will be stored on disk and be passed to BuildKit so that the Dockerfile can mount those secrets. https://docs.docker.com/build/building/secrets/

func WithTags

func WithTags(tags ...string) BuildOption

List of tags to tag the image with. Will also be used with the cache layer. Requires at least one tag.

type Builder

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

func NewBuilder

func NewBuilder(ref name.Reference, opts ...BuildOption) (*Builder, error)

Create a new Build ready to be executed. The reference is the registry reference that was used to configure the registry. It will be used to store the cache layers over to distribution. See the different BuildOption below to learn about the different options. Returns an error if any of the option passed fails to configure the Builder.

func (*Builder) Execute

func (b *Builder) Execute(ctx context.Context) (gcr.ImageIndex, []byte, error)

Build the repository into an ImageIndex (OCI Standard) The context is set around the repository which means it needs to be present in the filesystem.

The build execute buildkit as a system command directly and pipes both STDOUT and STDERR to their respective file descriptor.

The error that returns from Build is any error that is returned from the buildkit process.

The ImageIndex is generated from go-containerregistry and is a valid OCI ImageIndex that can be exported to any container registry.

Metadata from the build is return a valid JSON as a byteslice.

type Pair

type Pair struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Argument represent a key/value pair that was passed in as an environment variable. In a linux system, it would be represented as a `KEY=Value` environment variable. The argument list is stored as a JSON payload, and those values needs to be extracted from it before it can be passed to buildkit.

Jump to

Keyboard shortcuts

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