Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/rukpak/convert/registryv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,17 @@ func RegistryV1ToHelmChart(ctx context.Context, rv1 fs.FS, installNamespace stri
return nil, err
}

plain, err := Convert(reg, installNamespace, watchNamespaces)
return toChart(reg, installNamespace, watchNamespaces)
}

func toChart(in RegistryV1, installNamespace string, watchNamespaces []string) (*chart.Chart, error) {
plain, err := Convert(in, installNamespace, watchNamespaces)
if err != nil {
return nil, err
}

chrt := &chart.Chart{Metadata: &chart.Metadata{}}
chrt.Metadata.Annotations = in.CSV.GetAnnotations()
for _, obj := range plain.Objects {
jsonData, err := json.Marshal(obj)
if err != nil {
Expand Down
21 changes: 21 additions & 0 deletions internal/rukpak/convert/registryv1_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package convert

import (
"fmt"
"testing"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -16,6 +17,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/operator-framework/api/pkg/operators/v1alpha1"
"github.com/operator-framework/operator-registry/alpha/property"
)

func TestRegistryV1Converter(t *testing.T) {
Expand Down Expand Up @@ -173,6 +175,9 @@ var _ = Describe("RegistryV1 Suite", func() {
csv = v1alpha1.ClusterServiceVersion{
ObjectMeta: metav1.ObjectMeta{
Name: "testCSV",
Annotations: map[string]string{
"olm.properties": fmt.Sprintf("[{\"type\": %s, \"value\": \"%s\"}]", property.TypeConstraint, "value"),
},
},
Spec: v1alpha1.ClusterServiceVersionSpec{
InstallModes: []v1alpha1.InstallMode{{Type: v1alpha1.InstallModeTypeMultiNamespace, Supported: true}},
Expand Down Expand Up @@ -380,6 +385,22 @@ var _ = Describe("RegistryV1 Suite", func() {
Expect(err).To(HaveOccurred())
Expect(plainBundle).To(BeNil())
})

It("should propagate csv annotations to chart metadata annotation", func() {
By("creating a registry v1 bundle")
watchNamespaces = []string{"testWatchNs1", "testWatchNs2"}
unstructuredSvc := convertToUnstructured(svc)
registryv1Bundle = RegistryV1{
PackageName: "testPkg",
CSV: csv,
Others: []unstructured.Unstructured{unstructuredSvc},
}

By("converting to helm")
chrt, err := toChart(registryv1Bundle, installNamespace, watchNamespaces)
Expect(err).NotTo(HaveOccurred())
Expect(chrt.Metadata.Annotations["olm.properties"]).NotTo(BeNil())
})
})

Context("Should enforce limitations", func() {
Expand Down