Support logging in via Skopeo

See coop-cloud/auto-apps-json#1.
This commit is contained in:
decentral1se 2021-06-17 21:40:58 +02:00
parent e8510c8aeb
commit 7482362af1
Signed by untrusted user who does not match committer: decentral1se
GPG Key ID: 92DAD76BD9567B8A

View File

@ -8,7 +8,7 @@
import argparse
from json import dump
from os import chdir, getcwd, listdir
from os import chdir, environ, getcwd, listdir
from os.path import basename
from pathlib import Path
from re import findall, search
@ -31,6 +31,21 @@ parser = argparse.ArgumentParser(description="Generate a new apps.json")
parser.add_argument("--output", type=Path, default=f"{getcwd()}/apps.json")
def skopeo_login():
"""Log into the docker registry to avoid rate limits."""
user = environ.get("SKOPEO_USER")
password = environ.get("SKOPEO_PASSWORD")
registry = environ.get("SKOPEO_REGISTRY", "docker.io")
if not user or not password:
log.info("Failed to log in via Skopeo due to missing env vars")
return
login_cmd = f"skopeo login {registry} -u {user} -p {password}"
output = _run_cmd(login_cmd, shell=True)
log.info(f"Skopeo login attempt: {output}")
def get_published_apps_json():
"""Retrieve already published apps json."""
url = "https://apps.coopcloud.tech"
@ -202,6 +217,8 @@ def main():
"""Run the script."""
args = parser.parse_args()
skopeo_login()
repos_json = get_repos_json()
clone_all_apps(repos_json)