Add skeleton for ArtifactDeploymentService

This commit is contained in:
bom 2023-08-04 11:48:16 +02:00
parent c02440ac65
commit f3bf8cb335

View file

@ -1,15 +1,27 @@
from ..infrastructure import GitApi
from ..infrastructure import GitApi, ArtifactDeploymentApi
from ..domain import Credentials
class ArtifactDeploymentService:
def __init__(self, git_api: GitApi):
def __init__(self, git_api: GitApi, artifact_deployment_api: ArtifactDeploymentApi):
self.git_api = git_api
self.artifact_deployment_api = artifact_deployment_api
@classmethod
def prod(cls):
return cls(
GitApi(),
ArtifactDeploymentApi(),
)
# def __get_base_artifact_release_url(self, base_url: str, organization: str, name: str) -> str:
# return f"{base_url}/{organization}/{name}/releases"
def __get_base_artifact_release_url(self, base_url: str, organization: str, name: str) -> str:
return f"{base_url}/{organization}/{name}/releases"
def post_release(self, target_url: str, tag: str, credentials: Credentials):
response = self.artifact_deployment_api.post_release(target_url, tag, credentials.mappings["token"])
# Get release id from response
def post_asset(self, target_url: str, release_id: str, attachment: str, attachment_type: str, token: str):
self.artifact_deployment_api.post_asset(target_url, release_id, attachment, attachment_type, token)
def calculate_checksums(self, build_path: str):
self.artifact_deployment_api.calculate_checksums(build_path)