@@ -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,33 @@ 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 .Has (v1alpha1.InstallMode {Type : v1alpha1 .InstallModeTypeAllNamespaces , Supported : true }) &&
49+ ! installModes .Has (v1alpha1.InstallMode {Type : v1alpha1 .InstallModeTypeSingleNamespace , Supported : true }) &&
50+ ! installModes .Has (v1alpha1.InstallMode {Type : v1alpha1 .InstallModeTypeOwnNamespace , Supported : true }) {
51+ return nil , fmt .Errorf ("unsupported bundle: bundle must support at least one of [AllNamespaces SingleNamespace OwnNamespace] install modes" )
52+ }
53+
54+ opts := []render.Option {
55+ render .WithCertificateProvider (r .CertificateProvider ),
56+ }
57+
58+ // TODO: in a follow up PR we'll split this into two components:
59+ // 1. takes a bundle + cluster extension => manifests
60+ // 2. takes a bundle + cluster extension => chart (which will use the component in 1. under the hood)
61+ // GetWatchNamespace will move under the component in 1. and also be reused by the component that
62+ // takes bundle + cluster extension => revision
63+ watchNamespace , err := GetWatchNamespace (ext )
64+ if err != nil {
65+ return nil , err
66+ }
67+
68+ if watchNamespace != "" {
69+ opts = append (opts , render .WithTargetNamespaces (watchNamespace ))
5370 }
5471
5572 objs , err := r .BundleRenderer .Render (rv1 , ext .Spec .Namespace , opts ... )
0 commit comments