From f4be6e0c8ba9fd39d18610b213913d9fa7306703 Mon Sep 17 00:00:00 2001 From: erik Date: Fri, 11 Aug 2023 15:26:59 +0200 Subject: [PATCH] Implement calculation of forgejo release api endpoint url --- .../python/ddadevops/application/release_mixin_services.py | 2 +- src/main/python/ddadevops/domain/release.py | 6 +++++- src/test/python/domain/test_release.py | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/python/ddadevops/application/release_mixin_services.py b/src/main/python/ddadevops/application/release_mixin_services.py index b15f260..19e167e 100644 --- a/src/main/python/ddadevops/application/release_mixin_services.py +++ b/src/main/python/ddadevops/application/release_mixin_services.py @@ -63,7 +63,7 @@ class ReleaseService: def publish_artifacts(self, release: Release): for artifact_path in release.release_artifacts: self.artifact_deployment_api.calculate_checksums(artifact_path) - self.artifact_deployment_api.post_release(release) # create release + self.artifact_deployment_api.create_forgejo_release(release.forgejo_release_api_endpoint) # create release # add artifacts to release pass diff --git a/src/main/python/ddadevops/domain/release.py b/src/main/python/ddadevops/domain/release.py index b8c64ec..7679ff8 100644 --- a/src/main/python/ddadevops/domain/release.py +++ b/src/main/python/ddadevops/domain/release.py @@ -70,4 +70,8 @@ class Release(Validateable): def forgejo_release_api_endpoint(self): if self.release_artifact_server_url == None or self.release_organisation == None or self.release_repository_name == None: raise RuntimeError("when doing artifact release, release_artifact_server_url, release_organisation, release_repository_name may not be None.") - return f"{self.release_artifact_server_url}/api/v1/repos/{self.release_organisation}/{self.release_repository_name}/releases" + + server_url = self.release_artifact_server_url.removeprefix("/").removesuffix("/") + organisation = self.release_organisation.removeprefix("/").removesuffix("/") + repository = self.release_repository_name.removeprefix("/").removesuffix("/") + return f"{server_url}/api/v1/repos/{organisation}/{repository}/releases" diff --git a/src/test/python/domain/test_release.py b/src/test/python/domain/test_release.py index 48b520a..ffd1ffb 100644 --- a/src/test/python/domain/test_release.py +++ b/src/test/python/domain/test_release.py @@ -94,6 +94,10 @@ def test_should_calculate_forgejo_release_api_endpoint(): "https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases" == sut.forgejo_release_api_endpoint() ) + assert( + "/meissa/" + == sut.release_organisation + ) with pytest.raises(Exception): sut = Release(