1
0
mirror of https://github.com/ko-build/ko.git synced 2025-11-06 09:19:12 +02:00
Commit Graph

43 Commits

Author SHA1 Message Date
Halvard Skogsrud
9a256a4b19 Enable setting environment variables in .ko.yaml (#419)
* Enable setting environment variables in .ko.yaml

Matches the GoReleaser format.

Related: #340

* Use different env example
2021-08-23 08:05:01 -07:00
Jason Hall
86a7b6f4b8 Don't set image.base.name if base is specified by digest (#408)
* 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
2021-08-11 16:52:01 -04:00
Jason Hall
4ff8308086 Use annotation strings from image-spec/specs-go (#407) 2021-08-03 20:00:24 -04:00
Jason Hall
c9efd26241 Annotate OCI image indexes with base image information (#385) 2021-07-30 09:29:58 -07:00
Jason Hall
f16d0d0412 Don't add .exe suffix to windows executables (#400) 2021-07-28 16:28:22 -04:00
Jason Hall
690533235a Build working Windows container images (#374)
* 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
2021-07-27 16:19:21 -04:00
Jason Hall
26d03e92c2 Annotate images with base image information (#354)
* WIP: annotate base images

* remove TODO

* .

* Annotate with base index digest, if based on an index

* use correct new proposed annotation
2021-07-20 15:06:08 -05:00
Matthias Diester
ab4d264103 Add support for Go build flags (#340)
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`.
2021-07-02 08:40:56 -07:00
Simon Kirsten
ee23538378 Add KO_DATA_DATE_EPOCH env var to set the modification time for files in kodata (#372)
* Add KO_DATA_DATE_EPOCH env var

* Add documentation for KO_DATA_DATE_EPOCH env var
2021-06-15 12:50:35 -07:00
Halvard Skogsrud
2ba8bb26d1 Enable setting the working dir for the go tool (#365)
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.
2021-06-10 08:29:30 -07:00
Jason Hall
f7df810619 Add --image-label to add labels to built images (#324) 2021-03-03 10:03:31 -08: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
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
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
Matt Moore
222b0fc788 Allow ko to produce estargz layers. (#271)
* 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
2020-12-17 15:00:30 -08:00
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
1c704388dc Print platform variant when building go binary (#248) 2020-11-20 09:15:04 -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
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
Markus Thömmes
695b39f9f4 Fix things pointed out by golangci-lint 2020-10-13 15:27:59 +02: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
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
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
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
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
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
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
241d532569 Update ggcr (#91)
Fixes #90

This picks up an auth rewrite.
2019-09-26 13:28:02 -07:00
jonjohnsonjr
3a17dee60a Use GOOS/GOARCH from base image (#77) 2019-08-19 10:02:17 -07:00
Matt Moore
a3656d1441 Add support for recursively resolving directory symlinks. (#73)
* Add support for recursively resolving directory symlinks.

This adds support for properly resolving directory symlinks within kodata.
I verified that with this I can symlink `.git/refs` into `kodata/` and (with
changes) resolve the `.git/HEAD` symlink to read the appropriate
`ref: refs/heads/...` files with the commit SHA.

* Incorporate code review feedback
2019-08-15 17:59:15 -07:00
Matt Moore
2d12e28795 Add permissions to the kodata directory. (#68)
I suspect that this may be a source of problems reading kodata with nonroot,
but it is probably worth doing either way.
2019-08-12 07:12:47 -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
Sumanth Chinthagunta
d35600780e Update gobuild.go (#56)
Changing the order of environment variables so that user supplied value for `CGO_ENABLED` take priority 
https://github.com/google/ko/issues/52
2019-07-08 20:21:10 -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
Adam Harwayne
b0a1702132 Add --disable-optimizations flag to make debugging easier. (#24)
* Ignore GoLand files.

* Add --disable-optimizations flag to make debugging easier.

* Fix unit test (by ignoring the new functionality).
2019-04-18 10:18:29 -07:00
Jason Hall
ab8152ad0a Update ko to ggcr head, update ggcr vendor 2019-03-21 18:51:39 -04:00
Jason Hall
6354665a42 Initial commit 2019-03-14 14:23:47 -04:00