diff --git a/cmd/build-extensions-container.go b/cmd/build-extensions-container.go index e0e938e3a9..ce60b47420 100644 --- a/cmd/build-extensions-container.go +++ b/cmd/build-extensions-container.go @@ -185,8 +185,34 @@ func buildExtensionContainer() error { SizeInBytes: float64(stat.Size()), SkipCompression: true, } - cosaBuild.MetaStamp = float64(time.Now().UnixNano()) + fmt.Printf("Generating meta.json `extensions` entry for: %s\n", buildID) + // The /tmp/extensions.json file is generated as part of the extension container build process. + // For more details, refer to: + // https://github.com/openshift/os/blob/master/extensions/Dockerfile + extensionsFilePath:= "./tmp/extensions.json" + fileContent, err := os.ReadFile(extensionsFilePath) + if err != nil { + fmt.Printf("Error reading JSON file: %v\n", err) + return err + } + // Parse the JSON content into a map + packages := make(map[string]string) + err = json.Unmarshal(fileContent, &packages) + if err != nil { + fmt.Printf("Error parsing JSON content: %v\n", err) + return err + } + + // Convert to extensionsInterfaceMap + extensionsInterfaceMap := make(map[string]interface{}) + for key, value := range packages { + extensionsInterfaceMap[key] = value + } + cosaBuild.Extensions = &cosa.Extensions { + Manifest: extensionsInterfaceMap, + } + cosaBuild.MetaStamp = float64(time.Now().UnixNano()) newBytes, err := json.MarshalIndent(cosaBuild, "", " ") if err != nil { return err diff --git a/pkg/builds/cosa_v1.go b/pkg/builds/cosa_v1.go index f439b4020f..e05f9e8ca3 100644 --- a/pkg/builds/cosa_v1.go +++ b/pkg/builds/cosa_v1.go @@ -1,7 +1,7 @@ package builds // generated by 'make schema' -// source hash: 4bb2fd8591ae1cc9179181b9efcb550542137a01c9544fd048e66794e0fb176a +// source hash: d7b6e01415317b89e346747884eb3536cc9e78049a2c71615739afd51fa65569 type AdvisoryDiff []AdvisoryDiffItems @@ -129,9 +129,9 @@ type Cloudartifact struct { type Extensions struct { Manifest map[string]interface{} `json:"manifest"` - Path string `json:"path"` - RpmOstreeState string `json:"rpm-ostree-state"` - Sha256 string `json:"sha256"` + Path string `json:"path,omitempty"` + RpmOstreeState string `json:"rpm-ostree-state,omitempty"` + Sha256 string `json:"sha256,omitempty"` } type Gcp struct { diff --git a/pkg/builds/schema_doc.go b/pkg/builds/schema_doc.go index c7833fd763..663f07506e 100644 --- a/pkg/builds/schema_doc.go +++ b/pkg/builds/schema_doc.go @@ -1,5 +1,5 @@ // Generated by ./generate-schema.sh -// Source hash: 4bb2fd8591ae1cc9179181b9efcb550542137a01c9544fd048e66794e0fb176a +// Source hash: d7b6e01415317b89e346747884eb3536cc9e78049a2c71615739afd51fa65569 // DO NOT EDIT package builds @@ -707,10 +707,12 @@ var generatedSchemaJSON = `{ "$id": "#/properties/extensions", "type": "object", "title": "Extensions", - "required": [ + "optional": [ "path", "sha256", - "rpm-ostree-state", + "rpm-ostree-state" + ], + "required": [ "manifest" ], "properties": { diff --git a/schema/generate-schema.sh b/schema/generate-schema.sh index 73b50c7f86..99fcfce189 100755 --- a/schema/generate-schema.sh +++ b/schema/generate-schema.sh @@ -20,8 +20,13 @@ else schematyper=$(which schematyper 2>/dev/null || true) fi if test -z "${schematyper}"; then - env GOBIN=${topdir}/bin go install github.com/idubinskiy/schematyper@latest - schematyper=${topdir}/bin/schematyper + if [ ! -d "${topdir}/schematyper" ]; then + git clone https://github.com/idubinskiy/schematyper.git ${topdir}/schematyper + go -C ${topdir}/schematyper mod edit -replace gopkg.in/alecthomas/kingpin.v2=github.com/alecthomas/kingpin/v2@v2.4.0 + go -C ${topdir}/schematyper mod tidy && go -C ${topdir}/schematyper mod vendor + go -C ${topdir}/schematyper build + fi + schematyper=${topdir}/schematyper/schematyper fi ${schematyper} \ diff --git a/src/build-extensions-container.sh b/src/build-extensions-container.sh index 621600c54e..1ef9893e08 100755 --- a/src/build-extensions-container.sh +++ b/src/build-extensions-container.sh @@ -24,6 +24,7 @@ if [[ -f "${workdir}/src/config.json" ]]; then fi mkdir "${ctx_dir}/hotfixes" +touch "${workdir}/tmp/extensions.json" tar -xC "${ctx_dir}/hotfixes" -f /dev/disk/by-id/virtio-hotfixes # Build the image, replacing the FROM directive with the local image we have. @@ -33,6 +34,7 @@ img=localhost/extensions-container (set -x; podman build --from oci-archive:"$ostree_ociarchive" --network=host \ --build-arg COSA=true --build-arg VARIANT="${variant}" --label version="$buildid" \ --volume /etc/pki/ca-trust:/etc/pki/ca-trust:ro \ + --volume "${workdir}"/tmp/extensions.json:/tmp/extensions.json \ -t "${img}" -f extensions/Dockerfile "${ctx_dir}") # Call skopeo to export it from the container storage to an oci-archive. diff --git a/src/cmd-coreos-prune b/src/cmd-coreos-prune index c85f0ad7d9..e843fc9008 100755 --- a/src/cmd-coreos-prune +++ b/src/cmd-coreos-prune @@ -56,7 +56,7 @@ Build = collections.namedtuple("Build", ["id", "images", "arch", "meta_json"]) # set metadata caching to 5m CACHE_MAX_AGE_METADATA = 60 * 5 # These lists are up to date as of schema hash -# 4bb2fd8591ae1cc9179181b9efcb550542137a01c9544fd048e66794e0fb176a. If changing +# d7b6e01415317b89e346747884eb3536cc9e78049a2c71615739afd51fa65569. If changing # this hash, ensure that the list of SUPPORTED and UNSUPPORTED artifacts below # is up to date. SUPPORTED = ["amis", "gcp"] diff --git a/src/v1.json b/src/v1.json index df27d327a2..ebc80bf080 100644 --- a/src/v1.json +++ b/src/v1.json @@ -701,10 +701,12 @@ "$id": "#/properties/extensions", "type": "object", "title": "Extensions", - "required": [ + "optional": [ "path", "sha256", - "rpm-ostree-state", + "rpm-ostree-state" + ], + "required": [ "manifest" ], "properties": {