Commit Graph
904 Commits
Author SHA1 Message Date
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.
v0.5.1 v0.5.0
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
Dave Protasowski 429a4097a7 Update .travis.yml (#156) 2020-04-30 16:27:12 -04: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 3e73a508fa go mod tidy (#141) v0.4.0 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.
v0.3.0
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
Jason Hall f12b9e62de Document strict mode in README.md (#126) 2020-01-27 09:21:50 -08:00
jonjohnsonjr 99ecfeb5c4 Add goreleaser GitHub action (#121) v0.2.0 2020-01-24 08:44:56 -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 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
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 Protasowskiandjonjohnsonjr 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
Scott Brenner a6277d0a45 Quick typo fix (#99) 2019-10-22 12:32:49 -07:00
Jason Hall 267b61e6ed Merge pull request #100 from syedriko/image_registry_auth_note
Added a note on logging in to the image registry KO_DOCKER_REPO points at
2019-10-18 11:44:32 -04:00
Sergey Yedrikov 26dcb6f23a Added a note on logging in to the image registry KO_DOCKER_REPO points at 2019-10-18 10:47:39 -04:00
Jason Hall 57f20d0355 Merge pull request #98 from n3wscott/logo
Adding ko logo.
2019-10-15 09:45:39 -04:00
Scott Nichols 5697b9d2ae rel url. 2019-10-14 15:06:06 -07:00
Scott Nichols 474505bde6 Adding ko logo. 2019-10-14 10:20:20 -07: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
Jason Hall 15f9719970 Merge pull request #89 from toshi0607/feature/fix-broken-markdown
fix broken markdown
2019-09-23 09:17:34 -04:00
toshi0607 f5bfec379b fix broken markdown 2019-09-23 22:09:21 +09:00
Jason Hall 56f32f8a17 Update README to include better install instructions (#87) 2019-09-20 10:08:56 -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
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
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
zxxa bd404f30ef add SOURCE_DATE_EPOCH usage (#72) 2019-08-16 09:50:39 -07:00