@@ -46,6 +46,9 @@ func ChainedResourceGenerator(resourceGenerators ...ResourceGenerator) ResourceG
46
46
}
47
47
48
48
func BundleDeploymentGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
49
+ if rv1 == nil {
50
+ return nil , fmt .Errorf ("bundle cannot be nil" )
51
+ }
49
52
objs := make ([]client.Object , 0 , len (rv1 .CSV .Spec .InstallStrategy .StrategySpec .DeploymentSpecs ))
50
53
for _ , depSpec := range rv1 .CSV .Spec .InstallStrategy .StrategySpec .DeploymentSpecs {
51
54
annotations := util .MergeMaps (rv1 .CSV .Annotations , depSpec .Spec .Template .Annotations )
@@ -68,13 +71,17 @@ func BundleDeploymentGenerator(rv1 *RegistryV1, opts Options) ([]client.Object,
68
71
}
69
72
70
73
func 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
+ }
72
77
73
78
// If we're in AllNamespaces mode permissions will be treated as clusterPermissions
74
79
if len (opts .TargetNamespaces ) == 1 && opts .TargetNamespaces [0 ] == "" {
75
80
return nil , nil
76
81
}
77
82
83
+ permissions := rv1 .CSV .Spec .InstallStrategy .StrategySpec .Permissions
84
+
78
85
objs := make ([]client.Object , 0 , 2 * len (opts .TargetNamespaces )* len (permissions ))
79
86
for _ , ns := range opts .TargetNamespaces {
80
87
for _ , permission := range permissions {
@@ -99,6 +106,9 @@ func BundlePermissionsGenerator(rv1 *RegistryV1, opts Options) ([]client.Object,
99
106
}
100
107
101
108
func BundleClusterPermissionsGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
109
+ if rv1 == nil {
110
+ return nil , fmt .Errorf ("bundle cannot be nil" )
111
+ }
102
112
clusterPermissions := rv1 .CSV .Spec .InstallStrategy .StrategySpec .ClusterPermissions
103
113
104
114
// If we're in AllNamespaces mode, promote the permissions to clusterPermissions
@@ -133,6 +143,9 @@ func BundleClusterPermissionsGenerator(rv1 *RegistryV1, opts Options) ([]client.
133
143
}
134
144
135
145
func BundleServiceAccountGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
146
+ if rv1 == nil {
147
+ return nil , fmt .Errorf ("bundle cannot be nil" )
148
+ }
136
149
allPermissions := append (
137
150
rv1 .CSV .Spec .InstallStrategy .StrategySpec .Permissions ,
138
151
rv1 .CSV .Spec .InstallStrategy .StrategySpec .ClusterPermissions ... ,
@@ -154,6 +167,9 @@ func BundleServiceAccountGenerator(rv1 *RegistryV1, opts Options) ([]client.Obje
154
167
}
155
168
156
169
func BundleCRDGenerator (rv1 * RegistryV1 , _ Options ) ([]client.Object , error ) {
170
+ if rv1 == nil {
171
+ return nil , fmt .Errorf ("bundle cannot be nil" )
172
+ }
157
173
objs := make ([]client.Object , 0 , len (rv1 .CRDs ))
158
174
for _ , crd := range rv1 .CRDs {
159
175
objs = append (objs , crd .DeepCopy ())
@@ -162,6 +178,9 @@ func BundleCRDGenerator(rv1 *RegistryV1, _ Options) ([]client.Object, error) {
162
178
}
163
179
164
180
func BundleAdditionalResourcesGenerator (rv1 * RegistryV1 , opts Options ) ([]client.Object , error ) {
181
+ if rv1 == nil {
182
+ return nil , fmt .Errorf ("bundle cannot be nil" )
183
+ }
165
184
objs := make ([]client.Object , 0 , len (rv1 .Others ))
166
185
for _ , res := range rv1 .Others {
167
186
supported , namespaced := registrybundle .IsSupported (res .GetKind ())
0 commit comments