Implement calculation of forgejo release api endpoint url

This commit is contained in:
erik 2023-08-11 15:26:59 +02:00
parent 5f5743354c
commit f4be6e0c8b
3 changed files with 10 additions and 2 deletions

View file

@ -63,7 +63,7 @@ class ReleaseService:
def publish_artifacts(self, release: Release): def publish_artifacts(self, release: Release):
for artifact_path in release.release_artifacts: for artifact_path in release.release_artifacts:
self.artifact_deployment_api.calculate_checksums(artifact_path) 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 # add artifacts to release
pass pass

View file

@ -70,4 +70,8 @@ class Release(Validateable):
def forgejo_release_api_endpoint(self): def forgejo_release_api_endpoint(self):
if self.release_artifact_server_url == None or self.release_organisation == None or self.release_repository_name == None: 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.") 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"

View file

@ -94,6 +94,10 @@ def test_should_calculate_forgejo_release_api_endpoint():
"https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases" "https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases"
== sut.forgejo_release_api_endpoint() == sut.forgejo_release_api_endpoint()
) )
assert(
"/meissa/"
== sut.release_organisation
)
with pytest.raises(Exception): with pytest.raises(Exception):
sut = Release( sut = Release(