diff --git a/config/_default/params.yaml b/config/_default/params.yaml index 624ecfb..28bf352 100644 --- a/config/_default/params.yaml +++ b/config/_default/params.yaml @@ -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 diff --git a/content/en/docs/operating/setup/installation.md b/content/en/docs/operating/setup/installation.md index fbfa6f7..2cc1816 100644 --- a/content/en/docs/operating/setup/installation.md +++ b/content/en/docs/operating/setup/installation.md @@ -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: @@ -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 @@ -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: @@ -260,7 +260,7 @@ spec: chart: spec: chart: capsule - version: "0.11.0" + version: "{{< capsule_chart_version >}}" sourceRef: kind: HelmRepository name: capsule diff --git a/layouts/partials/capsule/chart-version.html b/layouts/partials/capsule/chart-version.html new file mode 100644 index 0000000..2c4b9db --- /dev/null +++ b/layouts/partials/capsule/chart-version.html @@ -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 -}} diff --git a/layouts/shortcodes/capsule_chart_version.html b/layouts/shortcodes/capsule_chart_version.html new file mode 100644 index 0000000..b874e8f --- /dev/null +++ b/layouts/shortcodes/capsule_chart_version.html @@ -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" . -}}