From 4961bec18d4134a01063b32d65ac77b20608032d Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Thu, 3 Sep 2026 16:39:15 +0200 Subject: [PATCH] fix: pin the Helm chart's image tag to the plugin version Before, each doc page hardcoded its own chart version. That is fragile: the chart is published after the plugin, so we can't know the right chart version yet when we write the docs. Now we set the image tag straight to the plugin version instead. The latest release skips this, since the chart already defaults to itself there. Signed-off-by: Marco Nenciarini --- web/src/components/HelmInstallation/index.tsx | 50 ++++++++++++------- .../version-0.13.0/installation.mdx | 2 +- .../version-0.14.0/installation.mdx | 2 +- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/web/src/components/HelmInstallation/index.tsx b/web/src/components/HelmInstallation/index.tsx index b105cc4..af5f79b 100644 --- a/web/src/components/HelmInstallation/index.tsx +++ b/web/src/components/HelmInstallation/index.tsx @@ -1,22 +1,36 @@ -import { ReactElement } from "react"; -import CodeBlock from "@theme/CodeBlock"; +import {ReactElement} from 'react'; +import CodeBlock from '@theme/CodeBlock'; +import {useActiveVersion, useLatestVersion} from '@docusaurus/plugin-content-docs/client'; -type HelmInstallationProps = { - chartVersion?: string; -}; - -// HelmInstallationSnippet is the Helm incantation to install a specific -// or latest available version of the Barman Cloud Plugin. -export function HelmInstallationSnippet({ - chartVersion, -}: HelmInstallationProps): ReactElement { - const versionArg = chartVersion ? `\n --version ${chartVersion} \\` : ""; - return ( - - {`helm repo add cnpg https://cloudnative-pg.github.io/charts --force-update +// HelmInstallationSnippet is the Helm command to install the plugin. +// +// - Latest release: no override. The chart already defaults to +// itself. +// - Older release: pin image.tag and sidecarImage.tag to that +// version. We check this again on every build using +// useLatestVersion, so an old page updates itself once a newer +// version ships. +// - Dev docs: also no override, but this does NOT install a dev +// build. Setting the tag alone would not be enough, since the +// chart's own templates (CRDs, RBAC...) can be older than what +// main needs. Use the kubectl method to test a dev build. +export function HelmInstallationSnippet(): ReactElement { + const activeVersion = useActiveVersion('default'); + const latestVersion = useLatestVersion('default'); + const isOlderRelease = activeVersion + && activeVersion.name !== 'current' + && activeVersion.name !== latestVersion.name; + const setArgs = isOlderRelease + ? ` \\ + --set image.tag=v${activeVersion.name} \\ + --set sidecarImage.tag=v${activeVersion.name}` + : ''; + return ( + + {`helm repo add cnpg https://cloudnative-pg.github.io/charts --force-update helm upgrade --install plugin-barman-cloud \\ - --namespace cnpg-system \\${versionArg} + --namespace cnpg-system${setArgs} \\ cnpg/plugin-barman-cloud`} - - ); + + ); } diff --git a/web/versioned_docs/version-0.13.0/installation.mdx b/web/versioned_docs/version-0.13.0/installation.mdx index 0781394..9df96d1 100644 --- a/web/versioned_docs/version-0.13.0/installation.mdx +++ b/web/versioned_docs/version-0.13.0/installation.mdx @@ -64,7 +64,7 @@ import { HelmInstallationSnippet } from '@site/src/components/HelmInstallation'; The plugin can be installed using the provided [Helm chart](https://github.com/cloudnative-pg/charts/tree/main/charts/plugin-barman-cloud): - + Example output: diff --git a/web/versioned_docs/version-0.14.0/installation.mdx b/web/versioned_docs/version-0.14.0/installation.mdx index 9af7804..a4cb684 100644 --- a/web/versioned_docs/version-0.14.0/installation.mdx +++ b/web/versioned_docs/version-0.14.0/installation.mdx @@ -64,7 +64,7 @@ import { HelmInstallationSnippet } from '@site/src/components/HelmInstallation'; The plugin can be installed using the provided [Helm chart](https://github.com/cloudnative-pg/charts/tree/main/charts/plugin-barman-cloud): - + Example output: