Skip to content

Commit

Permalink
feat(teams) Add team controller responsibility to team membership upd…
Browse files Browse the repository at this point in the history
…ater (#723)
  • Loading branch information
gciezkowski-acc committed Dec 17, 2024
1 parent 6503a12 commit a58404e
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 274 deletions.
3 changes: 0 additions & 3 deletions charts/manager/crds/greenhouse.sap_clusterkubeconfigs.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
3 changes: 0 additions & 3 deletions charts/manager/crds/greenhouse.sap_clusters.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
3 changes: 0 additions & 3 deletions charts/manager/crds/greenhouse.sap_organizations.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
3 changes: 0 additions & 3 deletions charts/manager/crds/greenhouse.sap_plugindefinitions.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
3 changes: 0 additions & 3 deletions charts/manager/crds/greenhouse.sap_pluginpresets.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
3 changes: 0 additions & 3 deletions charts/manager/crds/greenhouse.sap_plugins.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
3 changes: 0 additions & 3 deletions charts/manager/crds/greenhouse.sap_teammemberships.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
3 changes: 0 additions & 3 deletions charts/manager/crds/greenhouse.sap_teamrolebindings.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
3 changes: 0 additions & 3 deletions charts/manager/crds/greenhouse.sap_teamroles.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
3 changes: 0 additions & 3 deletions charts/manager/crds/greenhouse.sap_teams.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
7 changes: 0 additions & 7 deletions charts/manager/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ rules:
- patch
- update
- watch
- apiGroups:
- greenhouse.sap
resources:
- teammemberships=
verbs:
- get
- list
- apiGroups:
- rbac
resources:
Expand Down
1 change: 0 additions & 1 deletion cmd/greenhouse/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var knownControllers = map[string]func(controllerName string, mgr ctrl.Manager)
"organizationController": startOrganizationReconciler,

// Team controllers.
"teamController": (&teamcontrollers.TeamReconciler{}).SetupWithManager,
"teamPropagation": (&teamcontrollers.TeamPropagationReconciler{}).SetupWithManager,

// TeamMembership controllers.
Expand Down
33 changes: 0 additions & 33 deletions pkg/controllers/team/suite_test.go

This file was deleted.

85 changes: 0 additions & 85 deletions pkg/controllers/team/team_controller.go

This file was deleted.

112 changes: 0 additions & 112 deletions pkg/controllers/team/team_controller_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions pkg/controllers/teammembership/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/cloudoperators/greenhouse/pkg/controllers/team"
"github.com/cloudoperators/greenhouse/pkg/controllers/teammembership"
"github.com/cloudoperators/greenhouse/pkg/scim"
"github.com/cloudoperators/greenhouse/pkg/test"
Expand All @@ -31,7 +30,6 @@ var _ = BeforeSuite(func() {

test.RegisterController("teammembershipUpdaterController",
(&teammembership.TeamMembershipUpdaterController{}).SetupWithManager)
test.RegisterController("teamController", (&team.TeamReconciler{}).SetupWithManager)
test.TestBeforeSuite()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func listTeamsAsReconcileRequests(ctx context.Context, c client.Client, listOpts
}

func (r *TeamMembershipUpdaterController) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
return lifecycle.Reconcile(ctx, r.Client, req.NamespacedName, &greenhousev1alpha1.Team{}, r, nil) // status function is nil because it updates the other entity inside.
return lifecycle.Reconcile(ctx, r.Client, req.NamespacedName, &greenhousev1alpha1.Team{}, r, nil)
}

func (r *TeamMembershipUpdaterController) EnsureDeleted(_ context.Context, _ lifecycle.RuntimeObject) (ctrl.Result, lifecycle.ReconcileResult, error) {
Expand Down Expand Up @@ -187,6 +187,7 @@ func (r *TeamMembershipUpdaterController) EnsureCreated(ctx context.Context, obj
return ctrl.Result{}, lifecycle.Failed, err
}

team.Status.Members = users
teamMembershipStatus.SetConditions(membersValidCondition, greenhousev1alpha1.TrueCondition(greenhousev1alpha1.SCIMAccessReadyCondition, "", ""))

membersCountMetric.With(prometheus.Labels{
Expand Down
Loading

0 comments on commit a58404e

Please sign in to comment.