Add parameters for controlling inheritance of labels and annotations

Add new parameters `inherit-annotations` and `inherit-labels` that allows disabling inheritance from the base image or base states.

Signed-off-by: Sebastian Schimpfhauser <seschi98@googlemail.com>
This commit is contained in:
Sebastian Schimpfhauser 2026-01-24 12:12:23 +01:00
parent 64c9b14150
commit 7dcf1e826a
No known key found for this signature in database
6 changed files with 151 additions and 37 deletions

View file

@ -88,6 +88,8 @@ describe('getArgs', () => {
'0.4.1',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -109,6 +111,8 @@ ARG=val
"MULTILINE=aaaa
bbbb
ccc"`],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -128,6 +132,8 @@ ccc"`],
2,
'0.4.2',
new Map<string, string>([
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['tags', 'name/app:7.4, name/app:latest'],
['load', 'false'],
['no-cache', 'false'],
@ -148,6 +154,8 @@ ccc"`],
'0.4.2',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['labels', 'org.opencontainers.image.title=buildkit\norg.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit'],
['outputs', 'type=local,dest=./release-out'],
['load', 'false'],
@ -169,6 +177,8 @@ ccc"`],
'0.4.1',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['platforms', 'linux/amd64,linux/arm64'],
['load', 'false'],
['no-cache', 'false'],
@ -187,6 +197,8 @@ ccc"`],
'0.4.1',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -204,6 +216,8 @@ ccc"`],
'0.4.2',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
['load', 'false'],
['no-cache', 'false'],
@ -223,6 +237,8 @@ ccc"`],
'0.4.2',
new Map<string, string>([
['github-token', 'abcdefghijklmno0123456789'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['outputs', '.'],
['load', 'false'],
['no-cache', 'false'],
@ -242,6 +258,8 @@ ccc"`],
'0.4.2',
new Map<string, string>([
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['tag', 'localhost:5000/name/app:latest'],
['platforms', 'linux/amd64,linux/arm64'],
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
@ -269,6 +287,8 @@ ccc"`],
'0.4.2',
new Map<string, string>([
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['tag', 'localhost:5000/name/app:latest'],
['platforms', 'linux/amd64,linux/arm64'],
['secrets', `GIT_AUTH_TOKEN=abcdefghi,jklmno=0123456789
@ -307,6 +327,8 @@ ccc"`],
'0.4.2',
new Map<string, string>([
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['tag', 'localhost:5000/name/app:latest'],
['platforms', 'linux/amd64,linux/arm64'],
['secrets', `GIT_AUTH_TOKEN=abcdefghi,jklmno=0123456789
@ -345,6 +367,8 @@ ccc`],
'0.5.1',
new Map<string, string>([
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['tag', 'localhost:5000/name/app:latest'],
['secret-files', `MY_SECRET=${path.join(__dirname, 'fixtures', 'secret.txt')}`],
['file', './test/Dockerfile'],
@ -372,6 +396,8 @@ ccc`],
'0.4.2',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['labels', 'org.opencontainers.image.title=filter_results_top_n\norg.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"'],
['outputs', 'type=local,dest=./release-out'],
['load', 'false'],
@ -393,6 +419,8 @@ ccc`],
'0.6.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['tag', 'localhost:5000/name/app:latest'],
['file', './test/Dockerfile'],
['add-hosts', 'docker:10.180.0.1,foo:10.0.0.1'],
@ -420,6 +448,8 @@ ccc`],
'0.7.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['file', './test/Dockerfile'],
['add-hosts', 'docker:10.180.0.1\nfoo:10.0.0.1'],
['cgroup-parent', 'foo'],
@ -451,6 +481,8 @@ nproc=3`],
'0.7.0',
new Map<string, string>([
['context', '{{defaultContext}}:docker'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -470,6 +502,8 @@ nproc=3`],
new Map<string, string>([
['github-token', 'abcdefghijklmno0123456789'],
['context', '{{defaultContext}}:subdir'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -489,6 +523,8 @@ nproc=3`],
'0.8.2',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -508,6 +544,8 @@ nproc=3`],
'0.10.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -527,6 +565,8 @@ nproc=3`],
'0.10.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -547,6 +587,8 @@ nproc=3`],
'0.10.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -567,6 +609,8 @@ nproc=3`],
'0.10.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -587,6 +631,8 @@ nproc=3`],
'0.10.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -607,6 +653,8 @@ nproc=3`],
'0.10.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -627,6 +675,8 @@ nproc=3`],
'0.10.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'true'],
['no-cache', 'false'],
['push', 'false'],
@ -646,6 +696,8 @@ nproc=3`],
'0.10.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['build-args', `FOO=bar#baz`],
['load', 'true'],
['no-cache', 'false'],
@ -667,6 +719,8 @@ nproc=3`],
'0.10.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['no-cache', 'false'],
['load', 'true'],
['push', 'false'],
@ -690,6 +744,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'0.10.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['no-cache', 'false'],
['load', 'true'],
['push', 'false'],
@ -712,6 +768,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'0.11.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['annotations', 'example1=www\nindex:example2=xxx\nmanifest:example3=yyy\nmanifest-descriptor[linux/amd64]:example4=zzz'],
['outputs', 'type=local,dest=./release-out'],
['load', 'false'],
@ -733,6 +791,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'0.12.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['annotations', 'example1=www\nindex:example2=xxx\nmanifest:example3=yyy\nmanifest-descriptor[linux/amd64]:example4=zzz'],
['outputs', 'type=local,dest=./release-out'],
['load', 'false'],
@ -758,6 +818,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'0.12.0',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['outputs', `type=image,"name=localhost:5000/name/app:latest,localhost:5000/name/app:foo",push-by-digest=true,name-canonical=true,push=true`],
['load', 'false'],
['no-cache', 'false'],
@ -779,6 +841,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'0.13.1',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -801,6 +865,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'0.13.1',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -822,6 +888,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'0.13.1',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -842,6 +910,8 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'0.13.1',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'true'],
['inherit-labels', 'true'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
@ -857,6 +927,30 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
['BUILDX_NO_DEFAULT_ATTESTATIONS', '1']
])
],
[
35,
'0.13.1',
new Map<string, string>([
['context', '.'],
['inherit-annotations', 'false'],
['inherit-labels', 'false'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]),
[
'build',
'--iidfile', imageIDFilePath,
'--inherit-annotations', 'false',
'--inherit-labels', 'false',
'--metadata-file', metadataJson,
'.'
],
new Map<string, string>([
['BUILDX_NO_DEFAULT_ATTESTATIONS', '1']
])
],
])(
'[%d] given %p with %p as inputs, returns %p',
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>, envs: Map<string, string> | undefined) => {