Skip to content

Commit

Permalink
Fix helm chart releaser download
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Sep 12, 2023
1 parent 2415171 commit f6708a0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions c2cciutils/applications-versions.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# https://docs.renovatebot.com/modules/datasource/#github-releases-datasource
k3d-io/k3d: v5.5.2 # github-releases
postgresql: 12.8.5 # helm - https://charts.bitnami.com/bitnami
helm/chart-releaser: v1.6.0 # github-releases
11 changes: 11 additions & 0 deletions c2cciutils/applications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@ k3d-io/k3d:
- k3d
- - k3d
- --version
helm/chart-releaser:
get-file-name: chart-releaser_{short_version}_linux_amd64.tar.gz
type: tar
tar-file-name: cr
to-file-name: cr
finish-commands:
- - chmod
- +x
- cr
- - cr
- version
6 changes: 4 additions & 2 deletions c2cciutils/scripts/download_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import urllib
from glob import glob
from io import BytesIO
from typing import cast
from typing import Optional, cast

import requests
import yaml
Expand Down Expand Up @@ -38,7 +38,7 @@ def main() -> None:
download_applications(applications, versions)


def download_c2cciutils_applications() -> None:
def download_c2cciutils_applications(name: Optional[str] = None) -> None:
"""Download the applications defined in the c2cciutils package."""
with open(
os.path.join(os.path.dirname(os.path.dirname(__file__)), "applications-versions.yaml"),
Expand All @@ -51,6 +51,8 @@ def download_c2cciutils_applications() -> None:
applications = cast(
applications_definition.ApplicationsConfiguration, yaml.load(config_file, Loader=yaml.SafeLoader)
)
if name is not None:
applications = {name: applications[name]}
download_applications(applications, versions)


Expand Down
2 changes: 1 addition & 1 deletion c2cciutils/scripts/k8s/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def main() -> None:
config = c2cciutils.get_config()

_print("::group::Install")
c2cciutils.scripts.download_applications.download_c2cciutils_applications()
c2cciutils.scripts.download_applications.download_c2cciutils_applications("k3d-io/k3d")
_print("::endgroup::")

_print("::group::Create cluster")
Expand Down
8 changes: 1 addition & 7 deletions c2cciutils/scripts/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import re
import subprocess # nosec
import sys
import tarfile
from re import Match
from typing import Optional, cast

Expand Down Expand Up @@ -396,12 +395,7 @@ def main() -> None:
config.get("publish", {}).get("helm", {}) if config.get("publish", {}).get("helm", False) else {},
)
if helm_config and helm_config["folders"] and version_type in helm_config.get("versions", []):
url = "https://github.com/helm/chart-releaser/releases/download/v1.2.1/chart-releaser_1.2.1_linux_amd64.tar.gz"
response = requests.get(url, stream=True, timeout=int(os.environ.get("C2CCIUTILS_TIMEOUT", "30")))
with tarfile.open(fileobj=response.raw, mode="r:gz") as file:
filename_re = re.compile(r"^[a-zA-Z0-9][a-zA-Z0-9._/-]*$")
members = [member for member in file.getmembers() if filename_re.match(member.name) is not None]
file.extractall(path=os.path.expanduser("~/.local/bin"), members=members) # nosec
c2cciutils.scripts.download_applications.download_c2cciutils_applications("helm/chart-releaser")

owner, repo = full_repo_split
commit_sha = (
Expand Down

0 comments on commit f6708a0

Please sign in to comment.