* Viper keys are case insensitive.
This fixes an issue where import paths with uppercase (github.com/GoogleCloudPlatform 👀) were being canonicalized by Viper to all lowercase and the baseImageOverrides in `.ko.yaml` were failing to properly identify the base image.
I hit this in: https://github.com/tektoncd/pipeline/pull/2435 trying to opt some of the GCP images out of `:nonroot`.
This also adds some logging to a place where I see a lot of folks have issues with `ko` where we swallow an error. I hit it experimenting with variants on the `ko publish` import path, and added the logging to debug.
* Drop the new log statement
* Create a MultiPublisher
MultiPublisher mimics io.MultiWriter in that it will publish an image to
multiple publish.Interface implementations.
* Add publish.{Tarball,Layout}Publisher
This adds support for publishing in the tarball format and to an OCI
image layout.
The tarball format isn't great, yet. It only supports writing once
instead of appending.
* Consolidate options
These were spread all over the place for no reasons. Now all the
publisher related options are grouped together.
* Add options for tarball/layout
Adds --oci-layout-path, --tarball, and --push flags.
--push=false will disable the default behavior of publishing to a
registry.
* go mod vendor
* Add Close method to publish.Interface
This allows us to defer writing to the tarball until we've collected all
the images that have been published.
* Fix tests
When resolving files, we would just log.Fatal if we encountered an
error. This seems to be racy and causes ko to exit with a 0 error code
when it shouldn't. To fix this, we synchronize the builder goroutines
with the kubectl go routine and exit with an error if either of them
failed.
This fix also happened to fix a goroutine leak. If the kubectl goroutine
failed, we never properly cancelled the builds, which would happily
conitnue compiling packages and consuming resources.
* Preserve YAML comments & style when resolving/applying
This is accomplished by adopting the yaml.v3 lib. It
exposes a Node struct that's used internally by the
yaml encoder/decoder
ko internally now manipulates YAML documents using this struct
Fixes#101
* add/remove vendored modules
* Apply suggestions from code review
Fix comments
Co-Authored-By: jonjohnsonjr <jonjohnson@google.com>
* update doc link
* Fix use of yaml.Decoder in a test
When the yaml.Decoder returns an io.EOF it implies
there were no YAML documents decoded and that there
are no more!
* Update pkg/resolve/resolve.go
resolve comment suggestion
Co-Authored-By: jonjohnsonjr <jonjohnson@google.com>
* leave ko prefix if we're not operating in strict mode
* move testutils to internal/testing
* Use debug.ReadBuildInfo to populate `ko version`
* don't print version on build info failure
* Build using Go 1.12 and 1.13
* drop 'version: ' prefix
* println
* Add build.Limiter
You can limit the number of concurrent builds with -j (a la make).
The default value for this is GOMAXPROCS, which seems reasonable.
When ko is invoked in this mode, import paths must have the `ko://`
prefix. If a human marks an import path with `ko://` and ko can't
resolve the resulting import path, it fails. In "loose mode", such an
import path would be silently ignored and passed on to the resolved
YAML, often resulting in invalid image names (e.g., `image:
github.com/foo/bar`)
In loose mode, `ko://` prefixes are always ignored for
backward-compatibility.
Why this is necessary: when using a local docker registry, users may not
want to support https, or there may be other troubles not allowing
verifiable TLS support.
This commit adds this functionality by adding an `--insecure-registry`
flag.
This hoists the publisher creation out of the loop for `ko publish` to
avoid needlessly resolving credentials multiple times.
This pulls the publisher creation outside of resolveFilesToWriter so we
can fail earlier if e.g. KO_DOCKER_REPO is unset, otherwise we start up
the kubectl goroutine and it would asynchronously fail with:
error: no objects passed to apply