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 ¶
- func BuildVersion(root string) string
- func CommitStamp(root string) (commit, date string, ok bool)
- func Ldflags(root string) []string
- type Runner
- func (r *Runner) Build(ctx context.Context, importPath string) (string, error)
- func (r *Runner) BuildEach(ctx context.Context, tag string, labels []string, importPaths ...string) ([]string, error)
- func (r *Runner) BuildTagged(ctx context.Context, tag string, labels []string, importPaths ...string) ([]string, error)
- func (r *Runner) Resolve(ctx context.Context, path string, stdinManifest []byte) ([]byte, error)
- func (r *Runner) ResolveBytes(ctx context.Context, manifest []byte) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildVersion ¶
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
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
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 ¶
New returns a Runner, resolving the ko binary once up front so a missing tool fails before any cluster mutation happens.
func (*Runner) Build ¶
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.