diff --git a/bin/app-json.py b/bin/app-json.py index 2b0ab4a..9b83c0e 100755 --- a/bin/app-json.py +++ b/bin/app-json.py @@ -91,16 +91,32 @@ def get_app_features(app_path): def get_app_versions(app_path): - versions = {} + versions = [] chdir(app_path) + tags = check_output(f"git tag --list", shell=True).strip() + for tag in tags: - # TODO - # checkout that tag in the local git branch - # parse all service images via yq or other magic - # lookup the digest with skopeo - pass + run(f"git checkout", shell=True) + + services_command = "yq e .services | keys | .[] compose*.yml" + services = check_output(services_command, shell=True).decode("utf-8").split() + + for service in services: + images_command = f"yq e '.services.{service}.image' compose*.yml" + images = check_output(images_command, shell=True).decode("utf-8").split() + + for image in images: + if image in ("null", "---"): + continue + + digest_command = f"skopeo inspect {image} | yq '.Digest'" + output = check_output(digest_command, shell=True).decode("utf-8") + digest = output.strip().split(":")[-1][:8] + versions.append( + {service: {"image": image, "tag": tag, "digest": digest}} + ) return versions