@@ -46,6 +46,9 @@ func ChainedResourceGenerator(resourceGenerators ...ResourceGenerator) ResourceG
4646}
4747
4848func BundleDeploymentGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
49+ if rv1 == nil {
50+ return nil , fmt .Errorf ("bundle cannot be nil" )
51+ }
4952 objs := make ([]client.Object , 0 , len (rv1 .CSV .Spec .InstallStrategy .StrategySpec .DeploymentSpecs ))
5053 for _ , depSpec := range rv1 .CSV .Spec .InstallStrategy .StrategySpec .DeploymentSpecs {
5154 annotations := util .MergeMaps (rv1 .CSV .Annotations , depSpec .Spec .Template .Annotations )
@@ -68,13 +71,17 @@ func BundleDeploymentGenerator(rv1 *RegistryV1, opts Options) ([]client.Object,
6871}
6972
7073func BundlePermissionsGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
71- permissions := rv1 .CSV .Spec .InstallStrategy .StrategySpec .Permissions
74+ if rv1 == nil {
75+ return nil , fmt .Errorf ("bundle cannot be nil" )
76+ }
7277
7378 // If we're in AllNamespaces mode permissions will be treated as clusterPermissions
7479 if len (opts .TargetNamespaces ) == 1 && opts .TargetNamespaces [0 ] == "" {
7580 return nil , nil
7681 }
7782
83+ permissions := rv1 .CSV .Spec .InstallStrategy .StrategySpec .Permissions
84+
7885 objs := make ([]client.Object , 0 , 2 * len (opts .TargetNamespaces )* len (permissions ))
7986 for _ , ns := range opts .TargetNamespaces {
8087 for _ , permission := range permissions {
@@ -99,6 +106,9 @@ func BundlePermissionsGenerator(rv1 *RegistryV1, opts Options) ([]client.Object,
99106}
100107
101108func BundleClusterPermissionsGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
109+ if rv1 == nil {
110+ return nil , fmt .Errorf ("bundle cannot be nil" )
111+ }
102112 clusterPermissions := rv1 .CSV .Spec .InstallStrategy .StrategySpec .ClusterPermissions
103113
104114 // If we're in AllNamespaces mode, promote the permissions to clusterPermissions
@@ -133,6 +143,9 @@ func BundleClusterPermissionsGenerator(rv1 *RegistryV1, opts Options) ([]client.
133143}
134144
135145func BundleServiceAccountGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
146+ if rv1 == nil {
147+ return nil , fmt .Errorf ("bundle cannot be nil" )
148+ }
136149 allPermissions := append (
137150 rv1 .CSV .Spec .InstallStrategy .StrategySpec .Permissions ,
138151 rv1 .CSV .Spec .InstallStrategy .StrategySpec .ClusterPermissions ... ,
@@ -154,6 +167,9 @@ func BundleServiceAccountGenerator(rv1 *RegistryV1, opts Options) ([]client.Obje
154167}
155168
156169func BundleCRDGenerator (rv1 * RegistryV1 , _ Options ) ([]client.Object , error ) {
170+ if rv1 == nil {
171+ return nil , fmt .Errorf ("bundle cannot be nil" )
172+ }
157173 objs := make ([]client.Object , 0 , len (rv1 .CRDs ))
158174 for _ , crd := range rv1 .CRDs {
159175 objs = append (objs , crd .DeepCopy ())
@@ -162,6 +178,9 @@ func BundleCRDGenerator(rv1 *RegistryV1, _ Options) ([]client.Object, error) {
162178}
163179
164180func BundleAdditionalResourcesGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
181+ if rv1 == nil {
182+ return nil , fmt .Errorf ("bundle cannot be nil" )
183+ }
165184 objs := make ([]client.Object , 0 , len (rv1 .Others ))
166185 for _ , res := range rv1 .Others {
167186 supported , namespaced := registrybundle .IsSupported (res .GetKind ())
0 commit comments