Skip to content

Commit

Permalink
cmd-push-container-manifest: change image format
Browse files Browse the repository at this point in the history
The `oscontainer` and `base-oscontainer` keys should follow the same
schema. Currently, the former has a `digest` field, while the other one
does not. Tweak `cosa push-container-manifest` and `cosa push-container`
so that they follows the new schema. (Though note the latter command
will be deleted soon).

To keep previous 4.12 `meta.json` files valid, this loosens the `image`
schema definition so that `digest` is now optional. Once we branch for
4.12, we will undo this change so that it becomes required again.

Fixes coreos#3122
  • Loading branch information
jlebon committed Oct 20, 2022
1 parent e4bf879 commit a84bfc7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 92 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 4 additions & 12 deletions 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: 144450d458f89f637ca487d353af3dfd60096ddbf3179da8e2b42b2bd2d0a6eb
// source hash: 1a456ce336dcdcc026bc6c3bb171f8a3a71cb39bebd38986e6e9ef3a2a25cf73

type AdvisoryDiff []AdvisoryDiffItems

Expand All @@ -27,18 +27,14 @@ type Artifact struct {
UncompressedSize int `json:"uncompressed-size,omitempty"`
}

type BaseOsContainer struct {
Image string `json:"image"`
}

type Build struct {
AdvisoryDiffAgainstParent AdvisoryDiff `json:"parent-advisories-diff,omitempty"`
AdvisoryDiffBetweenBuilds AdvisoryDiff `json:"advisories-diff,omitempty"`
AlibabaAliyunUploads []AliyunImage `json:"aliyun,omitempty"`
Amis []Amis `json:"amis,omitempty"`
Architecture string `json:"coreos-assembler.basearch,omitempty"`
Azure *Cloudartifact `json:"azure,omitempty"`
BaseOsContainer *BaseOsContainer `json:"base-oscontainer,omitempty"`
BaseOsContainer *Image `json:"base-oscontainer,omitempty"`
BuildArtifacts *BuildArtifacts `json:"images,omitempty"`
BuildID string `json:"buildid"`
BuildRef string `json:"ref,omitempty"`
Expand All @@ -54,7 +50,7 @@ type Build struct {
CosaImageChecksum string `json:"coreos-assembler.image-config-checksum,omitempty"`
CosaImageVersion int `json:"coreos-assembler.image-genver,omitempty"`
Extensions *Extensions `json:"extensions,omitempty"`
ExtensionsContainer *ExtensionsContainer `json:"extensions-container,omitempty"`
ExtensionsContainer *Image `json:"extensions-container,omitempty"`
FedoraCoreOsParentCommit string `json:"fedora-coreos.parent-commit,omitempty"`
FedoraCoreOsParentVersion string `json:"fedora-coreos.parent-version,omitempty"`
Gcp *Gcp `json:"gcp,omitempty"`
Expand Down Expand Up @@ -133,10 +129,6 @@ type Extensions struct {
Sha256 string `json:"sha256"`
}

type ExtensionsContainer struct {
Image string `json:"image"`
}

type Gcp struct {
ImageFamily string `json:"family,omitempty"`
ImageName string `json:"image"`
Expand All @@ -153,7 +145,7 @@ type Git struct {

type Image struct {
Comment string `json:"comment,omitempty"`
Digest string `json:"digest"`
Digest string `json:"digest,omitempty"`
Image string `json:"image"`
}

Expand Down
26 changes: 4 additions & 22 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: 144450d458f89f637ca487d353af3dfd60096ddbf3179da8e2b42b2bd2d0a6eb
// Source hash: 1a456ce336dcdcc026bc6c3bb171f8a3a71cb39bebd38986e6e9ef3a2a25cf73
// DO NOT EDIT

package builds
Expand Down Expand Up @@ -56,10 +56,10 @@ var generatedSchemaJSON = `{
"image": {
"type": "object",
"required": [
"digest",
"image"
],
"optional": [
"digest",
"comment"
],
"properties": {
Expand Down Expand Up @@ -875,31 +875,13 @@ var generatedSchemaJSON = `{
"$id": "#/properties/base-oscontainer",
"type": "object",
"title": "Base OS container",
"required": [
"image"
],
"properties": {
"image": {
"$id": "#/properties/base-oscontainer/image",
"type": "string",
"title": "Image"
}
}
"$ref": "#/definitions/image"
},
"extensions-container": {
"$id": "#/properties/extensions-container",
"type": "object",
"title": "Extensions container",
"required": [
"image"
],
"properties": {
"image": {
"$id": "#/properties/extensions-container/image",
"type": "string",
"title": "Image"
}
}
"$ref": "#/definitions/image"
},
"gcp": {
"$id": "#/properties/gcp",
Expand Down
5 changes: 4 additions & 1 deletion src/cmd-push-container
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ with tempfile.NamedTemporaryFile(dir='tmp', prefix='push-container-digestfile')
container = 'base-oscontainer'
if args.image != 'ostree':
container = args.image
meta[container] = {'image': f"{container_name}@{digest}"}
meta[container] = {
'image': container_name,
'digest': digest
}
metapath_new = f"{metapath}.new"
with open(metapath_new, 'w') as f:
json.dump(meta, f, sort_keys=True)
Expand Down
5 changes: 4 additions & 1 deletion src/cmd-push-container-manifest
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def main():

# Update the meta.json in each build/arch metadata
for _, buildmeta in buildmetas.items():
buildmeta[args.metajsonname] = {'image': f"{args.repo}@{digest}"}
buildmeta[args.metajsonname] = {
'image': args.repo,
'digest': digest
}
buildmeta.write(artifact_name=args.metajsonname)


Expand Down
26 changes: 4 additions & 22 deletions src/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
"image": {
"type": "object",
"required": [
"digest",
"image"
],
"optional": [
"digest",
"comment"
],
"properties": {
Expand Down Expand Up @@ -869,31 +869,13 @@
"$id": "#/properties/base-oscontainer",
"type": "object",
"title": "Base OS container",
"required": [
"image"
],
"properties": {
"image": {
"$id": "#/properties/base-oscontainer/image",
"type": "string",
"title": "Image"
}
}
"$ref": "#/definitions/image"
},
"extensions-container": {
"$id": "#/properties/extensions-container",
"type": "object",
"title": "Extensions container",
"required": [
"image"
],
"properties": {
"image": {
"$id": "#/properties/extensions-container/image",
"type": "string",
"title": "Image"
}
}
"$ref": "#/definitions/image"
},
"gcp": {
"$id": "#/properties/gcp",
Expand Down Expand Up @@ -970,4 +952,4 @@
"$ref": "#/definitions/image"
}
}
}
}

0 comments on commit a84bfc7

Please sign in to comment.