mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
Merge pull request #2997 from jsternberg/bake-set-annotations
bake: allow annotations to be set on the command line
This commit is contained in:
commit
accfbf6e24
@ -555,9 +555,9 @@ func (c Config) newOverrides(v []string) (map[string]map[string]Override, error)
|
||||
o := t[kk[1]]
|
||||
|
||||
// IMPORTANT: if you add more fields here, do not forget to update
|
||||
// docs/bake-reference.md and https://docs.docker.com/build/bake/overrides/
|
||||
// docs/reference/buildx_bake.md (--set) and https://docs.docker.com/build/bake/overrides/
|
||||
switch keys[1] {
|
||||
case "output", "cache-to", "cache-from", "tags", "platform", "secrets", "ssh", "attest", "entitlements", "network":
|
||||
case "output", "cache-to", "cache-from", "tags", "platform", "secrets", "ssh", "attest", "entitlements", "network", "annotations":
|
||||
if len(parts) == 2 {
|
||||
o.ArrValue = append(o.ArrValue, parts[1])
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ target "webapp" {
|
||||
args = {
|
||||
VAR_BOTH = "webapp"
|
||||
}
|
||||
annotations = [
|
||||
"index,manifest:org.opencontainers.image.authors=dvdksn"
|
||||
]
|
||||
inherits = ["webDEP"]
|
||||
}`),
|
||||
}
|
||||
@ -115,6 +118,15 @@ target "webapp" {
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("AnnotationsOverrides", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
m, g, err := ReadTargets(ctx, []File{fp}, []string{"webapp"}, []string{"webapp.annotations=index,manifest:org.opencontainers.image.vendor=docker"}, nil, &EntitlementConf{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{"index,manifest:org.opencontainers.image.authors=dvdksn", "index,manifest:org.opencontainers.image.vendor=docker"}, m["webapp"].Annotations)
|
||||
require.Equal(t, 1, len(g))
|
||||
require.Equal(t, []string{"webapp"}, g["default"].Targets)
|
||||
})
|
||||
|
||||
t.Run("ContextOverride", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, _, err := ReadTargets(ctx, []File{fp}, []string{"webapp"}, []string{"webapp.context"}, nil, &EntitlementConf{})
|
||||
|
@ -354,6 +354,7 @@ $ docker buildx bake --set foo*.no-cache # bypass caching only for
|
||||
|
||||
You can override the following fields:
|
||||
|
||||
* `annotations`
|
||||
* `args`
|
||||
* `cache-from`
|
||||
* `cache-to`
|
||||
|
Loading…
x
Reference in New Issue
Block a user