1
0
mirror of https://github.com/ko-build/ko.git synced 2025-02-07 19:30:23 +02:00

85 Commits

Author SHA1 Message Date
Matt Moore
960e6a3f1c
Update ggcr and use the new tarball.WithCompressCaching (#263)
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!
2020-12-13 18:14:27 -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
Matt Moore
79beb3b015
Refactor the publish.Namer, add --bare option for image naming (#234)
* 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
2020-11-03 13:47:36 -08:00
Jason Hall
d767708246
IsSupportedReference returns descriptive error (#233)
This can be useful to determine what they need to do to make a ko
publish work.
2020-10-31 09:55:28 -07:00
Matt Moore
cde258294f
Run the hello test on multiple architectures (#227) 2020-10-23 16:47:34 -07:00
Markus Thömmes
695b39f9f4 Fix things pointed out by golangci-lint 2020-10-13 15:27:59 +02:00
Jason Hall
e780390edb
Avoid panic caused by MultiPublisher (#216)
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.

.
2020-10-06 06:45:25 -07:00
Jason Hall
d7b989a9df
Remove docs for Strict Mode and --strict flag (#210) 2020-09-30 11:00:36 -07:00
Matt Moore
61fbde832a
Have kind.local test use --platform=all (#208)
Fix --platform=all with kind.local
2020-09-29 10:11:15 -07: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
Matt Moore
d48767339f
Fix base image resolution (#201) 2020-09-25 10:20:33 -07:00
Matt Moore
5af0bc138f
Print more complete platform information. (#200)
Fixes: https://github.com/google/ko/issues/199
2020-09-25 08:51:18 -07:00
Matt Moore
bd3f1cb17b
[Automated] Update actions (#194)
* Update common github actions

Signed-off-by: Matt Moore (via Sockpuppet) <mattmoor@vmware.com>

* Run gofmt
2020-09-24 19:00:36 -07:00
Matt Moore
985c449e0b
Fix goimports (#196) 2020-09-24 18:39:46 -07:00
Matt Moore
33e66aca49
Remove deprecated things. (#162)
Fixes: https://github.com/google/ko/issues/158
Fixes: https://github.com/google/ko/issues/160
2020-09-24 16:14:58 -07:00
jonjohnsonjr
8b52ec2374
Multi-platform ko (#38)
🦜
2020-09-24 15:58:08 -07:00
Markus Thömmes
1aa3b3793e
Allow images to be loaded into kind using 'kind.local'. (#180)
* Allow images to be loaded into kind using 'kind.local'.

* Add documentation for kind.
2020-09-04 08:32:26 -07:00
Markus Thömmes
618b1631a5
Make Tarball publisher types private and return Interface. (#182) 2020-08-12 08:11:22 -07:00
Markus Thömmes
ecce857be6
Some small nits around the codebase to make linters happy. (#181) 2020-08-10 08:21:31 -07:00
Matt Moore
ab4ca8ec17
Fix the other publishers (#165) 2020-05-06 13:26:22 -07:00
Matt Moore
ea2beac575
Fix -P with passing ko:// through. (#163)
Turns out I broke this.  Thanks to @bobcatfish for reporting the issue.

With this change:
```
ko resolve -Pf cmd/ko/test/test.yaml > /dev/null
2020/05/04 08:44:35 Using base gcr.io/distroless/static:nonroot for github.com/google/ko/cmd/ko/test
2020/05/04 08:44:36 Building github.com/google/ko/cmd/ko/test
2020/05/04 08:44:37 Publishing gcr.io/mattmoor-knative/github.com/google/ko/cmd/ko/test:latest
2020/05/04 08:44:39 Published gcr.io/mattmoor-knative/github.com/google/ko/cmd/ko/test@sha256:ee655510172b429dbce619fc69677621d71cb824cbbf2a21746d700127257ec4
```

I can cut v0.5.1 once this lands.
2020-05-04 09:06:55 -07:00
Matt Moore
d45c527750
This adds the deprecation notices for ko:// and nonroot (#161)
* Add a deprecation notice when `defaultBaseImage` is not specified.

Related: https://github.com/google/ko/issues/160

* Add a deprecation notice when `ko://` is not specified.

Related: https://github.com/google/ko/issues/158

* Add a sample import path.
2020-05-03 18:42:51 -07:00
Dave Protasowski
6cbfe964d7
[modules] Dependent command packages can now be built with ko (#154)
Thus if you have a (in)direct command package as a dependency
say `myhost.com/go/package/cmd/run` you can now publish this
with the following ko command

  ko publish myhost.com/go/package/cmd/run
2020-05-01 07:18:26 -07:00
Matt Moore
ff61ea330c
Refactor how/where ko:// is handled. (#153)
This change more or less completely changes how `ko://` is handled internally to `ko`, but the user-facing changes should only be net-positive.  `ko://` was previously stripped at the highest level, and the build logic was unaware, which had some undesirable diagnostic/functional implications that are collectively addressed in this change.

With this change, the `ko://` prefix is preserved and passed to the build logic, which internally parses a new `reference` type (this was useful to have Go's type checker find all of the places that needed fixing).  The main functional differences are:
1. If a reference is prefixed with `ko://` we will now fail fast in `IsSupportedReference` regardless of whether `--strict` is passed.
2. If a reference is prefixed with `ko://` it will bypass the prefix check, which allows the use of `ko://github.com/another/repo` that references a vendored binary package.

For `2.` the absence of the module prefix causes the filtering logic Jon introduced to avoid the reference.  This was critical for efficiency when `ko://` isn't around because we feed every string in the yaml through it, but when the user has explicitly decorated things it's the perfect thing to be sensitive to.

Fixes: https://github.com/google/ko/issues/146
Fixes: https://github.com/google/ko/issues/152
2020-04-29 19:32:30 -07:00
Matt Moore
f45bc13ded
Viper keys are case insensitive. (#150)
* 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
2020-04-20 09:13:33 -07:00
jonjohnsonjr
acf34edd61
Rework parsing logic (#138)
Fixes #137
2020-02-25 10:12:20 -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
Halvard Skogsrud
ca1b2a1ded Fix: Add directory containing binary to PATH (#127)
Fixes the PATH environment variable so it contains the directory
containing the binary (i.e., /ko-app) instead of the binary itself
(e.g., /ko-app/ko).

See #114.
2020-01-28 09:15:14 -08:00
Daniel Helfand
2e28671384 add kubectl check for ko delete, apply, and create (#120) 2020-01-16 13:27:43 -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
cezkuj
1fcfe62a96 Reorder parsing KO_DOCKER_REPO to get proper credentials (#117)
Fixes #93

With this change we support also pointing to default registry (without prefix).
Eg. KO_DOCKER_REPO=myuser
2019-12-18 09:47:56 -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
835dcfbe44
Improve ko run (#76)
Make it more like go run.
2019-12-06 10:52:34 -08:00
Evan Anderson
6aff039ca9 Fix path mangling on Windows. (#112)
Since we are always building linux containers, use `path.Join` rather than
`filepath.Join` when adding files to the tar.

Signed-off-by: Evan Anderson <evan.k.anderson@gmail.com>
2019-12-02 11:05:48 -08:00
Stanley Nguyen
1c54dd6b3e Add context to go build (#105) 2019-11-09 09:23:09 -08:00
Jason Hall
7893c74458
Merge pull request #109 from jonjohnsonjr/tagged-digests
Include tag in resolved references
2019-11-08 10:30:01 -05:00
Adam Harwayne
5a25402af9 Ignore null YAML documents when using a label selector. (#107) 2019-11-07 16:12:23 -06: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
Dave Protasowski
4833bb4a3e Preserve YAML comments & style when resolving/applying (#103)
* 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
2019-11-05 12:24:08 -08:00
Stanley Nguyen
be4e1ffdd6 [Resolves #71] Add trimpath arg to gobuild (#102)
* Add trimpath arg to gobuild

* Add build constraints for trimpath usage

* Reduce duplications across go versions

* Change trimpath fn-files for better names

* Attempt to apply with minikube on Travis

* Attempt to apply with KinD on Travis

* Install kind thru curl to not affect build
2019-11-01 10:55:03 -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
Jason Hall
133ae27c63 Use debug.ReadBuildInfo to populate ko version (#81)
* 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
2019-09-12 14:59:50 -07:00