Skip to content

Commit

Permalink
cmd-build: Conditionally change the packing structure of container-image
Browse files Browse the repository at this point in the history
When the previous build exists, use its packing structure otherwise container-encapsulate
generates a new one
  • Loading branch information
RishabhSaini committed May 31, 2023
1 parent 6f0ed42 commit 599491e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/builds/cosa_v1.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package builds

// generated by 'make schema'
// source hash: 2cd4fe2a0c72e389ee6cb2b906653cdfd33f87b87d7e2e261fce4615a8c0272a
// source hash: a5fec50536bd4c2eed006dfb897b3b40fdf50393a0e3e32edf874b4e200e4e4d

type AdvisoryDiff []AdvisoryDiffItems

Expand Down Expand Up @@ -106,6 +106,7 @@ type BuildArtifacts struct {
Metal *Artifact `json:"metal,omitempty"`
Metal4KNative *Artifact `json:"metal4k,omitempty"`
Nutanix *Artifact `json:"nutanix,omitempty"`
OciManifest *Artifact `json:"oci-manifest,omitempty"`
OpenStack *Artifact `json:"openstack,omitempty"`
Ostree Artifact `json:"ostree"`
PowerVirtualServer *Artifact `json:"powervs,omitempty"`
Expand Down
11 changes: 9 additions & 2 deletions pkg/builds/schema_doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Generated by ./generate-schema.sh
// Source hash: 2cd4fe2a0c72e389ee6cb2b906653cdfd33f87b87d7e2e261fce4615a8c0272a
// Source hash: a5fec50536bd4c2eed006dfb897b3b40fdf50393a0e3e32edf874b4e200e4e4d
// DO NOT EDIT

package builds
Expand Down Expand Up @@ -479,7 +479,8 @@ var generatedSchemaJSON = `{
"vmware",
"vultr",
"qemu-secex",
"ignition-gpg-key"
"ignition-gpg-key",
"oci-manifest"
],
"properties": {
"ostree": {
Expand All @@ -488,6 +489,12 @@ var generatedSchemaJSON = `{
"title": "OSTree",
"$ref": "#/definitions/artifact"
},
"oci-manifest": {
"$id": "#/properties/images/properties/oci-manifest",
"type": "object",
"title": "OCI Manifest",
"$ref": "#/definitions/artifact"
},
"dasd": {
"$id": "#/properties/images/properties/dasd",
"type": "object",
Expand Down
20 changes: 20 additions & 0 deletions src/cmd-build
Original file line number Diff line number Diff line change
Expand Up @@ -452,18 +452,33 @@ else
"--label=io.openshift.build.versions=machine-os=${buildid}"
)
fi

last_build_manifest=()
# Use the last stable release if buildfetch used
if [ -n "${PARENT_BUILD}" ]; then
last_build_manifest+=("--previous_build_manifest=${parent_builddir}/${name}-${PARENT_BUILD}-ostree.${basearch}-manifest.json")
# Use the previous local build
elif [ -n "${previous_build}" ]; then
last_build_manifest+=("--previous_build_manifest=${previous_builddir}/${name}-${previous_build}-ostree.${basearch}-manifest.json")
fi
runv rpm-ostree compose container-encapsulate --max-layers="$MAX_OSTREECONTAINER_LAYERS" --format-version=1 \
--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}" \
--copymeta-opt=fedora-coreos.stream \
"${last_build_manifest[@]}" \
"${labels[@]}" \
"${buildid}" \
oci-archive:"${ostree_tarfile_path}".tmp:latest
/usr/lib/coreos-assembler/finalize-artifact "${ostree_tarfile_path}"{.tmp,}
ostree_tarfile_sha256=$(sha256sum "${ostree_tarfile_path}" | awk '{print$1}')
ostree_oci_manifest_path="${name}-${buildid}-ostree.${basearch}-manifest.json"
skopeo inspect --raw oci-archive:"${ostree_tarfile_path}" > tmp/manifest.json
/usr/lib/coreos-assembler/finalize-artifact tmp/manifest.json "${ostree_oci_manifest_path}"
ostree_oci_manifest_sha256=$(sha256sum "${ostree_oci_manifest_path}" | awk '{print$1}')
ostree_oci_manifest_size=$(stat --format=%s "${ostree_oci_manifest_path}")
fi

# The base metadata, plus locations for code sources.
Expand Down Expand Up @@ -507,6 +522,11 @@ cat > tmp/images.json <<EOF
"sha256": "${ostree_tarfile_sha256}",
"size": ${ostree_tarfile_size},
"skip-compression": true
},
"oci-manifest": {
"path": "${ostree_oci_manifest_path}",
"sha256": "${ostree_oci_manifest_sha256}",
"size": ${ostree_oci_manifest_size}
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@
"vmware",
"vultr",
"qemu-secex",
"ignition-gpg-key"
"ignition-gpg-key",
"oci-manifest"
],
"properties": {
"ostree": {
Expand All @@ -482,6 +483,12 @@
"title": "OSTree",
"$ref": "#/definitions/artifact"
},
"oci-manifest": {
"$id": "#/properties/images/properties/oci-manifest",
"type": "object",
"title": "OCI Manifest",
"$ref": "#/definitions/artifact"
},
"dasd": {
"$id": "#/properties/images/properties/dasd",
"type": "object",
Expand Down

0 comments on commit 599491e

Please sign in to comment.