1
0
mirror of https://github.com/ko-build/ko.git synced 2025-04-20 11:29:06 +02:00

3 Commits

Author SHA1 Message Date
Nghia Tran
3e5ee5b718
Validate KO_CONFIG_PATH (#471)
* Validate KO_CONFIG_PATH to avoid ignored options

* Remove dup
2022-02-08 11:28:53 -08:00
Halvard Skogsrud
2fbc9089eb Add Trimpath build option
Enables programmatic control of whether `ko` adds the `-trimpath`
flag to `go build`.

The `-trimpath` flag removes file system paths from the resulting
binary. `ko` adds `-trimpath` by default as it aids in achieving
reproducible builds.

However, removing file system paths makes interactive debugging more
challenging, in particular in mapping source file locations in the
IDE to debug information in the binary.

If you set `Trimpath` to `false` to enable interactive debugging, you
probably also want to set `DisableOptimizations` to `true` to disable
compiler optimizations and inlining.

Reference for `-trimpath`:
https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies

Resolves: #500
Related: #71, #78, https://github.com/GoogleContainerTools/skaffold/issues/6843
2021-11-18 09:04:15 +11:00
Halvard Skogsrud
103ff5b2a8 Use build config Dir for all go tool commands
Ensure that the directory specified in build configs in `.ko.yaml` is
used to:

1. Load module information
2. Resolve local paths to Go import paths
3. Working directory for compilation

The change achieves this by introducing `gobuilds`, which contains a
map of import path to `build.Interface` instances. Each entry maps to a
`builds` entry from `.ko.yaml`. `gobuilds` dispatches to the builder
instances based on the requested import path, and falls back to a
default builder if there's no match.

Thanks to @jonjohnsonjr for the suggestions in
https://github.com/google/ko/issues/422#issuecomment-909408527

Also removes mutable globals in the `commands` package.

Fixes: #422
2021-10-27 08:22:23 +11:00