def get_expiration_map()

in wadebug/wa_actions/docker_utils.py [0:0]


def get_expiration_map():
    def is_wa_image(image):
        if not image["RepoDigests"]:
            return False
        for repo_tag in image["RepoDigests"]:
            return (
                repo_tag.find(WA_WEBAPP_CONTAINER_TAG) > -1
                or repo_tag.find(WA_COREAPP_CONTAINER_TAG) > -1
            )

    client = docker.from_env()
    images = client.api.images()
    expiration_map = {}
    for image in images:
        if is_wa_image(image):
            ver = get_version(image["RepoTags"][0].split(":")[1])
            if ver[0] not in expiration_map:
                if "Labels" in image and "EXPIRES_ON" in image["Labels"]:
                    dt_ts = datetime.strptime(
                        image["Labels"]["EXPIRES_ON"], EXPIRED_DATE_FORMAT
                    )
                    expiration_map[ver[0]] = str(dt_ts)
                    continue
                ts = get_expiry_date(ver[0], image["Created"])
                expiration_map[ver[0]] = ts
    return expiration_map