Skip to content

Commit 1431ba8

Browse files
jlebondustymabe
authored andcommitted
cmd-build-with-buildah: add org.opencontainers.image.{source,revision} labels
These labels contain information about the git repo that was built.
1 parent 2de6b0d commit 1431ba8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/cmd-build-with-buildah

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,20 @@ build_with_buildah() {
131131
fi
132132
fi
133133

134+
# Here we call prepare_git_artifacts just for its git logic, We don't
135+
# actually care about the JSON file; the source of truth is in the labels.
136+
prepare_git_artifacts src/config "${tempdir}/coreos-assembler-config-git.json"
137+
source=$(jq -r .git.origin "${tempdir}/coreos-assembler-config-git.json")
138+
commit=$(jq -r .git.commit "${tempdir}/coreos-assembler-config-git.json")
139+
rm -f "${tempdir}/coreos-assembler-config-git.json"
140+
141+
# For the source: check if there's only one remote, if so use it with get-url
142+
# For revision: rev-parse
134143
set -- build --security-opt=label=disable --cap-add=all --device /dev/fuse \
135144
--build-arg-file "$argsfile" -v "$(realpath "${tempdir}/src")":/run/src \
136-
--build-arg VERSION="${VERSION}"
145+
--build-arg VERSION="${VERSION}" \
146+
--label org.opencontainers.image.source="${source}" \
147+
--label org.opencontainers.image.revision="${commit}"
137148

138149
# XXX: Temporary hack until we have https://github.com/coreos/rpm-ostree/pull/5454
139150
# which would allow us to fold this back into the build process.

0 commit comments

Comments
 (0)