Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema: Add entry for base-oscontainer #2907

Merged
merged 2 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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.

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.

7 changes: 6 additions & 1 deletion schema/cosa/cosa_v1.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cosa

// generated by 'make schema'
// source hash: be093d10a3ebf57e28907a5676a88928631bb09eee602dff89f381ddd1ca8f5e
// source hash: ec49fcff4b25566b5f515909fd5fcc22a51c169449e8a6f50390551f7bf97506

type AdvisoryDiff []AdvisoryDiffItems

Expand All @@ -27,13 +27,18 @@ 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"`
BuildArtifacts *BuildArtifacts `json:"images,omitempty"`
BuildID string `json:"buildid"`
BuildRef string `json:"ref,omitempty"`
Expand Down
18 changes: 17 additions & 1 deletion schema/cosa/schema_doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Generated by ./generate-schema.sh
// Source hash: be093d10a3ebf57e28907a5676a88928631bb09eee602dff89f381ddd1ca8f5e
// Source hash: ec49fcff4b25566b5f515909fd5fcc22a51c169449e8a6f50390551f7bf97506
// DO NOT EDIT

package cosa
Expand Down Expand Up @@ -211,6 +211,7 @@ var generatedSchemaJSON = `{
"amis",
"azure",
"azurestack",
"base-oscontainer",
"build-url",
"digitalocean",
"exoscale",
Expand Down Expand Up @@ -842,6 +843,21 @@ var generatedSchemaJSON = `{
"title":"Azure",
"$ref": "#/definitions/cloudartifact"
},
"base-oscontainer": {
"$id":"#/properties/base-oscontainer",
"type":"object",
"title":"Base OS container",
"required": [
"image"
],
"properties": {
"image": {
"$id":"#/properties/base-oscontainer/image",
"type":"string",
"title":"Image"
}
}
},
"gcp": {
"$id":"#/properties/gcp",
"type":"object",
Expand Down
16 changes: 16 additions & 0 deletions schema/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"amis",
"azure",
"azurestack",
"base-oscontainer",
"build-url",
"digitalocean",
"exoscale",
Expand Down Expand Up @@ -836,6 +837,21 @@
"title":"Azure",
"$ref": "#/definitions/cloudartifact"
},
"base-oscontainer": {
"$id":"#/properties/base-oscontainer",
"type":"object",
"title":"Base OS container",
"required": [
"image"
],
"properties": {
"image": {
"$id":"#/properties/base-oscontainer/image",
"type":"string",
"title":"Image"
}
}
},
"gcp": {
"$id":"#/properties/gcp",
"type":"object",
Expand Down
26 changes: 20 additions & 6 deletions src/cmd-push-container
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import argparse
import json
import os
import tempfile
import shutil
import subprocess
import sys

Expand Down Expand Up @@ -44,11 +46,23 @@ if args.authfile is not None:
skopeoargs.extend(['--authfile', args.authfile])
if args.format is not None:
skopeoargs.extend(['--format', args.format])
container_name = args.name
if ":" not in container_name:
container_name = f"{container_name}:{latest_build}-{arch}"
container_name = container_name_and_tag = args.name
if args.base_image_name:
container_name = f"{container_name}-base-image"
skopeoargs.extend([f"oci-archive:{ociarchive}", f"docker://{container_name}"])
print(subprocess.list2cmdline(skopeoargs))
os.execvp('skopeo', skopeoargs)
if ":" not in container_name_and_tag:
container_name_and_tag = f"{container_name}:{latest_build}-{arch}"
if ":" in container_name:
container_name = container_name.rsplit(':')[0]
with tempfile.NamedTemporaryFile(dir='tmp', prefix='push-container-digestfile') as df:
skopeoargs.append(f"--digestfile={df.name}")
skopeoargs.extend([f"oci-archive:{ociarchive}", f"docker://{container_name}"])
print(subprocess.list2cmdline(skopeoargs))
subprocess.check_call(skopeoargs)
df.seek(0)
digest = df.read().decode('utf-8').strip()
# Inject the oscontainer with SHA256 into the build metadata
meta['base-oscontainer'] = {'image': f"{container_name}@{digest}"}
metapath_new = f"{metapath}.new"
with open(metapath_new, 'w') as f:
json.dump(meta, f, sort_keys=True)
shutil.move(metapath_new, metapath)
16 changes: 16 additions & 0 deletions src/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"amis",
"azure",
"azurestack",
"base-oscontainer",
"build-url",
"digitalocean",
"exoscale",
Expand Down Expand Up @@ -836,6 +837,21 @@
"title":"Azure",
"$ref": "#/definitions/cloudartifact"
},
"base-oscontainer": {
"$id":"#/properties/base-oscontainer",
"type":"object",
"title":"Base OS container",
"required": [
"image"
],
"properties": {
"image": {
"$id":"#/properties/base-oscontainer/image",
"type":"string",
"title":"Image"
}
}
},
"gcp": {
"$id":"#/properties/gcp",
"type":"object",
Expand Down