blob: b4d48e96111c54524317edd7b47f8e782b6c4640 [file] [log] [blame]
Mohammed Naser71ebfe82022-12-28 05:28:16 +00001from docker_image import reference
2
3from atmosphere.operator import constants
4
5
6def get_image_ref(
7 image_name: str, override_registry: str = None
8) -> reference.Reference:
9 ref = reference.Reference.parse(constants.IMAGE_LIST[image_name])
Mohammed Naser9766b482023-01-03 00:51:05 -050010 if not override_registry:
Mohammed Naser71ebfe82022-12-28 05:28:16 +000011 return ref
12
13 # NOTE(mnaser): We re-write the name of a few images to make sense of them
14 # in the context of the override registry.
15 ref_name = ref.repository["path"].split("/")[-1]
16 if image_name == "skopeo":
17 ref_name = "skopeo-stable"
18
19 # NOTE(mnaser): Since the attributes inside of reference.Reference are not
20 # determined during parse time, we need to re-parse the
21 # string to get the correct attributes.
22 ref["name"] = "{}/{}".format(override_registry, ref_name)
23 ref = reference.Reference.parse(ref.string())
24
25 return ref