Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/_default/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ version: latest
url_latest_version: https://projectcapsule.dev
archived_version: false
versions:
- version: v0.12
url: https://release-0-12.projectcapsule.dev
- version: v0.11
url: https://release-0-11.projectcapsule.dev
- version: v0.10
Expand Down
10 changes: 5 additions & 5 deletions content/en/docs/operating/setup/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ Perform the following steps to install the capsule Operator:

2. Install Capsule:

helm install capsule projectcapsule/capsule --version 0.10.6 -n capsule-system --create-namespace
helm install capsule projectcapsule/capsule --version {{< capsule_chart_version >}} -n capsule-system --create-namespace

or (**OCI**)

helm install capsule oci://ghcr.io/projectcapsule/charts/capsule --version 0.10.6 -n capsule-system --create-namespace
helm install capsule oci://ghcr.io/projectcapsule/charts/capsule --version {{< capsule_chart_version >}} -n capsule-system --create-namespace

3. Show the status:

Expand All @@ -47,7 +47,7 @@ Perform the following steps to install the capsule Operator:

or (**OCI**)

helm upgrade capsule oci://ghcr.io/projectcapsule/charts/capsule --version 0.10.7
helm upgrade capsule oci://ghcr.io/projectcapsule/charts/capsule --version {{< capsule_chart_version >}}

5. Uninstall the Chart

Expand Down Expand Up @@ -163,7 +163,7 @@ spec:
project: system
source:
repoURL: ghcr.io/projectcapsule/charts
targetRevision: 0.11.0
targetRevision: {{< capsule_chart_version >}}
chart: capsule
helm:
valuesObject:
Expand Down Expand Up @@ -260,7 +260,7 @@ spec:
chart:
spec:
chart: capsule
version: "0.11.0"
version: "{{< capsule_chart_version >}}"
sourceRef:
kind: HelmRepository
name: capsule
Expand Down
55 changes: 55 additions & 0 deletions layouts/partials/capsule/chart-version.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{- /* Returns the Capsule Helm chart version to use in examples.

Logic:
- If .Site.Params.version is "latest" or empty, pick the latest chart
version from the Helm repo index.
- Otherwise, treat .Site.Params.version as a minor series like "v0.11"
or "0.11" and pick the newest chart version whose version starts with
that minor (for example "0.11.2").
- If anything goes wrong, fall back to the latest chart version.
*/ -}}

{{- $scratch := newScratch -}}
{{- $scratch.Set "chartVersion" "" -}}

{{- $helmIndexURL := "https://projectcapsule.github.io/charts/index.yaml" -}}
{{- $remote := resources.GetRemote $helmIndexURL -}}

{{- if $remote.Err -}}
{{- /* Remote fetch failed; we can't do better than a placeholder. */ -}}
{{- "latest" -}}
{{- else -}}
{{- $data := $remote | transform.Unmarshal -}}
{{- $entries := index $data "entries" -}}
{{- $capsuleCharts := index $entries "capsule" -}}

{{- if not (isset .Site.Params "version") -}}
{{- $scratch.Set "chartVersion" (index (index $capsuleCharts 0) "version") -}}
{{- else -}}
{{- $docVersion := .Site.Params.version | default "latest" -}}
{{- if or (eq $docVersion "") (eq $docVersion "latest") -}}
{{- /* Latest docs: just use the newest chart version. */ -}}
{{- $scratch.Set "chartVersion" (index (index $capsuleCharts 0) "version") -}}
{{- else -}}
{{- /* Archived docs: map docs version (for example "v0.11") to the
newest chart version in that minor series (for example 0.11.2).
*/ -}}
{{- $minor := replaceRE "^v" "" $docVersion -}}
{{- $prefix := printf "%s." $minor -}}

{{- range $capsuleCharts -}}
{{- $current := $.Scratch.Get "chartVersion" -}}
{{- if and (eq $current "") (or (hasPrefix .version $prefix) (eq .version $minor)) -}}
{{- $.Scratch.Set "chartVersion" .version -}}
{{- end -}}
{{- end -}}

{{- /* Fallback for unexpected version strings: use latest. */ -}}
{{- if eq ($scratch.Get "chartVersion") "" -}}
{{- $scratch.Set "chartVersion" (index (index $capsuleCharts 0) "version") -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- $scratch.Get "chartVersion" -}}
{{- end -}}
3 changes: 3 additions & 0 deletions layouts/shortcodes/capsule_chart_version.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- /* Renders the Capsule Helm chart version chosen by the
capsule/chart-version.html partial as plain text. */ -}}
{{- partial "capsule/chart-version.html" . -}}
Loading