Skip to content

Commit 3226fd1

Browse files
ravanellijbtrystram
authored andcommitted
cmd-push-container-manifest: add --write-digest-to-file
- This maps to Podman's --digestfile option, allowing the manifest digest to be saved for future reference or use. Signed-off-by: Renata Ravanelli <[email protected]>
1 parent c461f65 commit 3226fd1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/cmd-push-container-manifest

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def main():
2828
if args.images:
2929
# User provided images directly
3030
create_and_push_container_manifest(
31-
args.repo, args.tags, args.images, args.v2s2)
31+
args.repo, args.tags, args.images, args.write_digest_to_file, args.v2s2)
3232
else:
3333
# Picking up images from artifacts in meta.json
3434
builds = Builds()
@@ -104,7 +104,7 @@ def main():
104104

105105
# Create/Upload the manifest list to the container registry
106106
manifest_info = create_and_push_container_manifest(
107-
args.repo, args.tags, images, args.v2s2)
107+
args.repo, args.tags, images, args.write_digest_to_file, args.v2s2)
108108
# if we pushed in v2s2 mode, we need to reload from the repo the actual
109109
# final digests: https://github.com/containers/podman/issues/16603
110110
if args.v2s2:
@@ -159,6 +159,8 @@ Examples:
159159
parser.add_argument('--v2s2', action='store_true',
160160
help='Use old image manifest version 2 schema 2 format')
161161
parser.add_argument("--force", help="Force manifest overwriting", action='store_true')
162+
parser.add_argument('--write-digest-to-file', required=False,
163+
help='Write digest of pushed manifest to named file')
162164

163165
group = parser.add_mutually_exclusive_group(required=True)
164166
group.add_argument("--image", dest='images', action='append', default=[],

src/cosalib/container_manifest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def delete_local_container_manifest(repo, tag):
4848
runcmd(cmd)
4949

5050

51-
def push_container_manifest(repo, tags, v2s2=False):
51+
def push_container_manifest(repo, tags, write_digest_to_file, v2s2=False):
5252
'''
5353
Push manifest to registry
5454
@param repo str registry repository
@@ -61,12 +61,14 @@ def push_container_manifest(repo, tags, v2s2=False):
6161
# to create a manifest with 2 different mediaType. It seems to be
6262
# a Quay issue.
6363
base_cmd.extend(["--remove-signatures", "-f", "v2s2"])
64+
if write_digest_to_file:
65+
base_cmd.extend(["--digestfile", write_digest_to_file])
6466
runcmd(base_cmd + [f"{repo}:{tags[0]}"])
6567
for tag in tags[1:]:
6668
runcmd(base_cmd + [f"{repo}:{tag}"])
6769

6870

69-
def create_and_push_container_manifest(repo, tags, images, v2s2) -> dict:
71+
def create_and_push_container_manifest(repo, tags, images, write_digest_to_file, v2s2) -> dict:
7072
'''
7173
Do it all! Create, push, cleanup, and return the final manifest JSON.
7274
@param repo str registry repository
@@ -78,6 +80,6 @@ def create_and_push_container_manifest(repo, tags, images, v2s2) -> dict:
7880
# perhaps left over from a previous failed run -> delete
7981
delete_local_container_manifest(repo, tags[0])
8082
manifest_info = create_local_container_manifest(repo, tags[0], images)
81-
push_container_manifest(repo, tags, v2s2)
83+
push_container_manifest(repo, tags, write_digest_to_file, v2s2)
8284
delete_local_container_manifest(repo, tags[0])
8385
return manifest_info

0 commit comments

Comments
 (0)