@@ -117,7 +117,7 @@ func (r *reconciler) getExportedSchemas(ctx context.Context, cl client.Client) (
117117 return nil , err
118118 }
119119
120- var boundSchemas kubebindv1alpha2. ExportedSchemas = make (map [ string ] * kubebindv1alpha2.BoundSchema , len (list .Items ))
120+ boundSchemas : = make (kubebindv1alpha2.ExportedSchemas , len (list .Items ))
121121 for _ , item := range list .Items {
122122 boundSchema , err := helpers .UnstructuredToBoundSchema (item )
123123 if err != nil {
@@ -285,7 +285,7 @@ func (r *reconciler) validate(ctx context.Context, cl client.Client, req *kubebi
285285 return fmt .Errorf ("no exported schemas found" )
286286 }
287287
288- scopes := make ([] apiextensionsv1.ResourceScope , 0 , len ( exportedSchemas ) )
288+ first := apiextensionsv1 .ResourceScope ( "" )
289289 for _ , res := range req .Spec .Resources {
290290 boundSchema , ok := exportedSchemas [res .ResourceGroupName ()]
291291 if ! ok {
@@ -299,23 +299,19 @@ func (r *reconciler) validate(ctx context.Context, cl client.Client, req *kubebi
299299 )
300300 return fmt .Errorf ("schema %s not found" , res .ResourceGroupName ())
301301 }
302- scopes = append (scopes , boundSchema .Spec .Scope )
303- }
304-
305- // Check CRD scopes matches.
306- if len (scopes ) > 1 {
307- first := scopes [0 ]
308- for _ , scope := range scopes [1 :] {
309- if scope != first {
310- conditions .MarkFalse (req ,
311- kubebindv1alpha2 .APIServiceExportRequestConditionExportsReady ,
312- "DifferentScopes" ,
313- conditionsapi .ConditionSeverityError ,
314- "Different scopes found: %v" ,
315- scopes ,
316- )
317- return fmt .Errorf ("different scopes found for claimed resources: %v" , scopes )
318- }
302+ if first == apiextensionsv1 .ResourceScope ("" ) {
303+ first = boundSchema .Spec .Scope
304+ continue
305+ }
306+ if boundSchema .Spec .Scope != first {
307+ conditions .MarkFalse (req ,
308+ kubebindv1alpha2 .APIServiceExportRequestConditionExportsReady ,
309+ "DifferentScopes" ,
310+ conditionsapi .ConditionSeverityError ,
311+ "Different scopes found: %v" ,
312+ boundSchema .Spec .Scope ,
313+ )
314+ return fmt .Errorf ("different scopes found for claimed resources: %v" , boundSchema .Name )
319315 }
320316 }
321317
0 commit comments