|
|
@ -65,16 +65,12 @@ class ImageApi:
|
|
|
|
def dockerhub_login(self, username: str, password: str):
|
|
|
|
def dockerhub_login(self, username: str, password: str):
|
|
|
|
self.execution_api.execute_secure(
|
|
|
|
self.execution_api.execute_secure(
|
|
|
|
f"docker login --username {username} --password {password}",
|
|
|
|
f"docker login --username {username} --password {password}",
|
|
|
|
"docker login --username ***** --password *****"
|
|
|
|
"docker login --username ***** --password *****",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def dockerhub_publish(self, name: str, username: str, tag: str):
|
|
|
|
def dockerhub_publish(self, name: str, username: str, tag: str):
|
|
|
|
self.execution_api.execute_live(
|
|
|
|
self.execution_api.execute_live(f"docker tag {name} {username}/{name}:{tag}")
|
|
|
|
f"docker tag {name} {username}/{name}:{tag}"
|
|
|
|
self.execution_api.execute_live(f"docker push {username}/{name}:{tag}")
|
|
|
|
)
|
|
|
|
|
|
|
|
self.execution_api.execute_live(
|
|
|
|
|
|
|
|
f"docker push {username}/{name}:{tag}"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test(self, name: str, path: Path):
|
|
|
|
def test(self, name: str, path: Path):
|
|
|
|
self.execution_api.execute_live(
|
|
|
|
self.execution_api.execute_live(
|
|
|
@ -95,14 +91,24 @@ class ExecutionApi:
|
|
|
|
check=check,
|
|
|
|
check=check,
|
|
|
|
stdout=PIPE,
|
|
|
|
stdout=PIPE,
|
|
|
|
stderr=PIPE,
|
|
|
|
stderr=PIPE,
|
|
|
|
text=True).stdout
|
|
|
|
text=True,
|
|
|
|
|
|
|
|
).stdout
|
|
|
|
output = output.rstrip()
|
|
|
|
output = output.rstrip()
|
|
|
|
except CalledProcessError as exc:
|
|
|
|
except CalledProcessError as exc:
|
|
|
|
print(f"Command failed with code: {exc.returncode} and message: {exc.stderr}")
|
|
|
|
print(
|
|
|
|
|
|
|
|
f"Command failed with code: {exc.returncode} and message: {exc.stderr}"
|
|
|
|
|
|
|
|
)
|
|
|
|
raise exc
|
|
|
|
raise exc
|
|
|
|
return output
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
def execute_secure(self, command: str, sanitized_command: str, dry_run=False, shell=True, check=True):
|
|
|
|
def execute_secure(
|
|
|
|
|
|
|
|
self,
|
|
|
|
|
|
|
|
command: str,
|
|
|
|
|
|
|
|
sanitized_command: str,
|
|
|
|
|
|
|
|
dry_run=False,
|
|
|
|
|
|
|
|
shell=True,
|
|
|
|
|
|
|
|
check=True,
|
|
|
|
|
|
|
|
):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
output = self.execute(command, dry_run, shell, check)
|
|
|
|
output = self.execute(command, dry_run, shell, check)
|
|
|
|
return output
|
|
|
|
return output
|
|
|
@ -213,25 +219,40 @@ class ArtifactDeploymentApi:
|
|
|
|
self.execution_api = ExecutionApi()
|
|
|
|
self.execution_api = ExecutionApi()
|
|
|
|
|
|
|
|
|
|
|
|
def create_forgejo_release(self, target_url: str, tag: str, token: str):
|
|
|
|
def create_forgejo_release(self, target_url: str, tag: str, token: str):
|
|
|
|
return self.execution_api.execute_secure(f'curl -X "POST" "{target_url}" '
|
|
|
|
return self.execution_api.execute_secure(
|
|
|
|
+ '-H "accept: application/json" -H "Content-Type: application/json" '
|
|
|
|
f'curl -X "POST" "{target_url}" '
|
|
|
|
+ f'-d "{{ "body": "Provides files for release {tag} Attention: The "Source Code"-files below are not up-to-date!", "tag_name": "{tag}"}}" ' # noqa: E501
|
|
|
|
+ '-H "accept: application/json" -H "Content-Type: application/json" '
|
|
|
|
+ f'-H "Authorization: token {token}"',
|
|
|
|
+ f'-d "{{ "body": "Provides files for release {tag} Attention: The "Source Code"-files below are not up-to-date!", "tag_name": "{tag}"}}" ' # noqa: E501
|
|
|
|
sanitized_command=f'curl -X "POST" "{target_url}" '
|
|
|
|
+ f'-H "Authorization: token {token}"',
|
|
|
|
+ '-H "accept: application/json" -H "Content-Type: application/json" '
|
|
|
|
sanitized_command=f'curl -X "POST" "{target_url}" '
|
|
|
|
+ f'-d "{{ "body": "Provides files for release {tag} Attention: The "Source Code"-files below are not up-to-date!", "tag_name": "{tag}"}}" ') # noqa: E501
|
|
|
|
+ '-H "accept: application/json" -H "Content-Type: application/json" '
|
|
|
|
|
|
|
|
+ f'-d "{{ "body": "Provides files for release {tag} Attention: The "Source Code"-files below are not up-to-date!", "tag_name": "{tag}"}}" ',
|
|
|
|
def post_asset(self, target_url: str, release_id: str, attachment: str, attachment_type: str, token: str):
|
|
|
|
) # noqa: E501
|
|
|
|
return self.execution_api.execute_secure(f'curl -X "POST" "{target_url}/{release_id}/assets" ' # {target_url}/{release_id}/assets move to Domain
|
|
|
|
|
|
|
|
+ f'-H "accept: application/json" -H "Authorization: token {token}" '
|
|
|
|
def post_asset(
|
|
|
|
+ '-H "Content-Type: multipart/form-data" '
|
|
|
|
self,
|
|
|
|
+ f'-F "attachment=@{attachment};type={attachment_type}"',
|
|
|
|
target_url: str,
|
|
|
|
sanitized_command=f'curl -X "POST" "{target_url}/{release_id}/assets" ' # see above
|
|
|
|
release_id: str,
|
|
|
|
+ '-H "accept: application/json" '
|
|
|
|
attachment: str,
|
|
|
|
+ '-H "Content-Type: multipart/form-data" '
|
|
|
|
attachment_type: str,
|
|
|
|
+ f'-F "attachment=@{attachment};type={attachment_type}"')
|
|
|
|
token: str,
|
|
|
|
|
|
|
|
):
|
|
|
|
|
|
|
|
return self.execution_api.execute_secure(
|
|
|
|
|
|
|
|
f'curl -X "POST" "{target_url}/{release_id}/assets" ' # {target_url}/{release_id}/assets move to Domain
|
|
|
|
|
|
|
|
+ f'-H "accept: application/json" -H "Authorization: token {token}" '
|
|
|
|
|
|
|
|
+ '-H "Content-Type: multipart/form-data" '
|
|
|
|
|
|
|
|
+ f'-F "attachment=@{attachment};type={attachment_type}"',
|
|
|
|
|
|
|
|
sanitized_command=f'curl -X "POST" "{target_url}/{release_id}/assets" ' # see above
|
|
|
|
|
|
|
|
+ '-H "accept: application/json" '
|
|
|
|
|
|
|
|
+ '-H "Content-Type: multipart/form-data" '
|
|
|
|
|
|
|
|
+ f'-F "attachment=@{attachment};type={attachment_type}"',
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def calculate_checksums(self, artifact_path: str):
|
|
|
|
def calculate_checksums(self, artifact_path: str):
|
|
|
|
# self.execution_api.execute(f"find {artifact_path} -type f -exec sha256sum {{}}; | sort > {artifact_path} sha256sum.lst") relevant für provs
|
|
|
|
# self.execution_api.execute(f"find {artifact_path} -type f -exec sha256sum {{}}; | sort > {artifact_path} sha256sum.lst") relevant für provs
|
|
|
|
self.execution_api(f"sha256sum {artifact_path} > {artifact_path}.sha256",)
|
|
|
|
self.execution_api(
|
|
|
|
self.execution_api(f"sha512sum {artifact_path} > {artifact_path}.sha512",)
|
|
|
|
f"sha256sum {artifact_path} > {artifact_path}.sha256",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
self.execution_api(
|
|
|
|
|
|
|
|
f"sha512sum {artifact_path} > {artifact_path}.sha512",
|
|
|
|
|
|
|
|
)
|
|
|
|