-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·51 lines (36 loc) · 1.33 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import logging
import os
from dxf import DXF
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format="%(message)s")
registry_host = os.environ["REGISTRY_HOST"]
registry_insecure = "REGISTRY_INSECURE" in os.environ
registry_user = os.environ.get("REGISTRY_USER")
registry_password = os.environ.get("REGISTRY_PASSWORD")
logger.info("{0} Parameters {0}".format("*" * 5))
logger.info("host: {0}".format(registry_host))
logger.info("user: {0}".format(registry_user))
def _auth(dxf, response) -> None:
dxf.authenticate(registry_user, registry_password, response=response)
def _create_dxf(repository_name: str) -> DXF:
return DXF(
registry_host,
repository_name,
auth=_auth if registry_user and registry_password else None,
insecure=registry_insecure,
)
def _print_info() -> None:
root_dxf = _create_dxf("")
logger.info("{0} REGISTRY_INFO {0}".format("*" * 5))
for repo in root_dxf.list_repos():
logger.info("{0} {1} {0}".format("*" * 2, repo))
dxf = _create_dxf(repo)
try:
aliases = sorted(dxf.list_aliases(), reverse=True)
except TypeError:
pass
else:
for alias in sorted(aliases, reverse=True):
logger.info("- {0}".format(alias))
if __name__ == "__main__":
_print_info()