Skip to content

Commit

Permalink
build: Add image.yaml option to inject OpenShift CVO annotations
Browse files Browse the repository at this point in the history
We had these in the legacy oscontainer for RHCOS, and OKD today
hacks them in via a Dockerfile:
https://github.com/openshift/okd-machine-os/blob/0e9fbabbd3363bfc46d9d657bc173666e83e5d18/Dockerfile#L34

We need to carry support for this forward into the new format image,
as it's what is used to display the OS version as part of the release
image.
  • Loading branch information
cgwalters authored and jlebon committed Nov 1, 2022
1 parent 805ff1d commit 0d0bddf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cmd-build
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ else
ostree_tarfile_path="${name}-${buildid}-ostree.${basearch}.ociarchive"
gitsrc=$(jq -r .git.origin < "${PWD}/coreos-assembler-config-git.json")
cmd=(ostree container encapsulate --copymeta="rpmostree.inputhash")
openshift_cvo_labels=$(jq -r '.["ostree-container-inject-openshift-cvo-labels"]' < "${image_json}")

# The ostree-ext default is 64, but this is still too much apparently
# for (older?) versions of podman AKA containers/storage (or maybe)
Expand All @@ -419,11 +420,18 @@ else
;;
*) fatal "Unknown ostree-format: ${ostree_format}"
esac
labels=()
if test "${openshift_cvo_labels}" = "true"; then
labels+=("--label=io.openshift.build.version-display-names=machine-os=$(extract_osrelease_name "$buildid")" \
"--label=io.openshift.build.versions=machine-os=${buildid}"
)
fi
runv "${cmd[@]}" --repo="${tmprepo}" \
--label="coreos-assembler.image-config-checksum=${image_config_checksum}" \
--label="coreos-assembler.image-input-checksum=${image_input_checksum}" \
--label="org.opencontainers.image.source=${gitsrc}" \
--label="org.opencontainers.image.revision=${config_gitrev}" \
"${labels[@]}" \
"${buildid}" \
oci-archive:"${ostree_tarfile_path}".tmp:latest
/usr/lib/coreos-assembler/finalize-artifact "${ostree_tarfile_path}"{.tmp,}
Expand Down
10 changes: 10 additions & 0 deletions src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1038,3 +1038,13 @@ buildmeta = builds.get_build_meta('${buildid}')
cmdlib.import_ostree_commit(workdir, builddir, buildmeta)
")
}

# Extract the value of NAME from os-release
extract_osrelease_name() {
local buildid=$1; shift
local out="$workdir/tmp/osrelease"
rm "${out}" -rf
ostree checkout --repo "${tmprepo}" --user-mode --subpath=/usr/lib/os-release "${buildid}" "$out"
# shellcheck disable=SC1091,SC2153
(. "$out/os-release" && echo "${NAME}")
}
2 changes: 2 additions & 0 deletions src/image-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ extra-kargs: []

# Can also be oci-chunked
ostree-format: oci-chunked-v1
# Inject io.openshift.build.version-display-names for OpenShift CVO
ostree-container-inject-openshift-cvo-labels: false
# True if we should use `ostree container image deploy`
deploy-via-container: false

Expand Down

0 comments on commit 0d0bddf

Please sign in to comment.