1
+ import json
2
+
1
3
from cosalib .cmdlib import runcmd
2
4
3
5
4
- def create_local_container_manifest (repo , tag , images ):
6
+ def create_local_container_manifest (repo , tag , images ) -> dict :
5
7
'''
6
- Create local manifest list
8
+ Create local manifest list and return the final manifest JSON
7
9
@param images list of image specifications (including transport)
8
10
@param repo str registry repository
9
11
@param tag str manifest tag
@@ -13,6 +15,9 @@ def create_local_container_manifest(repo, tag, images):
13
15
for image in images :
14
16
cmd = ["podman" , "manifest" , "add" , f"{ repo } :{ tag } " , image ]
15
17
runcmd (cmd )
18
+ manifest_info = runcmd (["podman" , "manifest" , "inspect" , f"{ repo } :{ tag } " ],
19
+ capture_output = True ).stdout
20
+ return json .loads (manifest_info )
16
21
17
22
18
23
def delete_local_container_manifest (repo , tag ):
@@ -25,12 +30,11 @@ def delete_local_container_manifest(repo, tag):
25
30
runcmd (cmd )
26
31
27
32
28
- def push_container_manifest (repo , tags , digestfile , v2s2 = False ):
33
+ def push_container_manifest (repo , tags , v2s2 = False ):
29
34
'''
30
35
Push manifest to registry
31
36
@param repo str registry repository
32
37
@param tags list of tags to push
33
- @param digestfile str write container digest to file
34
38
@param v2s2 boolean use to force v2s2 format
35
39
'''
36
40
base_cmd = ["podman" , "manifest" , "push" , "--all" , f"{ repo } :{ tags [0 ]} " ]
@@ -39,22 +43,20 @@ def push_container_manifest(repo, tags, digestfile, v2s2=False):
39
43
# to create a manifest with 2 different mediaType. It seems to be
40
44
# a Quay issue.
41
45
base_cmd .extend (["--remove-signatures" , "-f" , "v2s2" ])
42
- if digestfile :
43
- base_cmd .extend ([f"--digestfile={ digestfile } " ])
44
46
runcmd (base_cmd + [f"{ repo } :{ tags [0 ]} " ])
45
47
for tag in tags [1 :]:
46
48
runcmd (base_cmd + [f"{ repo } :{ tag } " ])
47
49
48
50
49
- def create_and_push_container_manifest (repo , tags , images , v2s2 , digestfile ) :
51
+ def create_and_push_container_manifest (repo , tags , images , v2s2 ) -> dict :
50
52
'''
51
- Do it all! Create, Push, Cleanup
53
+ Do it all! Create, push, cleanup, and return the final manifest JSON.
52
54
@param repo str registry repository
53
55
@param tags list of tags
54
56
@param images list of image specifications (including transport)
55
57
@param v2s2 boolean use to force v2s2 format
56
- @param digestfile str write container digest to file
57
58
'''
58
- create_local_container_manifest (repo , tags [0 ], images )
59
- push_container_manifest (repo , tags , digestfile , v2s2 )
59
+ manifest_info = create_local_container_manifest (repo , tags [0 ], images )
60
+ push_container_manifest (repo , tags , v2s2 )
60
61
delete_local_container_manifest (repo , tags [0 ])
62
+ return manifest_info
0 commit comments