← All recipes
Moderne licensed

Change Helm chart version

Recipe IDorg.openrewrite.kubernetes.helm.ChangeChartVersionArtifactorg.openrewrite.recipe:rewrite-kubernetes

Propagate a Helm chart version across every file that restates it: the chart's own Chart.yaml, the dependencies of the charts that consume it, Flux HelmRelease resources, k0rdent ClusterTemplate, ProviderTemplate and ServiceTemplate resources, and optionally files whose name encodes the version. dependencies[].version is a range, so by default a range that the new version already satisfies is left alone rather than pinned. Chart.lock is never edited, because its digest cannot be recomputed here; it is reported instead. Files under a chart's templates directory are Go template text and are left alone. A k0rdent template's metadata.name also encodes the chart version, but a name is an identity that ClusterDeployment, Release and *TemplateChain resources point at. Renaming it here would leave those references dangling, so this recipe changes only version fields; org.openrewrite.kubernetes.k0rdent.ChangeTemplateVersion moves the name and everything that references it together.

Single recipeProprietary

Usage

You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.kubernetes.helm.ChangeChartVersion --recipe-option "chartName=k0smotron" --recipe-option "newVersion=1.3.0"

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite.recipe:rewrite-kubernetes:RELEASE

Options

NameTypeDescription
chartNamerequiredStringThe name of the chart whose version is changing, as it is written in its Chart.yaml and in the dependencies of the charts that consume it.
e.g. k0smotron
oldVersionStringThe version being replaced. When omitted, the version the chart's own Chart.yaml currently declares is used, which is only knowable for a chart that lives in this repository.
e.g. 1.2.0
newVersionrequiredStringThe new chart version. Must be an exact semantic version.
e.g. 1.3.0
newAppVersionStringThe new appVersion for the chart. A chart's appVersion names the application it packages, which usually moves independently of the chart version, so it is left alone unless this is set.
e.g. v1.3.0
matchModeMatchModeHow to treat the range-valued version fields, dependencies[].version in a Chart.yaml and spec.chart.spec.version in a Flux HelmRelease. The exact-valued fields, a chart's own version and appVersion, are always set exactly. Default is Widen.
renameFilesMatchingStringA glob expression selecting files whose name encodes the version. Matching files are renamed, substituting the new version for the old in either 1.2.3 or 1-2-3 spelling. When omitted, nothing is renamed.
e.g. **/files/release/*.yaml

Data tables

Structured output this recipe can produce.

  • Helm chart version changesEvery place a chart version was propagated to, plus the places that were deliberately left alone.org.openrewrite.kubernetes.table.HelmChartVersionChanges
  • Source files that had resultsSource files that were modified by the recipe run.org.openrewrite.table.SourcesFileResults
  • Source files that had search resultsSearch results that were found during the recipe run.org.openrewrite.table.SearchResults
  • Source files that errored on a recipeThe details of all errors produced by a recipe run.org.openrewrite.table.SourcesFileErrors
  • Recipe performanceStatistics used in analyzing the performance of recipes.org.openrewrite.table.RecipeRunStats