When using ko with OCI Layout, Git status will always be dirty because the
layout is created before this build. This changes the layout to be created
after the build so that git will be clean. The means that any error creating
the layout won't be seen until after the build.
Signed-off-by: Jeff Mendoza <jlm@jlm.name>
Currently the resolver command creates the image-refs file on
initilization. This causes git to be dirty during builds. This change moves the
file creation to be in the recorder itself and on the first time the Publish()
method is called. This happens after the build so git is clean. This will mean
that any errors on file creation will be reported after the build rather than
before.
Signed-off-by: Jeff Mendoza <jlm@jlm.name>
This adds a new build flag for setting annotations
on image indexes and manifests.
Annotations are no longer copied from the base image.
`org.opencontainers.image.base.digest` and
`org.opencontainers.image.base.name`
are always set to the resolved values.
Usage example:
```sh
ko build --image-annotation foo=bar,fizz=buzz .
```
Fixes#1090Fixes#1090Fixes#1231Fixes#1235Fixes#1395
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
This restructures the build logic in order to expand the buildArgs to include:
- `Env`: the actual environment variables used to execute the build. This includes platform info (e.g. `GOOS`, `GOARCH`).
- `GoEnv`: the map of variables from `go env`, but overridden with any platform-specific values defined in `Env`.
Fixes#1301
Signed-off-by: Nathan Mittler <nmittler@aviatrix.com>
This includes a number of template parameters supported by [goreleaser](https://goreleaser.com/customization/templates/). Specifically, the build date information and the majority of the Git params.
Majority of the code is copied from goreleaser. I've added the MIT license from goreleaser at the top of the files.
Fixes#493
Signed-off-by: Nathan Mittler <nmittler@aviatrix.com>
Supports configuring global `env` variables that will be applied to all builds.
Modifies the `builder` function to accept a `buildContext` structure. This will simplify similar modifications in the future.
Fixes#1305
Signed-off-by: Nathan Mittler <nmittler@aviatrix.com>
Build.Config contains LdFlags and Flags, both arrays of strings. For
user convenience it should be possible to specify a single string
instead. FlagArray (Flags) and StringArray (LdFlags) implement
YAMLUnmarshaller interface to handle custom parsing logic.
Since build.Config is loaded via viper/mapstructure and not the YAML
parser, YAMLUnmarshaller interface was ignored.
Wire things up.
Signed-off-by: Nick Zavaritsky <mejedi@gmail.com>
Make the functionality match between:
KO_DOCKER_REPO=ko.local/my-image ko build --bare
And:
KO_DOCKER_REPO=kind.local/my-image ko build --bare
As it stands, `--bare` is broken with `kind.local/` as it just gets
`kind.local` as the image name, and then it fails to tag because the
registry is missing.
Concurrent writes/reads to the cache might result in partially written
files, which we'd like to avoid.
On top of that, we generally don't want builds to fail if something goes
wrong with the cache, so now we just log any cache errors and do a
fallback.
Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
I have a suspicion that this is causing a race where we modify the
cache's index.json file before we actually write out the image's config
file, so if we call RawConfigFile before we finish caching it, we'll
just fail to find that file.
Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
🐛 Right now `--sbom-dir` with a multi-arch build just writes the same file over and over.
This loosely follows the lead of apko which uses the form `sbom-{arch}.{form}.json`, but we are going with: `{app}-{platform}.{form}.json`.
It is notable that `{platform}` is a superset of `{arch}` and we sanitize the string encoding replacing the `/` and `:` characters with `-`.
/kind bug