Skip to content

Commit

Permalink
Add cosa push-container-manifest command
Browse files Browse the repository at this point in the history
This will create and push a container manifest (i.e. one that contains
multiple images from different architectures) to a remote registry.

(cherry picked from commit 8e5ad58)

jlebon: Had to manually add `push-container-manifest` to the entrypoint.
  • Loading branch information
dustymabe committed Nov 9, 2022
1 parent 66cd767 commit f157945
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
57 changes: 57 additions & 0 deletions src/cmd-push-container-manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/python3

# Push a container manifest (i.e. multi-arch) to a container registry based on
# arguments provided by ther user.

# The inverse of cmd-buildfetch (i.e. we upload a build which later can be
# partially re-downloaded with cmd-buildfetch).

import argparse
import os
import sys
from cosalib.container_manifest import create_and_push_container_manifest

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))


def main():
args = parse_args()
if args.authfile:
os.environ["REGISTRY_AUTH_FILE"] = args.authfile
create_and_push_container_manifest(
args.repo, args.tag, args.images, args.v2s2)


def parse_args():
parser = argparse.ArgumentParser(
prog="CoreOS Assembler Push Container Manifest",
description="Create and push a container manifest to a registry",
usage="""
Examples:
export REGISTRY_AUTH_FILE=/path/to/auth.json
cosa push-container-manifest \\
--repo quay.io/dustymabe/coreos-assembler --tag latest \\
--image docker://quay.io/dustymabe/coreos-assembler:x86_64-6864566 \\
--image docker://quay.io/dustymabe/coreos-assembler:s390x-6864566 \\
--image docker://quay.io/dustymabe/coreos-assembler:aarch64-6864566
cosa push-container-manifest \\
--repo quay.io/dustymabe/fedora-coreos --tag stable \\
--image oci-archive://builds/36.20220716.3.1/x86_64/fedora-coreos-37.20220725.91.0-ostree.x86_64.ociarchive \\
--image oci-archive://builds/36.20220716.3.1/aarch64/fedora-coreos-37.20220725.91.0-ostree.aarch64.ociarchive \\
--image oci-archive://builds/36.20220716.3.1/s390x/fedora-coreos-37.20220725.91.0-ostree.s390x.ociarchive""")
parser.add_argument("--repo", required=True, help="The registry repo to target for the manifest")
parser.add_argument("--tag", required=True, help="The tag of the manifest to use")
parser.add_argument("--authfile", help="A file to use for registry auth")
parser.add_argument('--v2s2', action='store_true',
help='Use old image manifest version2 schema 2 format')
parser.add_argument("--images", required=True, action='append', default=[],
help="""The images to add to the manifest. Can be specified multiple times like
--image docker://quay.io/dustymabe/coreos-assembler:s390x-686456
--image oci-archive://path/to/cosa-aarch64-686456.ociarchive""")

return parser.parse_args()


if __name__ == '__main__':
sys.exit(main())
2 changes: 1 addition & 1 deletion src/coreos-assembler
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cmd=${1:-}
# commands we'd expect to use in the local dev path
build_commands="init fetch build run prune clean list"
# commands more likely to be used in a prod pipeline only
advanced_build_commands="buildfetch buildupload oc-adm-release upload-oscontainer"
advanced_build_commands="buildfetch buildupload oc-adm-release push-container-manifest upload-oscontainer"
buildextend_commands="aliyun aws azure digitalocean exoscale gcp ibmcloud live metal metal4k nutanix openstack qemu vmware vultr"
utility_commands="aws-replicate compress generate-hashlist koji-upload kola remote-prune sign tag"
other_commands="shell meta"
Expand Down

0 comments on commit f157945

Please sign in to comment.