* Set build config via BuildOptions
Enables programmatically overriding build configs when ko is
embedded in another tool.
Related: #340, #419
* Use local registry for base images in unit tests
Tests create a local registry (using ggcr) with a dummy base image. This
speeds up tests, since they don't need to hit gcr.io to fetch the
default distroless base image.
* Update function comment to refer to random image
* Generate Markdown docs
This is largely copied from similar work in go-containerregistry
This required moving the Root command definition out of main() into a
place where it could be referenced from the gendoc tooling.
* fix boilerplate
* moar fix boilerplate
* update cmd/ko/main.go
* set -j to GOMAXPROCS at runtime
* rebase on cli-runtime change
* remove trailing whitespace
* Don't set image.base.name if base is specified by digest
* don't set empty annotation
* annotate Results, not Images and Indexes separately
* moar cleanup
* skip annotations check for images in indexes, these won't be annotated anymore
* first pass: kubectl flags must be passed after '--'
* add warning when using non-separated flags
* mark flags as deprecated
* drop defaultCacheDir and homedir dependency
* Implement ko deps
* actually add deps.go
* specify auth, useragent, platform
* stop reading tar if the context is cancelled
* chmod to the file's perms
* remove support for --platform, modules don't care about build tags
* fix copyright boilerplate
* drop fs dependency
* udpate module integration test to newer Go versions
* use entrypoint to identify the binary
* fix gosec finding, some style comments
* revert modules integration test change
* Build working Windows container images
Add e2e tests that run on Windows and cover kodata behavior
* now successfully skipping symlinks on windows :-/
* fix e2e test on windows, that relied on a symlink in kodata after all
* document windows symlink issue
* review feedback
* re-add kodata symlink tests for linux
There are use cases, where multiple Go build flags need to be set. However, the
environment variable to pass flags to Go build has some limits for `ldFlags`.
Add GoReleaser inspired configuration section to `.ko.yaml` to support setting
specific Go build and ldFlags to be used by the build. Like GoReleaser the
content of the configuration can use Go templates. Currently, only a section
for environment variables is included.
In order to reduce dependency overhead, only the respective config structs from
https://github.com/goreleaser/goreleaser/blob/master/pkg/config/config.go are
used internally to load from `.ko.yaml`.
This change adds a `WorkingDirectory` field to `options.BuildOptions`,
but doesn't expose this as a CLI flag. The default zero value means the
current working directory. The value is used as the directory for
executing `go` tool commands.
When embedding ko in other tools, it is sometimes necessary to set the
working directory for executing the `go` tool, instead of assuming the
current process working directory.
An example of where this is required from Skaffold:
https://github.com/GoogleContainerTools/skaffold/tree/master/examples/microservices
In this example, the working directory doesn't contain either `go.mod`
or any Go files. The `skaffold.yaml` configuration file specifies
a `context` field for each image, which is the directory where the `go`
tool can find package information.
- Export functions and a variable to enable embedding of ko's
`publish` functionality to be embedded in other tools.
See https://github.com/GoogleContainerTools/skaffold/pull/5611
- Remove DockerRepo PublishOption and flag.
This removes the `DockerRepo` config option and `--docker-repo`
flag from the PR.
New PR with the extracted config option:
https://github.com/google/ko/pull/351
- Fix copyright headers for boilerplate check.
- Use DockerRepo PublishOption instead of env var.
- Override defaultBaseImage using BuildOptions.
Remove exported package global SetDefaultBaseImage and instead
allow programmatic override of the default base image using
the field `BaseImage` in `options.BuildOptions`.
Also fix copyright header years.
- Add BuildOptions parameter to getBaseImage
This enables access to BaseImage for programmatically overriding
the default base image from `.ko.yaml`.
- Add UserAgent to BuildOptions and PublishOptions
This enables programmatically overriding the `User-Agent` HTTP
request header for both pulling the base image and pushing the
built image.
- Rename MakeBuilder to NewBuilder and MakePublisher to NewPublisher.
For more idiomatic constructor function names.
* Enable override of daemon publisher local domain
Add a `LocalDomain` field to `PublishOptions`, but no flag (yet?).
This allows use of a domain (base repo) other than `ko.local` for images
that are side-loaded to the local Docker daemon.
An alternative implementation would be to add a boolean field that
indicates that `ko publish` should use the value of the `KO_DOCKER_REPO`
environment variable (or the `DockerRepo` field in `PublishOptions`) as
the base name for images side-loaded to the local Docker daemon. I'd be
happy to get feedback on which option would work best.
* Restore NewDaemon tags positional arg
* Add flag and PublishOption for destination repo
This enables programmatically setting the destination image repository
when embedding ko's `publish` functionality in other tools.
See https://github.com/google/ko/pull/348
* Set DockerRepo PublishOption from KO_DOCKER_REPO
This enables programmatically setting the destination image repository
and avoids exposing a flag.
* Update comment on DockerRepo option
* Fix readme and copyright headers
The current `--bare` help message is a little bit confusing: It says
that it will not work with `--tags` properly, but in fact, I would
assume it means that it may not work properly instead.
With `--bare`, the name will be `${KO_DOCKER_REPO}:<tag>`.
This was using remote.WithTransport to set it manually, and this is much
simpler (also annotates with the go-containerregistry version). This is
really nice because it will give us at least some version information
where we had none before (for non-releases).
Before:
ko
ko/(devel)
ko/v0.7.0
After:
ko go-containerregistry/v0.4.0
ko/(devel) go-containerregistry/v0.4.0
ko/v0.7.0 go-containerregistry/v0.4.0
We dropped this flag, so we're always in non-strict mode by default,
so if there is a ko:// reference that fails to build, we don't error
out. This drops some guards so that we are always in strict mode and
only build ko:// things.
* Move ko binary to root of project.
* go.mod says required golang version is 1.14
* go install uses the folder name
* lint and copyright bump
* moving the test file changed the test hash.
* more refs of cmd/test
* add deprecation message
* Allow comma-separated list of platforms
* Parse platform spec once
* Update --platform docs in README
* Update pkg/build/gobuild_test.go
Co-authored-by: Matt Moore <mattmoor@vmware.com>
* Return err for bad defaulting for --platform
Also respect GOARM as variant if the goarch is arm.
* Refactor platform matching
* Update README.md to mention GOARM
* Fix travis test
Co-authored-by: Matt Moore <mattmoor@vmware.com>
* Add ctx to publish.Interface
I noticed that hitting ctrl-C didn't work when pushing images, this
should fix that.
* Use context everywhere that makes sense
* Allow ko to produce estargz layers.
This pulls in the latest google/go-containerregistry, which enables folks to set `GGCR_EXPERIMENT_ESTARGZ=1` to enable `ko` to start producing layers compatible with the estargz format, which enables the containerd estargz-snapshotter to lazy-load parts of images.
* Add README
This simplifies the logic for creating layers and relies on the new option instead of pre-gzipping (and gunzip being faster). The net effect of this should be the elimination of an extra gunzip, but it should not materially impact the memory pressure because we were ALREADY caching the gzipped layers in-memory, we were just doing it on the caller side, which provided less benefit!
* Refactor the publish.Namer to produce the full repo name.
* Add --naked to have image publishing use ${KO_DOCKER_REPO}:tag
* Change flag name, add disclaimer
MultiPublisher now returns an error when it's configured with no
publishers, and resolver.go now appends a nop publisher when it's
configured not to publish, that simulates a publish without actually
pushing any images.
.