Skip to content

Commit 2f9f493

Browse files
committed
Actually retag images when a tag is passed to taskgraph load-image
Fixes #712
1 parent ec06326 commit 2f9f493

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/taskgraph/docker.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,21 @@ def download_and_modify_image():
194194
# Open stream reader for the member
195195
reader = tarin.extractfile(member)
196196

197+
# If the member is `manifest.json` and we're retagging the image,
198+
# override RepoTags.
199+
if member.name == "manifest.json" and imageName:
200+
manifest = json.loads(reader.read()) # type: ignore
201+
reader.close() # type: ignore
202+
203+
if len(manifest) > 1:
204+
raise Exception("file contains more than one manifest")
205+
206+
repo_tags = manifest[0]["RepoTags"] = [f"{imageName}:{imageTag}"]
207+
208+
data = json.dumps(manifest)
209+
reader = BytesIO(data.encode("utf-8"))
210+
member.size = len(data)
211+
197212
# If member is `repositories`, we parse and possibly rewrite the
198213
# image tags.
199214
if member.name == "repositories":

0 commit comments

Comments
 (0)