[Skip-CI] Add initial artifact deployment domain object

This commit is contained in:
erik 2023-08-04 12:09:09 +02:00
parent 911158f882
commit 0952ec57a8

View file

@ -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",
}
]