Skip to content

Commit 677fe26

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 8bc7a5e commit 677fe26

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:
@@ -165,6 +165,8 @@ Examples:
165165
parser.add_argument('--v2s2', action='store_true',
166166
help='Use old image manifest version 2 schema 2 format')
167167
parser.add_argument("--force", help="Force manifest overwriting", action='store_true')
168+
parser.add_argument('--write-digest-to-file', required=False,
169+
help='Write digest of pushed manifest to named file')
168170

169171
group = parser.add_mutually_exclusive_group(required=True)
170172
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
@@ -53,7 +53,7 @@ def delete_local_container_imgref(repo, tag):
5353
runcmd(cmd)
5454

5555

56-
def push_container_manifest(repo, tags, v2s2=False):
56+
def push_container_manifest(repo, tags, write_digest_to_file, v2s2=False):
5757
'''
5858
Push manifest to registry
5959
@param repo str registry repository
@@ -66,12 +66,14 @@ def push_container_manifest(repo, tags, v2s2=False):
6666
# to create a manifest with 2 different mediaType. It seems to be
6767
# a Quay issue.
6868
base_cmd.extend(["--remove-signatures", "-f", "v2s2"])
69+
if write_digest_to_file:
70+
base_cmd.extend(["--digestfile", write_digest_to_file])
6971
runcmd(base_cmd + [f"{repo}:{tags[0]}"])
7072
for tag in tags[1:]:
7173
runcmd(base_cmd + [f"{repo}:{tag}"])
7274

7375

74-
def create_and_push_container_manifest(repo, tags, images, v2s2) -> dict:
76+
def create_and_push_container_manifest(repo, tags, images, write_digest_to_file, v2s2) -> dict:
7577
'''
7678
Do it all! Create, push, cleanup, and return the final manifest JSON.
7779
@param repo str registry repository
@@ -83,6 +85,6 @@ def create_and_push_container_manifest(repo, tags, images, v2s2) -> dict:
8385
# perhaps left over from a previous failed run -> delete
8486
delete_local_container_imgref(repo, tags[0])
8587
manifest_info = create_local_container_manifest(repo, tags[0], images)
86-
push_container_manifest(repo, tags, v2s2)
88+
push_container_manifest(repo, tags, write_digest_to_file, v2s2)
8789
delete_local_container_imgref(repo, tags[0])
8890
return manifest_info

0 commit comments

Comments
 (0)