Compare commits
No commits in common. "d555b34eef9fa352925ab2fd77e2edd821e8b81a" and "45884d10322531ad07b190d062594f98d05ee2ff" have entirely different histories.
d555b34eef
...
45884d1032
5 changed files with 132 additions and 8 deletions
|
@ -88,14 +88,10 @@ classDiagram
|
||||||
release_type
|
release_type
|
||||||
release_main_branch
|
release_main_branch
|
||||||
release_current_branch
|
release_current_branch
|
||||||
|
release_artifacts
|
||||||
release_artifact_server_url
|
release_artifact_server_url
|
||||||
release_organisation
|
release_organisation
|
||||||
release_repository_name
|
release_repository_name
|
||||||
release_artifact_token
|
|
||||||
}
|
|
||||||
class Artifact {
|
|
||||||
release_artifact_path
|
|
||||||
release_artifact_type
|
|
||||||
}
|
}
|
||||||
class Credentials {
|
class Credentials {
|
||||||
<<AggregateRoot>>
|
<<AggregateRoot>>
|
||||||
|
@ -138,7 +134,6 @@ classDiagram
|
||||||
TerraformDomain *-- "0..1" ProviderAws: providers
|
TerraformDomain *-- "0..1" ProviderAws: providers
|
||||||
Release o-- "0..1" BuildFile: primary_build_file
|
Release o-- "0..1" BuildFile: primary_build_file
|
||||||
Release o-- "0..n" BuildFile: secondary_build_files
|
Release o-- "0..n" BuildFile: secondary_build_files
|
||||||
Release "1" *-- "0..n" Artifact: release_artifacts
|
|
||||||
Release "1" *-- "1" Version: version
|
Release "1" *-- "1" Version: version
|
||||||
BuildFile *-- "1" Version: version
|
BuildFile *-- "1" Version: version
|
||||||
C4k *-- DnsRecord: dns_record
|
C4k *-- DnsRecord: dns_record
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
from ..infrastructure import GitApi, ArtifactDeploymentApi
|
||||||
|
from ..domain import Credentials
|
||||||
|
|
||||||
|
# This will be moved to release mixin
|
||||||
|
class ArtifactDeploymentService:
|
||||||
|
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 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)
|
||||||
|
|
||||||
|
# ToDo: Update release Id as in release_mixin_services.py
|
|
@ -88,11 +88,12 @@ class ReleaseService:
|
||||||
"type": "text/plain",
|
"type": "text/plain",
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
# TODO: use structure created above
|
||||||
for artifact in artifacts_to_attach:
|
for artifact in artifacts_to_attach:
|
||||||
self.artifact_deployment_api.add_asset_to_release(
|
self.artifact_deployment_api.add_asset_to_release(
|
||||||
release.forgejo_release_asset_api_endpoint(release_id),
|
release.forgejo_release_asset_api_endpoint(release_id),
|
||||||
artifact["path"],
|
"todo",
|
||||||
artifact["type"],
|
"todo",
|
||||||
release.release_artifact_token,
|
release.release_artifact_token,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
61
src/main/python/ddadevops/artifact_deployment_mixin.py
Normal file
61
src/main/python/ddadevops/artifact_deployment_mixin.py
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
from pybuilder.core import Project
|
||||||
|
from .devops_build import DevopsBuild
|
||||||
|
from .domain import MixinType
|
||||||
|
|
||||||
|
# """
|
||||||
|
# Functional Req:
|
||||||
|
|
||||||
|
# General process for deploying prebuilt (meissa) binaries to our own repo server.
|
||||||
|
|
||||||
|
# [-1]
|
||||||
|
# Building is handled by other entities
|
||||||
|
# is another pybuilder task
|
||||||
|
# the binary is reachable with devops.build_path()
|
||||||
|
# we might need to establish a "build" that does lein builds for us
|
||||||
|
# we might need to establish a "build" that does gradlew build for us
|
||||||
|
# same for all other projects that produce binaries
|
||||||
|
# currently the c4k_build.py just creates the auth and config yamls
|
||||||
|
|
||||||
|
# [0]
|
||||||
|
# get artifact deployment url
|
||||||
|
# Base url: https://repo.prod.meissa.de/api/v1/repos/
|
||||||
|
# Changeable: /meissa/provs/
|
||||||
|
# persitent suffix to url: releases
|
||||||
|
# name is accessible from input
|
||||||
|
|
||||||
|
# [1]
|
||||||
|
# get release token
|
||||||
|
# could be an api token for repo.prod.meissa.de
|
||||||
|
# credential mapping as described in the docs
|
||||||
|
|
||||||
|
# [2]
|
||||||
|
# get release tag
|
||||||
|
# is the version of the project
|
||||||
|
# get from gitApi
|
||||||
|
|
||||||
|
# [3]
|
||||||
|
# post a json message containting [2] to [0], watching stdout for answers
|
||||||
|
# authorized by [1]
|
||||||
|
# validate if [3] was successful by reading stdout
|
||||||
|
# or create error message containing ID of release
|
||||||
|
|
||||||
|
# [4]
|
||||||
|
# get release-id from stdout of [3]
|
||||||
|
# print release-id
|
||||||
|
|
||||||
|
# [5]
|
||||||
|
# generate sha256 sums & generate sha512 sums of results of [-1]
|
||||||
|
|
||||||
|
# [6]
|
||||||
|
# push results of [-1] & [5] to [0]/[4]/assets
|
||||||
|
|
||||||
|
# """
|
||||||
|
|
||||||
|
# This will be moved to release mixin
|
||||||
|
class ArtifactDeploymentMixin(DevopsBuild):
|
||||||
|
def __init__(self, project: Project, inp: dict):
|
||||||
|
super().__init__(project, inp)
|
||||||
|
devops = self.devops_repo.get_devops(self.project)
|
||||||
|
if MixinType.ARTIFACT_DEPLOYMENT not in devops.mixins: # TODO: Check for Release mixin as well
|
||||||
|
raise ValueError("ArtifactDeploymentMixin requires MixinType.ARTIFACT_DEPLOYMENT")
|
||||||
|
self.base_url = 'https://repo.prod.meissa.de/api/v1/repos/'
|
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,
|
||||||
|
)
|
||||||
|
|
||||||
|
# This will be moved to release mixin
|
||||||
|
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