@@ -6,16 +6,20 @@ import (
66 "fmt"
77
88 "helm.sh/helm/v3/pkg/chart"
9+ "k8s.io/apimachinery/pkg/util/sets"
10+
11+ "github.com/operator-framework/api/pkg/operators/v1alpha1"
912
1013 ocv1 "github.com/operator-framework/operator-controller/api/v1"
1114 "github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/bundle/source"
1215 "github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/render"
1316)
1417
1518type RegistryV1HelmChartProvider struct {
16- BundleRenderer render.BundleRenderer
17- CertificateProvider render.CertificateProvider
18- IsWebhookSupportEnabled bool
19+ BundleRenderer render.BundleRenderer
20+ CertificateProvider render.CertificateProvider
21+ IsWebhookSupportEnabled bool
22+ IsSingleOwnNamespaceEnabled bool
1923}
2024
2125func (r * RegistryV1HelmChartProvider ) Get (bundle source.BundleSource , ext * ocv1.ClusterExtension ) (* chart.Chart , error ) {
@@ -24,18 +28,6 @@ func (r *RegistryV1HelmChartProvider) Get(bundle source.BundleSource, ext *ocv1.
2428 return nil , err
2529 }
2630
27- watchNamespace , err := GetWatchNamespace (ext )
28- if err != nil {
29- return nil , err
30- }
31-
32- opts := []render.Option {
33- render .WithCertificateProvider (r .CertificateProvider ),
34- }
35- if watchNamespace != "" {
36- opts = append (opts , render .WithTargetNamespaces (watchNamespace ))
37- }
38-
3931 if len (rv1 .CSV .Spec .APIServiceDefinitions .Owned ) > 0 {
4032 return nil , fmt .Errorf ("unsupported bundle: apiServiceDefintions are not supported" )
4133 }
@@ -48,8 +40,35 @@ func (r *RegistryV1HelmChartProvider) Get(bundle source.BundleSource, ext *ocv1.
4840 }
4941 }
5042
51- if r .CertificateProvider == nil && len (rv1 .CSV .Spec .WebhookDefinitions ) > 0 {
52- return nil , fmt .Errorf ("unsupported bundle: webhookDefinitions are not supported" )
43+ installModes := sets .New (rv1 .CSV .Spec .InstallModes ... )
44+ if ! r .IsSingleOwnNamespaceEnabled && ! installModes .Has (v1alpha1.InstallMode {Type : v1alpha1 .InstallModeTypeAllNamespaces , Supported : true }) {
45+ return nil , fmt .Errorf ("unsupported bundle: bundle does not support AllNamespaces install mode" )
46+ }
47+
48+ if ! installModes .HasAny (
49+ v1alpha1.InstallMode {Type : v1alpha1 .InstallModeTypeAllNamespaces , Supported : true },
50+ v1alpha1.InstallMode {Type : v1alpha1 .InstallModeTypeSingleNamespace , Supported : true },
51+ v1alpha1.InstallMode {Type : v1alpha1 .InstallModeTypeOwnNamespace , Supported : true },
52+ ) {
53+ return nil , fmt .Errorf ("unsupported bundle: bundle must support at least one of [AllNamespaces SingleNamespace OwnNamespace] install modes" )
54+ }
55+
56+ opts := []render.Option {
57+ render .WithCertificateProvider (r .CertificateProvider ),
58+ }
59+
60+ // TODO: in a follow up PR we'll split this into two components:
61+ // 1. takes a bundle + cluster extension => manifests
62+ // 2. takes a bundle + cluster extension => chart (which will use the component in 1. under the hood)
63+ // GetWatchNamespace will move under the component in 1. and also be reused by the component that
64+ // takes bundle + cluster extension => revision
65+ watchNamespace , err := GetWatchNamespace (ext )
66+ if err != nil {
67+ return nil , err
68+ }
69+
70+ if watchNamespace != "" {
71+ opts = append (opts , render .WithTargetNamespaces (watchNamespace ))
5372 }
5473
5574 objs , err := r .BundleRenderer .Render (rv1 , ext .Spec .Namespace , opts ... )
0 commit comments