ko

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ko builds and publishes images referenced by manifests, replacing the run_ko helper in the shell installer.

ko stays an external binary. It is pinned as a Go tool in hack/tools/ko and located the same way hack/run-tool.sh locates it, so ate-setup and the remaining shell scripts build with identical ko versions. Only `ko resolve` is ever invoked: the resolved manifest is applied through client-go, which removes the need for ko's kubectl delegation and the `-- --context=` special case that run_ko carried.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildVersion

func BuildVersion(root string) string

BuildVersion is the VERSION environment variable, else `git describe`, or "dev" when git has nothing to say. It is what ko stamps into the binaries.

func CommitStamp added in v1.0.0

func CommitStamp(root string) (commit, date string, ok bool)

CommitStamp returns the commit checked out at root and its committer date in RFC 3339 form. ok is false when root has no commit, as in a source tarball.

func Ldflags added in v1.0.0

func Ldflags(root string) []string

Ldflags returns the -X flags that stamp a binary built from root with internal/version's Version, and with Commit and BuildDate when root has a commit checked out. internal/version replaces a stamped Version with the module's build info unless Commit is stamped too. BuildDate is the commit's time, so rebuilding one commit gives the same binary.

Types

type Runner

type Runner struct {
	// Root is the repository root; ko runs with this as its working directory.
	Root string
	// Env holds extra environment entries such as KO_DOCKER_REPO.
	Env []string
	// Stderr receives ko's build progress output.
	Stderr *os.File
	// contains filtered or unexported fields
}

Runner invokes ko with a fixed repository root and environment.

func New

func New(root string, env []string) (*Runner, error)

New returns a Runner, resolving the ko binary once up front so a missing tool fails before any cluster mutation happens.

func (*Runner) Build

func (r *Runner) Build(ctx context.Context, importPath string) (string, error)

Build builds and publishes one Go binary's image and returns its pushed reference (the last line ko prints). Resolve covers everything a manifest references; Build is for the images with no manifest names, such as the worker worker images a WorkerPool points at through workerImage.

func (*Runner) BuildEach added in v1.0.0

func (r *Runner) BuildEach(ctx context.Context, tag string, labels []string, importPaths ...string) ([]string, error)

BuildEach runs BuildTagged once per import path, retrying each failure per buildBackoff. It returns the refs in importPaths order.

func (*Runner) BuildTagged

func (r *Runner) BuildTagged(ctx context.Context, tag string, labels []string, importPaths ...string) ([]string, error)

BuildTagged builds and publishes the images for importPaths in one ko invocation, tagging each with tag and setting each "key=value" in labels as an image label, and returns their pushed references.

func (*Runner) Resolve

func (r *Runner) Resolve(ctx context.Context, path string, stdinManifest []byte) ([]byte, error)

Resolve builds and publishes the images referenced by the manifest read from path (or from stdinManifest when path is "-") and returns the manifest with image references replaced by digests.

func (*Runner) ResolveBytes

func (r *Runner) ResolveBytes(ctx context.Context, manifest []byte) ([]byte, error)

ResolveBytes resolves an in-memory manifest, such as kustomize output.

Jump to

Keyboard shortcuts

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