From f4ab771e2a7d70a9ae2f4d7216048198f4d4304f Mon Sep 17 00:00:00 2001 From: decentral1se Date: Fri, 2 Apr 2021 16:43:43 +0200 Subject: [PATCH] First working generation (woohoo) --- bin/app-json.py | 51 ++++++++++--------- .../abra-apps.autonomic.zone/abra-apps.json | 36 +++++++++++++ 2 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 deploy/abra-apps.autonomic.zone/abra-apps.json diff --git a/bin/app-json.py b/bin/app-json.py index 6ff8cdc..0ccdc55 100755 --- a/bin/app-json.py +++ b/bin/app-json.py @@ -52,7 +52,7 @@ def gen_apps_json(): chdir(app_path) output = check_output("git tag --list", shell=True) - tags = output.strip().decode("utf-8") + tags = output.decode("utf-8").strip().split() if not tags: continue @@ -61,16 +61,21 @@ def gen_apps_json(): apps_json[app] = { "category": "apps", "repository": f"https://git.autonomic.zone/coop-cloud/{app}.git", - "features": get_app_features(app_path), - "versions": get_app_versions(app_path), + "features": get_app_features(app_path, tag), + "versions": get_app_versions(app_path, tag), } return apps_json -def get_app_features(app_path): +def get_app_features(app_path, tag): + print(f"Gathering features for {app_path}, tag: {tag}") + features = {} + chdir(app_path) + run(f"git checkout {tag}", shell=True) + with open(f"{app_path}/README.md", "r") as handle: contents = handle.read() @@ -87,37 +92,35 @@ def get_app_features(app_path): value = match.split(":")[-1].replace("*", "").strip() features[title] = value + run(f"git checkout HEAD", shell=True) return features -def get_app_versions(app_path): +def get_app_versions(app_path, tag): + print(f"Gathering versions for {app_path}, tag: {tag}") + versions = [] chdir(app_path) + run(f"git checkout {tag}", shell=True) - tags = check_output(f"git tag --list", shell=True).decode("utf-8").strip().split() + services_command = "yq e '.services | keys | .[]' compose*.yml" + services = check_output(services_command, shell=True).decode("utf-8").split() - for tag in tags: - run(f"git checkout {tag}", shell=True) + 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() - services_command = "yq e '.services | keys | .[]' compose*.yml" - services = check_output(services_command, shell=True).decode("utf-8").split() + for image in images: + if image in ("null", "---"): + continue - 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 docker://{image} | jq '.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}} - ) + digest_command = f"skopeo inspect docker://{image} | jq '.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}}) + run(f"git checkout HEAD", shell=True) return versions diff --git a/deploy/abra-apps.autonomic.zone/abra-apps.json b/deploy/abra-apps.autonomic.zone/abra-apps.json new file mode 100644 index 0000000..f4ef5e0 --- /dev/null +++ b/deploy/abra-apps.autonomic.zone/abra-apps.json @@ -0,0 +1,36 @@ +{ + "gitea": { + "category": "apps", + "repository": "https://git.autonomic.zone/coop-cloud/gitea.git", + "features": { + "category": "Development", + "status": "β·πŸ’›", + "image": { + "image": "gitea/gitea", + "url": "https://hub.docker.com/gitea/gitea", + "rating": "βΆπŸ’š", + "source": "upstream" + }, + "healthcheck": "Yes", + "backups": "No", + "email": "?", + "tests": "β·πŸ’›" + }, + "versions": [ + { + "app": { + "image": "gitea/gitea:1.13.6", + "tag": "1.13.6", + "digest": "1d90f984" + } + }, + { + "db": { + "image": "mariadb:10.5", + "tag": "1.13.6", + "digest": "ab7c906b" + } + } + ] + } +} \ No newline at end of file