diff --git a/src/main/python/ddadevops/domain/artifact_deployment.py b/src/main/python/ddadevops/domain/artifact_deployment.py new file mode 100644 index 0000000..64905cc --- /dev/null +++ b/src/main/python/ddadevops/domain/artifact_deployment.py @@ -0,0 +1,40 @@ +from typing import List, Dict, Optional +from .common import ( + Validateable, + CredentialMappingDefault, + DnsRecord, + Devops, +) + + +class ArtifactDeployment(Validateable, CredentialMappingDefault): + def __init__(self, inp: dict): + self.name = inp.get("name") + self.artifact_base_url = inp.get("artifact_base_url") + self.organization = inp.get("organization") + + def get_artifact_release_url(self) -> str: + return f"{self.artifact_base_url}/{self.organization}/{self.name}/releases" + + def get_artifact_asset_url(self, release_id: str) -> str: + return f"{self.get_artifact_release_url}/{release_id}/assets" + + def update_runtime_config(self, dns_record: DnsRecord): + self.dns_record = dns_record + self.throw_if_invalid() + + def validate(self) -> List[str]: + result = [] + result += self.__validate_is_not_empty__("name") + result += self.__validate_is_not_empty__("artifact_base_url") + return result + + @classmethod + def get_mapping_default(cls) -> List[Dict[str, str]]: + return [ # ToDo: Adapt for token + { + "gopass_path": "server/meissa/grafana-cloud", + "gopass_field": "grafana-cloud-user", + "name": "c4k_grafana_cloud_user", + } + ]