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

32 Commits

Author SHA1 Message Date
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
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
Scott Nichols
c2b862d468 Move ko binary to root of project. (#257)
* Move ko binary to root of project.

* go.mod says required golang version is 1.14

* go install uses the folder name

* lint and copyright bump

* moving the test file changed the test hash.

* more refs of cmd/test

* add deprecation message
2020-12-22 09:31:02 -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
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
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
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
ecce857be6 Some small nits around the codebase to make linters happy. (#181) 2020-08-10 08:21:31 -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
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
jonjohnsonjr
3a17dee60a Use GOOS/GOARCH from base image (#77) 2019-08-19 10:02:17 -07:00
Jason Hall
b7eb9dfe48 Merge pull request #58 from ImJasonH/strict
Implement "strict mode" which requires `ko://` prefix for import paths
2019-08-15 21:48:35 -04: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
Jason Hall
3315663a21 Remove strictness checks from build, into resolve
Strictness has nothing to do with building, and is independent of how
images are built (fixed builder, some future exotic builder type, etc.)
2019-08-15 14:22:45 -04:00
Jason Hall
4342ceff74 Implement "strict mode"
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.
2019-08-15 09:45:59 -04: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
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
Davor Kapsa
2547a9c6b3 check NewGo error 2019-03-22 18:46:51 +01:00
Jason Hall
ab8152ad0a Update ko to ggcr head, update ggcr vendor 2019-03-21 18:51:39 -04:00
Jason Hall
d90911552c fix gobuild_test.go 2019-03-21 16:03:47 -04:00
Jason Hall
d580f39279 fix unit tests 2019-03-21 15:59:33 -04:00
Jason Hall
6354665a42 Initial commit 2019-03-14 14:23:47 -04:00