From 2df9ee42e62562eaa87ce50e0d885dcf6b38947f Mon Sep 17 00:00:00 2001 From: Til Blechschmidt Date: Fri, 14 Jan 2022 16:51:35 +0100 Subject: [PATCH] :bug: Fix subchart of demo chart not having correct version Also increases the Redis PVC size to prevent no space left errors :) --- .../demo/charts/webgrid/templates/redis.yaml | 2 +- docs/hooks.py | 25 +++++++++++++++++++ mkdocs.yml | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/distribution/kubernetes/demo/charts/webgrid/templates/redis.yaml b/distribution/kubernetes/demo/charts/webgrid/templates/redis.yaml index 7b62fe84..0a4e5059 100644 --- a/distribution/kubernetes/demo/charts/webgrid/templates/redis.yaml +++ b/distribution/kubernetes/demo/charts/webgrid/templates/redis.yaml @@ -13,7 +13,7 @@ spec: - ReadWriteOnce resources: requests: - storage: 100M + storage: 500M --- {{- end }} apiVersion: v1 diff --git a/docs/hooks.py b/docs/hooks.py index 9f6f5411..0d10fd79 100644 --- a/docs/hooks.py +++ b/docs/hooks.py @@ -1,6 +1,13 @@ import shutil import os +def on_pre_build(config): + # Make sure the chart version is set correctly + # This is necessary because the Helm package `--version` flag only changes the + # root chart version but not the subcharts. Thus we need to manually overwrite it! + print("Running pre-build hook!") + update_chart_version() + def on_post_build(*args, **kwargs): site_dir = kwargs['config']['site_dir'] @@ -28,3 +35,21 @@ def copy_docker_compose(site_dir): # Write the file out again with open(dst_file, 'w') as file: file.write(filedata) + +def update_chart_version(): + chart = "distribution/kubernetes/demo/charts/webgrid/Chart.yaml" + + # Read in the file + with open(chart, 'r') as file : + filedata = file.read() + + # Use the git ref in GitHub Actions + git_ref = os.getenv('GITHUB_REF') + if git_ref is not None and git_ref.startswith('refs/tags/'): + version = git_ref[10:] + filedata = filedata.replace('v0.0.0-tempversion', version) + print("Overwriting Helm subchart version with git tag '" + version + "'") + + # Write the file out again + with open(chart, 'w') as file: + file.write(filedata) diff --git a/mkdocs.yml b/mkdocs.yml index e4039fa8..1b5f5d1b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -94,6 +94,7 @@ plugins: helm_repo_url: https://webgrid.dev/ - mkdocs-simple-hooks: hooks: + on_pre_build: "docs.hooks:on_pre_build" on_post_build: "docs.hooks:on_post_build" extra_javascript: