There was recent work to add global values for `env`, `flags`, and `ldflags`. The global values would be merged with per-build values to generate the value used for the builds.
There are a couple issues with this:
- It's inconsistent with the existing code, which only has `default` values declared globally (there is no merging today).
- The name of the `flag` variable, caused a conflict with knative's `KO_FLAGS` environment variable (see #1317)
This PR does the following:
- Refactors the logic to use `defaultEnv`, `defaultFlags`, and `defaultLdflags`. This resolves both issues described above.
- Updates documentation
Fixes#1317
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
* 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
* Add manual integration tests for various go mod corner cases.
* Move integration test back and actually test the outputs.
I realize now this is run in a travis CI job :) So I'll make it actually work.
* Add _, gofmt
* Add tools build constraint.
* Stop redirecting stderr
* Use local mode to support CI.
* 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