@@ -39,38 +39,35 @@ type WorkloadServiceAccountReconciler struct {
39
39
40
40
// Reconcile is part of the main kubernetes reconciliation loop which aims to
41
41
// move the current state of the cluster closer to the desired state.
42
- // TODO(user): Modify the Reconcile function to compare the state specified by
43
- // the WorkloadServiceAccount object against the actual cluster state, and then
44
- // perform operations to make the cluster state reflect the state specified by
45
- // the user.
46
- //
47
- // For more details, check Reconcile and its Result here:
48
- // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.21.0/pkg/reconcile
49
42
func (r * WorkloadServiceAccountReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
50
43
log := logf .FromContext (ctx )
51
44
52
- var wsa agentoctopuscomv1beta1.WorkloadServiceAccount
53
- if err := r .Get (ctx , req .NamespacedName , & wsa ); err != nil {
54
- log .Error (err , "unable to fetch WorkloadServiceAccount" )
55
- return ctrl.Result {}, client .IgnoreNotFound (err )
56
- }
57
-
58
- for _ , project := range wsa .Spec .Scope .Projects {
59
- log .Info ("We have a project scope" , "project" , project )
60
- }
61
-
62
- for _ , environment := range wsa .Spec .Scope .Environments {
63
- log .Info ("We have an environment scope" , "project" , environment )
64
- }
45
+ log .Info ("WorkloadServiceAccount reconciliation triggered" )
65
46
66
- for _ , tenant := range wsa .Spec .Scope .Tenants {
67
- log .Info ("We have a tenant scope" , "tenant" , tenant )
47
+ wsaList := & agentoctopuscomv1beta1.WorkloadServiceAccountList {}
48
+ if err := r .List (ctx , wsaList , client .InNamespace (req .Namespace )); err != nil {
49
+ log .Error (err , "failed to list WorkloadServiceAccounts" )
50
+ return ctrl.Result {}, err
68
51
}
69
52
70
- for _ , step := range wsa .Spec .Scope .Steps {
71
- log .Info ("We have a step scope" , "step" , step )
53
+ log .Info ("Found WSAs in namespace" , "count" , len (wsaList .Items ))
54
+
55
+ for _ , currentWSA := range wsaList .Items {
56
+ for _ , project := range currentWSA .Spec .Scope .Projects {
57
+ log .Info ("WSA has project scope" , "wsa" , currentWSA .Name , "project" , project )
58
+ }
59
+ for _ , environment := range currentWSA .Spec .Scope .Environments {
60
+ log .Info ("WSA has environment scope" , "wsa" , currentWSA .Name , "environment" , environment )
61
+ }
62
+ for _ , tenant := range currentWSA .Spec .Scope .Tenants {
63
+ log .Info ("WSA has tenant scope" , "wsa" , currentWSA .Name , "tenant" , tenant )
64
+ }
65
+ for _ , step := range currentWSA .Spec .Scope .Steps {
66
+ log .Info ("WSA has step scope" , "wsa" , currentWSA .Name , "step" , step )
67
+ }
72
68
}
73
69
70
+ log .Info ("Successfully reconciled WorkloadServiceAccounts" )
74
71
return ctrl.Result {}, nil
75
72
}
76
73
0 commit comments