Skip to content

Commit 5b525c2

Browse files
authored
Merge pull request #349 from Kuadrant/fix/bootstrap-count
[Bugfix] Only bootstrap AuthConfigs in scope
2 parents 77b8032 + 611a22a commit 5b525c2

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

controllers/auth_config_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,11 @@ func (r *AuthConfigReconciler) bootstrapIndex(ctx context.Context) error {
624624
}
625625

626626
authConfigList := api.AuthConfigList{}
627-
if err := r.List(ctx, &authConfigList); err != nil {
627+
listOptions := []client.ListOption{}
628+
if r.LabelSelector != nil {
629+
listOptions = append(listOptions, client.MatchingLabelsSelector{Selector: r.LabelSelector})
630+
}
631+
if err := r.List(ctx, &authConfigList, listOptions...); err != nil {
628632
return err
629633
}
630634

controllers/auth_config_controller_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,12 @@ func TestEmptyAuthConfigIdentitiesDefaultsToAnonymousAccess(t *testing.T) {
318318
assert.Equal(t, len(config.IdentityConfigs), 1)
319319
}
320320

321-
func TestEmptyIndex(t *testing.T) {
321+
func TestBootstrapIndex(t *testing.T) {
322322
mockController := gomock.NewController(t)
323323
defer mockController.Finish()
324324
indexMock := mock_index.NewMockIndex(mockController)
325325

326-
authConfig := newTestAuthConfig(map[string]string{})
326+
authConfig := newTestAuthConfig(map[string]string{"scope": "in"})
327327
authConfig.Status.Summary = api.Summary{
328328
Ready: true,
329329
HostsReady: authConfig.Spec.Hosts,
@@ -334,11 +334,25 @@ func TestEmptyIndex(t *testing.T) {
334334
NumResponseItems: int64(len(authConfig.Spec.Response)),
335335
FestivalWristbandEnabled: false,
336336
}
337+
338+
authConfigOutOfScope := newTestAuthConfig(map[string]string{"scope": "out"})
339+
authConfigOutOfScope.Status.Summary = api.Summary{
340+
Ready: true,
341+
HostsReady: authConfig.Spec.Hosts,
342+
NumHostsReady: fmt.Sprintf("%d/%d", len(authConfig.Spec.Hosts), len(authConfig.Spec.Hosts)),
343+
NumIdentitySources: int64(len(authConfig.Spec.Identity)),
344+
NumMetadataSources: int64(len(authConfig.Spec.Metadata)),
345+
NumAuthorizationPolicies: int64(len(authConfig.Spec.Authorization)),
346+
NumResponseItems: int64(len(authConfig.Spec.Response)),
347+
FestivalWristbandEnabled: false,
348+
}
349+
337350
authConfigName := types.NamespacedName{Name: authConfig.Name, Namespace: authConfig.Namespace}
338351
resourceId := authConfigName.String()
339352
secret := newTestOAuthClientSecret()
340353
client := newTestK8sClient(&authConfig, &secret)
341354
reconciler := newTestAuthConfigReconciler(client, indexMock)
355+
reconciler.LabelSelector = ToLabelSelector("scope=in")
342356

343357
indexMock.EXPECT().Empty().Return(true)
344358
indexMock.EXPECT().FindKeys(resourceId).Return([]string{}).AnyTimes()

0 commit comments

Comments
 (0)