11package convert
22
33import (
4+ "fmt"
45 "testing"
56
67 . "github.com/onsi/ginkgo/v2"
@@ -16,6 +17,7 @@ import (
1617 "sigs.k8s.io/controller-runtime/pkg/client"
1718
1819 "github.com/operator-framework/api/pkg/operators/v1alpha1"
20+ "github.com/operator-framework/operator-registry/alpha/property"
1921)
2022
2123func TestRegistryV1Converter (t * testing.T ) {
@@ -173,6 +175,9 @@ var _ = Describe("RegistryV1 Suite", func() {
173175 csv = v1alpha1.ClusterServiceVersion {
174176 ObjectMeta : metav1.ObjectMeta {
175177 Name : "testCSV" ,
178+ Annotations : map [string ]string {
179+ "olm.properties" : fmt .Sprintf ("[{\" type\" : %s, \" value\" : \" %s\" }]" , property .TypeConstraint , "value" ),
180+ },
176181 },
177182 Spec : v1alpha1.ClusterServiceVersionSpec {
178183 InstallModes : []v1alpha1.InstallMode {{Type : v1alpha1 .InstallModeTypeMultiNamespace , Supported : true }},
@@ -380,6 +385,22 @@ var _ = Describe("RegistryV1 Suite", func() {
380385 Expect (err ).To (HaveOccurred ())
381386 Expect (plainBundle ).To (BeNil ())
382387 })
388+
389+ It ("should propagate csv annotations to chart metadata annotation" , func () {
390+ By ("creating a registry v1 bundle" )
391+ watchNamespaces = []string {"testWatchNs1" , "testWatchNs2" }
392+ unstructuredSvc := convertToUnstructured (svc )
393+ registryv1Bundle = RegistryV1 {
394+ PackageName : "testPkg" ,
395+ CSV : csv ,
396+ Others : []unstructured.Unstructured {unstructuredSvc },
397+ }
398+
399+ By ("converting to helm" )
400+ chrt , err := toChart (registryv1Bundle , installNamespace , watchNamespaces )
401+ Expect (err ).NotTo (HaveOccurred ())
402+ Expect (chrt .Metadata .Annotations ["olm.properties" ]).NotTo (BeNil ())
403+ })
383404 })
384405
385406 Context ("Should enforce limitations" , func () {
0 commit comments