@@ -45,7 +45,16 @@ func ChainedResourceGenerator(resourceGenerators ...ResourceGenerator) ResourceG
4545 }
4646}
4747
48+ var BundleRBACResourceGenerator = ChainedResourceGenerator (
49+ BundleServiceAccountGenerator ,
50+ BundlePermissionsGenerator ,
51+ BundleClusterPermissionsGenerator ,
52+ )
53+
4854func BundleDeploymentGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
55+ if rv1 == nil {
56+ return nil , fmt .Errorf ("bundle cannot be nil" )
57+ }
4958 objs := make ([]client.Object , 0 , len (rv1 .CSV .Spec .InstallStrategy .StrategySpec .DeploymentSpecs ))
5059 for _ , depSpec := range rv1 .CSV .Spec .InstallStrategy .StrategySpec .DeploymentSpecs {
5160 annotations := util .MergeMaps (rv1 .CSV .Annotations , depSpec .Spec .Template .Annotations )
@@ -68,13 +77,17 @@ func BundleDeploymentGenerator(rv1 *RegistryV1, opts Options) ([]client.Object,
6877}
6978
7079func BundlePermissionsGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
71- permissions := rv1 .CSV .Spec .InstallStrategy .StrategySpec .Permissions
80+ if rv1 == nil {
81+ return nil , fmt .Errorf ("bundle cannot be nil" )
82+ }
7283
7384 // If we're in AllNamespaces mode permissions will be treated as clusterPermissions
7485 if len (opts .TargetNamespaces ) == 1 && opts .TargetNamespaces [0 ] == "" {
7586 return nil , nil
7687 }
7788
89+ permissions := rv1 .CSV .Spec .InstallStrategy .StrategySpec .Permissions
90+
7891 objs := make ([]client.Object , 0 , 2 * len (opts .TargetNamespaces )* len (permissions ))
7992 for _ , ns := range opts .TargetNamespaces {
8093 for _ , permission := range permissions {
@@ -99,6 +112,9 @@ func BundlePermissionsGenerator(rv1 *RegistryV1, opts Options) ([]client.Object,
99112}
100113
101114func BundleClusterPermissionsGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
115+ if rv1 == nil {
116+ return nil , fmt .Errorf ("bundle cannot be nil" )
117+ }
102118 clusterPermissions := rv1 .CSV .Spec .InstallStrategy .StrategySpec .ClusterPermissions
103119
104120 // If we're in AllNamespaces mode, promote the permissions to clusterPermissions
@@ -133,6 +149,9 @@ func BundleClusterPermissionsGenerator(rv1 *RegistryV1, opts Options) ([]client.
133149}
134150
135151func BundleServiceAccountGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
152+ if rv1 == nil {
153+ return nil , fmt .Errorf ("bundle cannot be nil" )
154+ }
136155 allPermissions := append (
137156 rv1 .CSV .Spec .InstallStrategy .StrategySpec .Permissions ,
138157 rv1 .CSV .Spec .InstallStrategy .StrategySpec .ClusterPermissions ... ,
@@ -154,6 +173,9 @@ func BundleServiceAccountGenerator(rv1 *RegistryV1, opts Options) ([]client.Obje
154173}
155174
156175func BundleCRDGenerator (rv1 * RegistryV1 , _ Options ) ([]client.Object , error ) {
176+ if rv1 == nil {
177+ return nil , fmt .Errorf ("bundle cannot be nil" )
178+ }
157179 objs := make ([]client.Object , 0 , len (rv1 .CRDs ))
158180 for _ , crd := range rv1 .CRDs {
159181 objs = append (objs , crd .DeepCopy ())
@@ -162,6 +184,9 @@ func BundleCRDGenerator(rv1 *RegistryV1, _ Options) ([]client.Object, error) {
162184}
163185
164186func BundleAdditionalResourcesGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
187+ if rv1 == nil {
188+ return nil , fmt .Errorf ("bundle cannot be nil" )
189+ }
165190 objs := make ([]client.Object , 0 , len (rv1 .Others ))
166191 for _ , res := range rv1 .Others {
167192 supported , namespaced := registrybundle .IsSupported (res .GetKind ())
0 commit comments