spcd/cd/projects.py

28 lines
708 B
Python
Raw Normal View History

2024-06-09 20:04:29 +02:00
from __future__ import annotations
2024-06-09 18:09:53 +02:00
from pathlib import Path
2024-04-27 16:14:03 +02:00
GROUP_AND_NAME = [
2024-06-08 23:56:21 +02:00
"GITHUB_REPOSITORY",
"CI_PROJECT_PATH",
2024-04-27 16:14:03 +02:00
]
SERVER_URL = [
2024-06-08 23:56:21 +02:00
"GITHUB_SERVER_URL",
"CI_SERVER_URL",
2024-04-27 16:14:03 +02:00
]
2024-04-27 15:32:33 +02:00
class Projects:
2024-06-09 20:04:29 +02:00
def __init__(self: Projects, environment) -> None:
2024-04-27 17:09:51 +02:00
self.environment = environment
2024-04-27 16:14:03 +02:00
# group, name
for variable in GROUP_AND_NAME:
2024-04-27 17:09:51 +02:00
if value := self.environment.get(variable, None):
2024-06-09 18:41:20 +02:00
path = Path(value)
self.group = path.parent
self.name = path.name
2024-04-27 16:14:03 +02:00
# url
for variable in SERVER_URL:
2024-04-27 17:09:51 +02:00
if value := self.environment.get(variable, None):
2024-06-09 18:09:53 +02:00
self.url = Path(value) / self.group