From 0952ec57a87c07bbeade33cc43dd1fad816c74a1 Mon Sep 17 00:00:00 2001 From: erik Date: Fri, 4 Aug 2023 12:09:09 +0200 Subject: [PATCH] [Skip-CI] Add initial artifact deployment domain object --- .../ddadevops/domain/artifact_deployment.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/python/ddadevops/domain/artifact_deployment.py 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", + } + ]