@@ -20,6 +20,11 @@ import (
2020 "k8s.io/klog/v2"
2121)
2222
23+ // catalogVersionSentinel is a placeholder value that openshift.yaml sets for
24+ // options.openshift.catalogs.version to indicate the catalog tag should be
25+ // resolved dynamically from the running cluster's OCP major.minor version.
26+ const catalogVersionSentinel = "ocp-release"
27+
2328// Expected path structure:
2429// ${assets}/helm/${subDir}/olmv1/ = chart
2530// ${assets}/helm/${subDir}/openshift.yaml = primary values file
@@ -80,6 +85,11 @@ func (b *Builder) renderHelmTemplate(helmPath, manifestDir string) error {
8085 if err := values .SetStringValue ("options.operatorController.deployment.image" , os .Getenv ("OPERATOR_CONTROLLER_IMAGE" )); err != nil {
8186 return fmt .Errorf ("error setting OPERATOR_CONTROLLER_IMAGE: %w" , err )
8287 }
88+ // When openshift.yaml sets options.openshift.catalogs.version to catalogVersionSentinel,
89+ // replace it with the tag derived from the running cluster's OCP major.minor version.
90+ if err := applyCatalogImageTagOverride (values , b .ClusterCatalogImageTag ); err != nil {
91+ return fmt .Errorf ("error setting catalog image tag: %w" , err )
92+ }
8393
8494 // On HighlyAvailable topologies scale to 2 replicas and enable the PDB so that rolling
8595 // updates never leave zero running pods. On SingleReplica (SNO) / External topologies
@@ -222,6 +232,21 @@ type DocumentInfo struct {
222232 Order int
223233}
224234
235+ // applyCatalogImageTagOverride replaces options.openshift.catalogs.version in the
236+ // Helm values when it equals catalogVersionSentinel, substituting the tag derived
237+ // from the running cluster's OCP major.minor version. It is a no-op when clusterTag
238+ // is empty or when the current value is not catalogVersionSentinel.
239+ func applyCatalogImageTagOverride (values * helmvalues.HelmValues , clusterTag string ) error {
240+ if clusterTag == "" {
241+ return nil
242+ }
243+ currentTag , found := values .GetStringValue ("options.openshift.catalogs.version" )
244+ if ! found || currentTag != catalogVersionSentinel {
245+ return nil
246+ }
247+ return values .SetStringValue ("options.openshift.catalogs.version" , clusterTag )
248+ }
249+
225250func splitYAMLDocuments (content string ) []string {
226251 // Split by document separators but preserve the original text
227252 lines := strings .Split (content , "\n " )
0 commit comments