[Skip-CI] Add initial artifact deployment domain object
This commit is contained in:
parent
911158f882
commit
0952ec57a8
1 changed files with 40 additions and 0 deletions
40
src/main/python/ddadevops/domain/artifact_deployment.py
Normal file
40
src/main/python/ddadevops/domain/artifact_deployment.py
Normal 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",
|
||||
}
|
||||
]
|
Loading…
Reference in a new issue