add release-endpoint-calculation to domain object
This commit is contained in:
parent
a876fdc799
commit
caaf804fd3
2 changed files with 22 additions and 1 deletions
|
@ -77,7 +77,7 @@ class Release(Validateable):
|
||||||
result += self.release_secondary_build_files
|
result += self.release_secondary_build_files
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def forgejo_release_api_endpoint(self):
|
def forgejo_release_api_endpoint(self) -> str:
|
||||||
validation = self.validate_for_artifact()
|
validation = self.validate_for_artifact()
|
||||||
if validation != []:
|
if validation != []:
|
||||||
raise RuntimeError(f"not valid for creating artifacts: {validation}")
|
raise RuntimeError(f"not valid for creating artifacts: {validation}")
|
||||||
|
@ -89,6 +89,9 @@ class Release(Validateable):
|
||||||
repository = self.release_repository_name.removeprefix("/").removesuffix("/")
|
repository = self.release_repository_name.removeprefix("/").removesuffix("/")
|
||||||
return f"{server_url}/api/v1/repos/{organisation}/{repository}/releases"
|
return f"{server_url}/api/v1/repos/{organisation}/{repository}/releases"
|
||||||
|
|
||||||
|
def forgejo_release_asset_api_endpoint(self, id: int) -> str:
|
||||||
|
return f"{self.forgejo_release_api_endpoint()}/{id}/assets"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -115,3 +115,21 @@ def test_should_calculate_forgejo_release_api_endpoint():
|
||||||
Version.from_str("1.3.1-SNAPSHOT", "SNAPSHOT"),
|
Version.from_str("1.3.1-SNAPSHOT", "SNAPSHOT"),
|
||||||
)
|
)
|
||||||
sut.forgejo_release_api_endpoint()
|
sut.forgejo_release_api_endpoint()
|
||||||
|
|
||||||
|
def test_should_calculate_forgejo_release_asset_api_endpoint():
|
||||||
|
sut = Release(
|
||||||
|
devops_config(
|
||||||
|
{
|
||||||
|
"release_artifacts": ["x"],
|
||||||
|
"release_artifact_token": "y",
|
||||||
|
"release_artifact_server_url": "https://repo.prod.meissa.de",
|
||||||
|
"release_organisation": "meissa",
|
||||||
|
"release_repository_name": "provs",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
Version.from_str("1.3.1-SNAPSHOT", "SNAPSHOT"),
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
"https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases/123/assets"
|
||||||
|
== sut.forgejo_release_asset_api_endpoint(123)
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue