Add cosa commit and rhcos commit as labels in oscontainer
Tackle this issue
@@ -21,6 +21,7 @@ import shutil
import subprocess
from functools import wraps
from time import sleep
+from cosalib import cmdlib
OSCONTAINER_COMMIT_LABEL = 'com.coreos.ostree-commit'
@@ -195,6 +196,19 @@ def oscontainer_build(containers_storage, tmpdir, src, ref, image_name_and_tag,
'-l', OSCONTAINER_COMMIT_LABEL + '=' + rev]
if ostree_version is not None:
config += ['-l', 'version=' + ostree_version]
+
+ with open('builds/builds.json') as fb:
+ builds = json.load(fb)['builds']
+ latest_build = builds[0]['id']
+ arch = cmdlib.get_basearch()
+ metapath = f"builds/{latest_build}/{arch}/meta.json"
+ with open(metapath) as f:
+ meta = json.load(f)
+ rhcos_commit = meta['coreos-assembler.container-config-git']['commit']
+ cosa_commit = meta['coreos-assembler.container-image-git']['commit']
+ config += ['-l', f"com.coreos.coreos-assembler-commit={cosa_commit}"]
+ config += ['-l', f"com.coreos.redhat-coreos-commit={rhcos_commit}"]
+
if display_name is not None:
config += ['-l', 'io.openshift.build.version-display-names=machine-os=' + display_name,
'-l', 'io.openshift.build.versions=machine-os=' + ostree_version]
