Skip to content

Commit accfbf6

Browse files
authored
Merge pull request #2997 from jsternberg/bake-set-annotations
bake: allow annotations to be set on the command line
2 parents 18f4275 + d6fdf83 commit accfbf6

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

bake/bake.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,9 @@ func (c Config) newOverrides(v []string) (map[string]map[string]Override, error)
555555
o := t[kk[1]]
556556

557557
// IMPORTANT: if you add more fields here, do not forget to update
558-
// docs/bake-reference.md and https://docs.docker.com/build/bake/overrides/
558+
// docs/reference/buildx_bake.md (--set) and https://docs.docker.com/build/bake/overrides/
559559
switch keys[1] {
560-
case "output", "cache-to", "cache-from", "tags", "platform", "secrets", "ssh", "attest", "entitlements", "network":
560+
case "output", "cache-to", "cache-from", "tags", "platform", "secrets", "ssh", "attest", "entitlements", "network", "annotations":
561561
if len(parts) == 2 {
562562
o.ArrValue = append(o.ArrValue, parts[1])
563563
}

bake/bake_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ target "webapp" {
3434
args = {
3535
VAR_BOTH = "webapp"
3636
}
37+
annotations = [
38+
"index,manifest:org.opencontainers.image.authors=dvdksn"
39+
]
3740
inherits = ["webDEP"]
3841
}`),
3942
}
@@ -115,6 +118,15 @@ target "webapp" {
115118
})
116119
})
117120

121+
t.Run("AnnotationsOverrides", func(t *testing.T) {
122+
t.Parallel()
123+
m, g, err := ReadTargets(ctx, []File{fp}, []string{"webapp"}, []string{"webapp.annotations=index,manifest:org.opencontainers.image.vendor=docker"}, nil, &EntitlementConf{})
124+
require.NoError(t, err)
125+
require.Equal(t, []string{"index,manifest:org.opencontainers.image.authors=dvdksn", "index,manifest:org.opencontainers.image.vendor=docker"}, m["webapp"].Annotations)
126+
require.Equal(t, 1, len(g))
127+
require.Equal(t, []string{"webapp"}, g["default"].Targets)
128+
})
129+
118130
t.Run("ContextOverride", func(t *testing.T) {
119131
t.Parallel()
120132
_, _, err := ReadTargets(ctx, []File{fp}, []string{"webapp"}, []string{"webapp.context"}, nil, &EntitlementConf{})

docs/reference/buildx_bake.md

+1
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ $ docker buildx bake --set foo*.no-cache # bypass caching only for
354354

355355
You can override the following fields:
356356

357+
* `annotations`
357358
* `args`
358359
* `cache-from`
359360
* `cache-to`

0 commit comments

Comments
 (0)