Skip to content

Commit 76632c4

Browse files
Merge pull request #352 from openshift-bot/synchronize-upstream
NO-ISSUE: Synchronize From Upstream Repositories
2 parents 2edc96f + 7ce9437 commit 76632c4

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

commitchecker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
expectedMergeBase: 9a61b22dae69077a39ad844057bccab6fc54d421
1+
expectedMergeBase: f5dc9a98ae9939e9706b813fa1b45faf74688d2b
22
upstreamBranch: main
33
upstreamOrg: operator-framework
44
upstreamRepo: operator-controller

internal/operator-controller/rukpak/convert/helm.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,22 @@ func (r *BundleToHelmChartConverter) ToHelmChart(bundle source.BundleSource, ins
5757
return nil, err
5858
}
5959
hash := sha256.Sum256(jsonData)
60-
chrt.Templates = append(chrt.Templates, &chart.File{
61-
Name: fmt.Sprintf("object-%x.json", hash[0:8]),
60+
name := fmt.Sprintf("object-%x.json", hash[0:8])
61+
62+
// Some registry+v1 manifests may actually contain Go Template strings
63+
// that are meant to survive and actually persist into etcd (e.g. to be
64+
// used as a templated configuration for another component). In order to
65+
// avoid applying templating logic to registry+v1's static manifests, we
66+
// create the manifests as Files, and then template those files via simple
67+
// Templates.
68+
chrt.Files = append(chrt.Files, &chart.File{
69+
Name: name,
6270
Data: jsonData,
6371
})
72+
chrt.Templates = append(chrt.Templates, &chart.File{
73+
Name: name,
74+
Data: []byte(fmt.Sprintf(`{{.Files.Get "%s"}}`, name)),
75+
})
6476
}
6577

6678
return chrt, nil

test/e2e/cluster_extension_install_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,12 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
377377
assert.NotEmpty(ct, clusterExtension.Status.Install.Bundle)
378378
}
379379
}, pollDuration, pollInterval)
380+
381+
t.Log("By verifying that no templating occurs for registry+v1 bundle manifests")
382+
cm := corev1.ConfigMap{}
383+
require.NoError(t, c.Get(context.Background(), types.NamespacedName{Namespace: ns.Name, Name: "test-configmap"}, &cm))
384+
require.Contains(t, cm.Annotations, "shouldNotTemplate")
385+
require.Contains(t, cm.Annotations["shouldNotTemplate"], "{{ $labels.namespace }}")
380386
})
381387
}
382388
}

testdata/images/bundles/test-operator/v1.0.0/manifests/bundle.configmap.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ apiVersion: v1
22
kind: ConfigMap
33
metadata:
44
name: test-configmap
5+
annotations:
6+
shouldNotTemplate: >
7+
The namespace is {{ $labels.namespace }}. The templated
8+
$labels.namespace is NOT expected to be processed by OLM's
9+
rendering engine for registry+v1 bundles.
510
data:
611
version: "v1.0.0"
712
name: "test-configmap"

0 commit comments

Comments
 (0)