1
0
mirror of https://github.com/ko-build/ko.git synced 2024-11-27 08:21:07 +02:00
Commit Graph

275 Commits

Author SHA1 Message Date
Maxime Brunet
ac22328979 feat: add image user option
Signed-off-by: Maxime Brunet <max@brnt.mx>
2024-10-24 09:58:21 -04:00
Jeff Mendoza
93c0edaa41 Change OCI Layout publisher to lazy create layout after build.
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>
2024-10-16 13:24:29 -04:00
Jeff Mendoza
87a19c69dc Update doc comment
Signed-off-by: Jeff Mendoza <jlm@jlm.name>
2024-10-16 13:24:15 -04:00
Jeff Mendoza
6588ed4c7b Update recorder to lazy create file.
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>
2024-10-16 13:24:15 -04:00
Sean Liao
c98cb1e05f allow setting annotations
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 #1090
Fixes #1090
Fixes #1231
Fixes #1235
Fixes #1395
2024-10-16 13:18:43 -04:00
Zoran Regvart
dcd4c9bc06
debug: separate target and delve parameters
Adds the `--` separator parameter so delve doesn't try to parse any
command line parameters intended for the target binary.
2024-09-26 11:42:38 +02:00
cpanato
efc004a291
fix lints
Signed-off-by: cpanato <ctadeu@gmail.com>
2024-09-09 21:22:21 -05:00
Dan Luhring
0dcace336c debug: build unsupported platforms with a warning
Signed-off-by: Dan Luhring <dluhring@chainguard.dev>
2024-06-11 12:23:21 -04:00
Dan Luhring
1c83f790ff clone and build dlv instead of go install
Signed-off-by: Dan Luhring <dluhring@chainguard.dev>
2024-06-11 12:23:21 -04:00
Dan Luhring
9bafc92ac6 dlv: os_arch dir only if different from runtime
Signed-off-by: Dan Luhring <dluhring@chainguard.dev>
2024-06-11 12:23:21 -04:00
Dan Luhring
3d2d3363f6 limit platforms supported by debugging
Signed-off-by: Dan Luhring <dluhring@chainguard.dev>
2024-06-11 12:23:21 -04:00
Dan Luhring
5641e10d85 predict dlv install path using os + arch
Signed-off-by: Dan Luhring <dluhring@chainguard.dev>
2024-06-11 12:23:21 -04:00
Dan Luhring
3318ea6c8a review feedback
Signed-off-by: Dan Luhring <dluhring@chainguard.dev>
2024-06-11 12:23:21 -04:00
Christoph Stäbler
5c6cff9d4b Fix typo
Signed-off-by: Christoph Stäbler <cstabler@redhat.com>
2024-06-11 12:23:21 -04:00
Christoph Stäbler
fa9f695938 Add debug option to include Delve debugger
Signed-off-by: Christoph Stäbler <cstabler@redhat.com>
2024-06-11 12:23:21 -04:00
Jason Hall
2ceaa89b7e remove support for CycloneDX SBOMs
Signed-off-by: Jason Hall <jason@chainguard.dev>
2024-06-10 05:56:07 -04:00
Nathan Mittler
7cb29ac9b8 Refactor global values to be defaults
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
2024-05-21 11:29:50 -04:00
Nathan Mittler
2a4c12f410 Add global flags and ldflags
Fixes #1304
2024-05-15 16:46:47 -04:00
Nathan Mittler
c42ee5f028 feat: add template params for platform info
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>
2024-05-15 14:49:18 -04:00
Nathan Mittler
38a1feb001 Remove vendor directory
Also adding dependency on testify to replace some hand-rolled `requireXXX` methods.
2024-05-15 12:49:39 -04:00
Nathan Mittler
4dbf90fe81 feat: Add template params for git
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>
2024-05-15 11:27:55 -04:00
Nathan Mittler
067f9f7899 feat: Add global env
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>
2024-05-14 13:58:53 -07:00
Nick Zavaritsky
1f6a357d8f Ko learns about Linux capabilities
Signed-off-by: Nick Zavaritsky <mejedi@gmail.com>
2024-04-03 08:51:14 -04:00
Nick Zavaritsky
3a0416f78d Add package for handling Linux capabilities
Signed-off-by: Nick Zavaritsky <mejedi@gmail.com>
2024-04-03 08:51:14 -04:00
Nick Zavaritsky
832b853576 Handle shorthand syntax in build config
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>
2024-04-03 08:51:14 -04:00
cpanato
440e8ca7f2 fix lints
Signed-off-by: cpanato <ctadeu@gmail.com>
2024-03-26 09:45:42 -04:00
Adrian Lai
5ce94b973f Fix kind image names with --bare
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.
2024-03-20 13:44:11 -04:00
Sascha Schwarze
7698aa38c9
Correct cluster name in error message when no nodes are found 2023-12-04 08:57:09 +01:00
Adrian Lai
59a676e424 Fix kind image loading for MacOS
See: https://github.com/kubernetes-sigs/kind/pull/2957
2023-11-22 12:58:04 -06:00
cpanato
4aceae1ddf update test
Signed-off-by: cpanato <ctadeu@gmail.com>
2023-11-14 16:41:07 -05:00
Jon Johnson
c1c4af0e6e
Add more locking around on-disk image cache
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>
2023-11-06 12:39:19 -08:00
Jon Johnson
93d195ee35
Don't AppendDescriptor until we've written config (#1175)
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>
2023-11-06 12:28:13 -05:00
Jason Hall
047989802f
fix test broken by lint fix (#1143)
Signed-off-by: Jason Hall <jason@chainguard.dev>
2023-09-11 16:29:01 +02:00
Jason Hall
d58b51e50d
handle newfound lint errors (#1142)
Signed-off-by: Jason Hall <jason@chainguard.dev>
2023-09-11 09:41:49 -04:00
Jason Hall
daab1ac9dc
include go build output in build error (#1127)
Signed-off-by: Jason Hall <jason@chainguard.dev>
2023-09-07 09:45:32 -04:00
guangwu
d4a1cc961c
chore: remove refs to deprecated io/ioutil (#1092)
* chore: remove refs to deprecated io/ioutil

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>

* fix: gofmt check

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>

---------

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
2023-08-23 13:24:04 -04:00
Lars Lehtonen
83589fd520
pkg/commands: fix dropped errors (#1109) 2023-08-10 18:39:48 +00:00
Jon Johnson
81c1c704e1
implement dumb cache for images (#1102)
Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
2023-07-31 15:14:32 -07:00
Carlos Tadeu Panato Junior
2b8ee98d2d
update boilerplate file to be KO Build Authors (#1056) 2023-06-09 10:48:00 -04:00
Jason Hall
27ca485d0b
Revert "Fix kind image loading for MacOS (#1026)" (#1054)
This reverts commit a46638e296.
2023-05-23 08:14:15 -07:00
Adrian Lai
a46638e296
Fix kind image loading for MacOS (#1026)
See: https://github.com/kubernetes-sigs/kind/pull/2957
2023-05-23 14:43:14 +00:00
Matt Moore
c6dc504a60
Fix: Incorporate platform architecture (#1029)
🐛 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
2023-05-01 10:32:09 -04:00
Jon Johnson
6284661a61
Fix --local with KO_DOCKER_REPO (#1017) 2023-04-21 20:43:50 -04:00
Jon Johnson
6a1169b0a5
Add context to many gobuild errors (#1016) 2023-04-21 20:23:30 -04:00
Jon Johnson
a42d0f2068
Don't publish tags twice (#1010) 2023-04-18 14:09:33 -04:00
Jon Johnson
657cd9466a
Push images faster (#1005) 2023-04-07 13:33:24 -04:00
Felix Yan
427beff447
Correct a typo in resolver.go (#989) 2023-03-18 08:37:44 -04:00
Carlos Tadeu Panato Junior
4cde944f30
Upgrade to go120 (#984)
* upgrade to use go1.20

Signed-off-by: cpanato <ctadeu@gmail.com>

* bump go module to require minimum go1.19

Signed-off-by: cpanato <ctadeu@gmail.com>

* fix gofmt

Signed-off-by: cpanato <ctadeu@gmail.com>

* update base image

Signed-off-by: cpanato <ctadeu@gmail.com>

---------

Signed-off-by: cpanato <ctadeu@gmail.com>
2023-03-14 10:35:54 -04:00
Batuhan Apaydın
8e075ae1f1
fix file extension for cyclonedx (#974)
Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com>
2023-03-09 08:33:12 -05:00
Jason Hall
11670b7498
fix: handle docker's unknown/unknown platform in index manifests (#975) 2023-03-08 17:09:49 -05:00