Commit Graph
62 Commits
Author SHA1 Message Date
jonjohnsonjr 66bd5fc8a5 Clear Cmd when setting Entrypoint (#624)
See https://github.com/chainguard-dev/apko/issues/22
2022-02-28 16:55:57 -08:00
jonjohnsonjr ea93812481 Test the right directory for kocache (#616) 2022-02-24 11:54:25 -05:00
Jon Johnson 73a4629033 Always clean Dir for packages.Load 2021-12-20 08:39:16 +11:00
jonjohnsonjr 5a13603eef Fix tarball publisher ctx handling (#545)
Previously, we'd use the ctx from the Build invocation, but because
remote stashes the remote.WithContext option, when we later go to fetch
the actual base image to write it out to a tarball, it will fail because
the Build ctx was cancelled.

For whatever reason, NewGo takes a ctx, so this change propagates the
badness from remote so we can use the NewGo ctx when we fetch base
images.
2021-12-14 15:30:01 -08:00
jonjohnsonjr 2502eb9d47 Build each platform concurrently (#527)
* Build each platform concurrently

At least on my machine, this is slightly faster on a cold build and
saves significant time on a warm build.

* Plumb --jobs down to multi-arch

* Add deprecation warning for build.Limiter
2021-12-09 11:02:14 -08:00
jonjohnsonjr ad0607f0a1 Cache base image metadata in-memory (#525)
This saves a roundtrip to the registry if we ever use the same base
image for multiple builds in a single invocation.

This also sets us up for using an on-disk cache for image metadata to
speed things up even further.
2021-12-08 09:28:15 -05:00
jonjohnsonjr 54cddccd1c Introduce KOCACHE (#269)
* Introduce KOCACHE

Cache binaries under $KOCACHE/<import path>/<platform>

Cache metdata mapping buildid to diffid and diffid to descriptor.

* Point TODO at issue

* Split layerCache into separate file

This makes things a little cleaner by having a single place that calls
buildLayer and passing a thunk down into the cache logic to call that on
a cache miss.

Also, remove the debug logging to make the code easier to follow (if you
need to recompile anyway, it's easy enough to add log lines).

* Move cached output to $KOCACHE/bin
2021-12-08 08:47:26 -05:00
jonjohnsonjr 688ca47675 Isolate unit tests from os.Environ (#455)
Platform resolution unit tests were affected by GOARCH/GOOS. Move the
os.Environ() call out of the function under test to avoid this.
2021-09-29 09:23:32 -07:00
jonjohnsonjr 45467f076b Do not require docker installed for tests (#438) 2021-09-20 07:07:56 -04:00
jonjohnsonjr 61d5250c55 Drop scary warning (#439) 2021-09-16 10:48:12 -07:00
jonjohnsonjr 82e899db0c Look for ko.local in the daemon (#371)
* Look for ko.local in the daemon

* Update README
2021-06-09 09:20:45 -07:00
jonjohnsonjr 23ecf4753b Propagate --insecure-registry to base image (#370) 2021-06-01 09:47:30 -07:00
jonjohnsonjr ee74460418 Wrap io errs for kodata layer (#320)
* Wrap io errs for kodata layer

* Don't shadow hostPath
2021-02-25 09:42:29 -08:00
jonjohnsonjr 82cabb40ba Fix GOROOT mismatch issues (#303)
Print a warning if GOROOT is unset and ko's default build context
differs from $(go env GOROOT) and use the result of $(go env GOROOT).
2021-01-21 10:30:14 -08:00
jonjohnsonjr 0801316109 Fix ko login (#298)
This was missed when main.go was moved to the root.
2021-01-18 11:12:14 -08:00
jonjohnsonjr 34568cac73 Use remote.WithUserAgent where possible (#294)
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
2021-01-18 11:11:16 -08:00
Jon Johnson e521d7625f Bump ggcr to v0.4.0 2021-01-13 15:51:55 -08:00
Jon Johnson 6586a72f8a Always use "strict" mode
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.
2020-12-22 14:00:31 -08:00
Jon Johnson fa39374027 Document GOFLAGS 2020-12-22 10:23:17 -08:00
jonjohnsonjr 0427aed99b Add ko login (#277)
This was previously `ko auth login`, which I've hidden, and perhaps we
can alias to `ko login` in the future, but in theory folks could have
been using `ko auth get`, and I don't want to break that for no reason.
2020-12-22 09:12:27 -08:00
jonjohnsonjr eb93ca875f Update ggcr to v0.3.0 (#276)
* update ggcr

* go mod vendor

* go mod tidy
2020-12-22 07:22:28 -08:00
jonjohnsonjrandMatt Moore 7e3245343a Allow comma-separated list of platforms (#259)
* 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>
2020-12-21 16:53:00 -08:00
jonjohnsonjr fd5cd4bfbc Actually print errors during resolve (#275)
We were just throwing away the error for `ko resolve`.
2020-12-21 14:51:05 -08:00
jonjohnsonjr 522c37c4e0 Add ctx everywhere (#268)
* 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
2020-12-21 11:47:05 -08:00
jonjohnsonjr b84301964a Make --watch work with ko:// (#250)
The dep-notify package doesn't know anything about ko, so we need to
trim the strict prefix before sending import paths over to it.
2020-11-20 13:12:19 -08:00
jonjohnsonjr 1c704388dc Print platform variant when building go binary (#248) 2020-11-20 09:15:04 -08:00
Jon Johnson c183e84439 Stop using filepath.Join in publisher 2020-11-17 09:33:56 -08:00
jonjohnsonjr 1f17ce95d4 Set GOARM based on platform.variant (#239)
This relies on some hard-coded knowledge of the go compiler, which is
unfortunate, so we will have to update this if things change.
2020-11-04 12:44:08 -08:00
jonjohnsonjr 4a4d1b02bd Revive progress and warning logs (#203)
These got dropped when we pulled in:
https://github.com/google/go-containerregistry/pull/481

Which doesn't log by default, and requires opting in.
2020-09-25 11:50:20 -07:00
jonjohnsonjr 8b52ec2374 Multi-platform ko (#38)
🦜
2020-09-24 15:58:08 -07:00
jonjohnsonjr 3e73a508fa go mod tidy (#141) 2020-03-10 09:42:26 -07:00
jonjohnsonjr ed28755e6b Update go-containerregistry (#140)
Pick up https://github.com/google/go-containerregistry/pull/690
2020-03-10 09:36:12 -07:00
jonjohnsonjr acf34edd61 Rework parsing logic (#138)
Fixes #137
2020-02-25 10:12:20 -08:00
jonjohnsonjr f9e50dc059 Update ggcr (#136) 2020-02-19 11:26:04 -08:00
jonjohnsonjr 3c6a907da9 Add additional output formats (tarball and layout) (#134)
* 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
2020-02-19 09:30:01 -08:00
jonjohnsonjr cfd680de28 Deterministically fail ko {apply, create} (#133)
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.
2020-02-11 10:44:25 -08:00
jonjohnsonjr c3a657a04b Set AutomaticEnv for viper (#131)
This allows viper configuration to be set using environment variables
instead of just with a config file.
2020-02-06 13:51:22 -08:00
jonjohnsonjr 99ecfeb5c4 Add goreleaser GitHub action (#121) 2020-01-24 08:44:56 -08:00
jonjohnsonjr b7e1a7fdbc Update ggcr dependency (#119)
* Update ggcr dependency

I had to move genericclioptions to k8s.io/cli-runtime

* bump client-go

* usePersistentConfig=false
2020-01-15 13:16:11 -08:00
jonjohnsonjr d24b60a88f Set UA to something ko-specific (#116) 2019-12-13 15:08:52 -08:00
jonjohnsonjr 4ff72e36de Add entrypoint to PATH (#114)
This makes it easier to invoke the binary when using a debug container.
E.g. you could invoke `ko` instead of `/ko-app/ko`.
2019-12-11 11:08:26 -08:00
jonjohnsonjr 28f239ab78 Update ggcr (#113)
Mostly to pick up media type mutation, but this includes a bunch of
other fixes.

https://github.com/google/go-containerregistry/compare/ff1ac7f97758299e13f746209d8c0f199923d89a...73724ba06bda116382dafb17b39b682ffab4dc36
2019-12-09 11:07:23 -08:00
jonjohnsonjr 835dcfbe44 Improve ko run (#76)
Make it more like go run.
2019-12-06 10:52:34 -08:00
Jon Johnson e9800719c2 Include tag in resolved references
If a single tag is explicitly set (i.e. it's not "latest"), include that
in the reference that gets rendered in the yaml.

This is really useful for tracking releases.
2019-11-07 13:40:11 -08:00
jonjohnsonjr 479bd3e5ce Update ggcr (#97) 2019-10-04 15:27:28 -07:00
jonjohnsonjr 3880b61d2d Allow plain registries as KO_DOCKER_REPO (#94)
This allows you to use e.g. localhost:5000 as KO_DOCKER_REPO.

Fixes #93.
2019-10-02 10:02:01 -07:00
jonjohnsonjr 241d532569 Update ggcr (#91)
Fixes #90

This picks up an auth rewrite.
2019-09-26 13:28:02 -07:00
jonjohnsonjr f26825fb5a Remove extra dashes (#86) 2019-09-20 09:39:18 -07:00
jonjohnsonjr 451287a90e Update ggcr (#83) 2019-09-20 09:29:57 -07:00
jonjohnsonjr 99a587ede5 Add build.Limiter (#79)
* 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.
2019-09-11 10:07:02 -07:00
jonjohnsonjr 3a17dee60a Use GOOS/GOARCH from base image (#77) 2019-08-19 10:02:17 -07:00
jonjohnsonjr 96455023a3 Fix date command (#75) 2019-08-16 09:59:27 -07:00
jonjohnsonjr ee58128ba3 Fix README formatting (#74)
Apparently those newlines are important.
2019-08-16 09:52:45 -07:00
jonjohnsonjr 3a0e70e520 Fix mult-doc yaml re-joining (#63) 2019-07-23 09:04:40 -07:00
jonjohnsonjr 3566d3f01a Add go module support (#60)
* Add go module support

* Make localimports work for go modules
2019-07-12 22:54:25 -07:00
jonjohnsonjr b7d1820e13 Compress layers when we Build them (#47)
This avoids double-compressing later.
2019-06-25 16:30:25 -07:00
jonjohnsonjr f46a2b6372 Add author and created_by data (#45)
Fixes #42
2019-06-24 12:58:37 -07:00
jonjohnsonjr 116114f1f9 Bump ggcr depenency (#41)
* Update ggcr dependency

* Update kode

Fixed remote.Write interface change.

Drop name.WeakValidation (now default).
2019-06-21 13:15:10 -07:00
jonjohnsonjr cef9764e3d Return better error messages (#33)
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
2019-04-30 13:08:54 -05:00
jonjohnsonjr 3584e2d4d3 Merge pull request #16 from dvrkps/patch-1
check NewGo error
2019-03-22 12:37:24 -07:00
jonjohnsonjr eab537e91f Merge pull request #17 from ImJasonH/weak
Drop name.WeakValidation
2019-03-22 12:37:02 -07:00
jonjohnsonjr f0a367da93 Merge pull request #15 from google/ImJasonH-patch-1
Run tests with Go 1.11 and 1.12 (drop 1.10)
2019-03-21 19:52:57 -07:00