Skip to content

Commit 02ba77d

Browse files
committed
secretannotator: Only pass clients to Reconciler
Signed-off-by: Stephen Finucane <[email protected]>
1 parent 92e68ab commit 02ba77d

File tree

6 files changed

+28
-27
lines changed

6 files changed

+28
-27
lines changed

pkg/operator/secretannotator/aws/reconciler.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ const (
3838
AwsSecretAccessKeyName = "aws_secret_access_key"
3939
)
4040

41-
func NewReconciler(c client.Client, mgr manager.Manager) reconcile.Reconciler {
41+
func NewReconciler(client, rootCredClient, liveClient client.Client) reconcile.Reconciler {
4242
r := &ReconcileCloudCredSecret{
43-
Client: c,
44-
RootCredClient: mgr.GetClient(),
45-
LiveClient: utils.LiveClient(mgr),
43+
Client: client,
44+
RootCredClient: rootCredClient,
45+
LiveClient: liveClient,
4646
Logger: log.WithField("controller", constants.SecretAnnotatorControllerName),
4747
AWSClientBuilder: awsutils.ClientBuilder,
4848
}
4949

50-
s := status.NewSecretStatusHandler(c)
50+
s := status.NewSecretStatusHandler(client)
5151
statuscontroller.AddHandler(constants.SecretAnnotatorControllerName, s)
5252

5353
return r

pkg/operator/secretannotator/azure/reconciler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ type ReconcileCloudCredSecret struct {
3838
Logger log.FieldLogger
3939
}
4040

41-
func NewReconciler(c client.Client, mgr manager.Manager) reconcile.Reconciler {
41+
func NewReconciler(client, rootCredClient client.Client) reconcile.Reconciler {
4242
r := &ReconcileCloudCredSecret{
43-
Client: c,
44-
RootCredClient: mgr.GetClient(),
43+
Client: client,
44+
RootCredClient: rootCredClient,
4545
Logger: log.WithField("controller", constants.SecretAnnotatorControllerName),
4646
}
4747

48-
s := status.NewSecretStatusHandler(c)
48+
s := status.NewSecretStatusHandler(client)
4949
statuscontroller.AddHandler(constants.SecretAnnotatorControllerName, s)
5050

5151
return r

pkg/operator/secretannotator/gcp/reconciler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ const (
4040
GCPAuthJSONKey = "service_account.json"
4141
)
4242

43-
func NewReconciler(c client.Client, mgr manager.Manager, projectName string) reconcile.Reconciler {
43+
func NewReconciler(client, rootCredClient client.Client, projectName string) reconcile.Reconciler {
4444
r := &ReconcileCloudCredSecret{
45-
Client: c,
46-
RootCredClient: mgr.GetClient(),
45+
Client: client,
46+
RootCredClient: rootCredClient,
4747
Logger: log.WithField("controller", constants.SecretAnnotatorControllerName),
4848
GCPClientBuilder: ccgcp.NewClientFromJSON,
4949
ProjectName: projectName,
5050
}
5151

52-
s := status.NewSecretStatusHandler(c)
52+
s := status.NewSecretStatusHandler(client)
5353
statuscontroller.AddHandler(controllerName, s)
5454

5555
return r

pkg/operator/secretannotator/openstack/reconciler.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ import (
4949
"github.com/openshift/cloud-credential-operator/pkg/operator/utils"
5050
)
5151

52-
func NewReconciler(c client.Client, mgr manager.Manager) reconcile.Reconciler {
52+
func NewReconciler(client, rootCredClient, liveClient client.Client) reconcile.Reconciler {
5353
r := &ReconcileCloudCredSecret{
54-
Client: c,
55-
RootCredClient: mgr.GetClient(),
56-
LiveClient: utils.LiveClient(mgr),
54+
Client: client,
55+
RootCredClient: rootCredClient,
56+
LiveClient: liveClient,
5757
Logger: log.WithField("controller", constants.SecretAnnotatorControllerName),
5858
}
5959

60-
s := status.NewSecretStatusHandler(c)
60+
s := status.NewSecretStatusHandler(client)
6161
statuscontroller.AddHandler(constants.SecretAnnotatorControllerName, s)
6262

6363
return r

pkg/operator/secretannotator/secretannotator_controller.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/openshift/cloud-credential-operator/pkg/operator/secretannotator/gcp"
2727
"github.com/openshift/cloud-credential-operator/pkg/operator/secretannotator/openstack"
2828
"github.com/openshift/cloud-credential-operator/pkg/operator/secretannotator/vsphere"
29+
"github.com/openshift/cloud-credential-operator/pkg/operator/utils"
2930
log "github.com/sirupsen/logrus"
3031
)
3132

@@ -40,19 +41,19 @@ func Add(mgr, rootCredentialManager manager.Manager, kubeconfig string) error {
4041

4142
switch platformType {
4243
case configv1.AzurePlatformType:
43-
return azure.Add(mgr, rootCredentialManager, azure.NewReconciler(mgr.GetClient(), rootCredentialManager))
44+
return azure.Add(mgr, rootCredentialManager, azure.NewReconciler(mgr.GetClient(), rootCredentialManager.GetClient()))
4445
case configv1.AWSPlatformType:
45-
return aws.Add(mgr, rootCredentialManager, aws.NewReconciler(mgr.GetClient(), rootCredentialManager))
46+
return aws.Add(mgr, rootCredentialManager, aws.NewReconciler(mgr.GetClient(), rootCredentialManager.GetClient(), utils.LiveClient(mgr)))
4647
case configv1.GCPPlatformType:
4748
if infraStatus.PlatformStatus == nil || infraStatus.PlatformStatus.GCP == nil {
4849
log.Fatalf("Missing GCP configuration in infrastructure platform status")
4950
}
50-
return gcp.Add(mgr, rootCredentialManager, gcp.NewReconciler(mgr.GetClient(), rootCredentialManager, infraStatus.PlatformStatus.GCP.ProjectID))
51+
return gcp.Add(mgr, rootCredentialManager, gcp.NewReconciler(mgr.GetClient(), rootCredentialManager.GetClient(), infraStatus.PlatformStatus.GCP.ProjectID))
5152
case configv1.VSpherePlatformType:
52-
return vsphere.Add(mgr, rootCredentialManager, vsphere.NewReconciler(mgr.GetClient(), rootCredentialManager))
53+
return vsphere.Add(mgr, rootCredentialManager, vsphere.NewReconciler(mgr.GetClient(), rootCredentialManager.GetClient()))
5354
case configv1.OpenStackPlatformType:
54-
return openstack.Add(mgr, rootCredentialManager, openstack.NewReconciler(mgr.GetClient(), rootCredentialManager))
55+
return openstack.Add(mgr, rootCredentialManager, openstack.NewReconciler(mgr.GetClient(), rootCredentialManager.GetClient(), utils.LiveClient(mgr)))
5556
default: // returning the AWS implementation for default to avoid changing any behavior
56-
return aws.Add(mgr, rootCredentialManager, aws.NewReconciler(mgr.GetClient(), rootCredentialManager))
57+
return aws.Add(mgr, rootCredentialManager, aws.NewReconciler(mgr.GetClient(), rootCredentialManager.GetClient(), utils.LiveClient(mgr)))
5758
}
5859
}

pkg/operator/secretannotator/vsphere/reconciler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ type ReconcileCloudCredSecret struct {
5858
}
5959

6060
// NewReconciler will return a reconciler for handling vSphere cloud cred secrets.
61-
func NewReconciler(c client.Client, mgr manager.Manager) reconcile.Reconciler {
61+
func NewReconciler(client, rootCredClient client.Client) reconcile.Reconciler {
6262
return &ReconcileCloudCredSecret{
63-
Client: c,
64-
RootCredClient: mgr.GetClient(),
63+
Client: client,
64+
RootCredClient: rootCredClient,
6565
Logger: log.WithField("controller", constants.SecretAnnotatorControllerName),
6666
}
6767
}

0 commit comments

Comments
 (0)