Skip to content

Commit fac1a15

Browse files
committed
Move controller names to the naming package
1 parent b4c3089 commit fac1a15

File tree

7 files changed

+32
-34
lines changed

7 files changed

+32
-34
lines changed

cmd/postgres-operator/main.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ func main() {
307307
func addControllersToManager(mgr runtime.Manager, log logging.Logger, reg registration.Registration) {
308308
pgReconciler := &postgrescluster.Reconciler{
309309
Client: mgr.GetClient(),
310-
Owner: postgrescluster.ControllerName,
311-
Recorder: mgr.GetEventRecorderFor(postgrescluster.ControllerName),
310+
Owner: naming.ControllerPostgresCluster,
311+
Recorder: mgr.GetEventRecorderFor(naming.ControllerPostgresCluster),
312312
Registration: reg,
313313
}
314314

@@ -319,8 +319,8 @@ func addControllersToManager(mgr runtime.Manager, log logging.Logger, reg regist
319319

320320
upgradeReconciler := &pgupgrade.PGUpgradeReconciler{
321321
Client: mgr.GetClient(),
322-
Owner: "pgupgrade-controller",
323-
Recorder: mgr.GetEventRecorderFor("pgupgrade-controller"),
322+
Owner: naming.ControllerPGUpgrade,
323+
Recorder: mgr.GetEventRecorderFor(naming.ControllerPGUpgrade),
324324
Registration: reg,
325325
}
326326

@@ -331,7 +331,7 @@ func addControllersToManager(mgr runtime.Manager, log logging.Logger, reg regist
331331

332332
pgAdminReconciler := &standalone_pgadmin.PGAdminReconciler{
333333
Client: mgr.GetClient(),
334-
Owner: "pgadmin-controller",
334+
Owner: naming.ControllerPGAdmin,
335335
Recorder: mgr.GetEventRecorderFor(naming.ControllerPGAdmin),
336336
}
337337

@@ -347,10 +347,8 @@ func addControllersToManager(mgr runtime.Manager, log logging.Logger, reg regist
347347
}
348348

349349
crunchyBridgeClusterReconciler := &crunchybridgecluster.CrunchyBridgeClusterReconciler{
350-
Client: mgr.GetClient(),
351-
Owner: "crunchybridgecluster-controller",
352-
// TODO(crunchybridgecluster): recorder?
353-
// Recorder: mgr.GetEventRecorderFor(naming...),
350+
Client: mgr.GetClient(),
351+
Owner: naming.ControllerCrunchyBridgeCluster,
354352
NewClient: constructor,
355353
}
356354

internal/controller/postgrescluster/controller.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,15 @@ import (
3333
"github.com/crunchydata/postgres-operator/internal/initialize"
3434
"github.com/crunchydata/postgres-operator/internal/kubernetes"
3535
"github.com/crunchydata/postgres-operator/internal/logging"
36+
"github.com/crunchydata/postgres-operator/internal/naming"
3637
"github.com/crunchydata/postgres-operator/internal/pki"
3738
"github.com/crunchydata/postgres-operator/internal/postgres"
3839
"github.com/crunchydata/postgres-operator/internal/registration"
3940
"github.com/crunchydata/postgres-operator/internal/tracing"
4041
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
4142
)
4243

43-
const (
44-
// ControllerName is the name of the PostgresCluster controller
45-
ControllerName = "postgrescluster-controller"
46-
)
44+
const controllerName = naming.ControllerPostgresCluster
4745

4846
// Reconciler holds resources for the PostgresCluster reconciler
4947
type Reconciler struct {

internal/controller/postgrescluster/controller_ref_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (r *Reconciler) adoptObject(ctx context.Context, postgresCluster *v1beta1.P
4141

4242
return r.Client.Patch(ctx, obj, client.RawPatch(types.StrategicMergePatchType,
4343
patchBytes), &client.PatchOptions{
44-
FieldManager: ControllerName,
44+
FieldManager: controllerName,
4545
})
4646
}
4747

internal/controller/postgrescluster/pgbackrest_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ func TestReconcilePGBackRest(t *testing.T) {
179179
ctx, cancel := setupManager(t, cfg, func(mgr manager.Manager) {
180180
r = &Reconciler{
181181
Client: mgr.GetClient(),
182-
Recorder: mgr.GetEventRecorderFor(ControllerName),
183-
Owner: ControllerName,
182+
Recorder: mgr.GetEventRecorderFor(controllerName),
183+
Owner: controllerName,
184184
}
185185
})
186186
t.Cleanup(func() { teardownManager(cancel, t) })
@@ -805,8 +805,8 @@ func TestReconcileStanzaCreate(t *testing.T) {
805805
ctx, cancel := setupManager(t, cfg, func(mgr manager.Manager) {
806806
r = &Reconciler{
807807
Client: mgr.GetClient(),
808-
Recorder: mgr.GetEventRecorderFor(ControllerName),
809-
Owner: ControllerName,
808+
Recorder: mgr.GetEventRecorderFor(controllerName),
809+
Owner: controllerName,
810810
}
811811
})
812812
t.Cleanup(func() { teardownManager(cancel, t) })
@@ -1087,8 +1087,8 @@ func TestReconcileManualBackup(t *testing.T) {
10871087
_, cancel := setupManager(t, cfg, func(mgr manager.Manager) {
10881088
r = &Reconciler{
10891089
Client: mgr.GetClient(),
1090-
Recorder: mgr.GetEventRecorderFor(ControllerName),
1091-
Owner: ControllerName,
1090+
Recorder: mgr.GetEventRecorderFor(controllerName),
1091+
Owner: controllerName,
10921092
}
10931093
})
10941094
t.Cleanup(func() { teardownManager(cancel, t) })
@@ -1831,8 +1831,8 @@ func TestReconcilePostgresClusterDataSource(t *testing.T) {
18311831
ctx, cancel := setupManager(t, cfg, func(mgr manager.Manager) {
18321832
r = &Reconciler{
18331833
Client: tClient,
1834-
Recorder: mgr.GetEventRecorderFor(ControllerName),
1835-
Owner: ControllerName,
1834+
Recorder: mgr.GetEventRecorderFor(controllerName),
1835+
Owner: controllerName,
18361836
}
18371837
})
18381838
t.Cleanup(func() { teardownManager(cancel, t) })
@@ -2210,8 +2210,8 @@ func TestReconcileCloudBasedDataSource(t *testing.T) {
22102210
ctx, cancel := setupManager(t, cfg, func(mgr manager.Manager) {
22112211
r = &Reconciler{
22122212
Client: tClient,
2213-
Recorder: mgr.GetEventRecorderFor(ControllerName),
2214-
Owner: ControllerName,
2213+
Recorder: mgr.GetEventRecorderFor(controllerName),
2214+
Owner: controllerName,
22152215
}
22162216
})
22172217
t.Cleanup(func() { teardownManager(cancel, t) })
@@ -2635,7 +2635,7 @@ func TestGenerateBackupJobIntent(t *testing.T) {
26352635

26362636
r := &Reconciler{
26372637
Client: cc,
2638-
Owner: ControllerName,
2638+
Owner: controllerName,
26392639
}
26402640

26412641
ctx := context.Background()
@@ -3931,8 +3931,8 @@ func TestReconcileScheduledBackups(t *testing.T) {
39313931
_, cancel := setupManager(t, cfg, func(mgr manager.Manager) {
39323932
r = &Reconciler{
39333933
Client: mgr.GetClient(),
3934-
Recorder: mgr.GetEventRecorderFor(ControllerName),
3935-
Owner: ControllerName,
3934+
Recorder: mgr.GetEventRecorderFor(controllerName),
3935+
Owner: controllerName,
39363936
}
39373937
})
39383938
t.Cleanup(func() { teardownManager(cancel, t) })
@@ -4267,8 +4267,8 @@ func TestBackupsEnabled(t *testing.T) {
42674267
ctx, cancel := setupManager(t, cfg, func(mgr manager.Manager) {
42684268
r = &Reconciler{
42694269
Client: mgr.GetClient(),
4270-
Recorder: mgr.GetEventRecorderFor(ControllerName),
4271-
Owner: ControllerName,
4270+
Recorder: mgr.GetEventRecorderFor(controllerName),
4271+
Owner: controllerName,
42724272
}
42734273
})
42744274
t.Cleanup(func() { teardownManager(cancel, t) })

internal/controller/postgrescluster/pki_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestReconcileCerts(t *testing.T) {
4343

4444
r := &Reconciler{
4545
Client: tClient,
46-
Owner: ControllerName,
46+
Owner: controllerName,
4747
}
4848

4949
// set up cluster1

internal/naming/controllers.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
package naming
66

77
const (
8-
ControllerBridge = "bridge-controller"
9-
ControllerPGAdmin = "pgadmin-controller"
8+
ControllerBridge = "bridge-controller"
9+
ControllerCrunchyBridgeCluster = "crunchybridgecluster-controller"
10+
ControllerPGAdmin = "pgadmin-controller"
11+
ControllerPGUpgrade = "pgupgrade-controller"
12+
ControllerPostgresCluster = "postgrescluster-controller"
1013
)

internal/upgradecheck/header.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"k8s.io/apimachinery/pkg/util/uuid"
1717
crclient "sigs.k8s.io/controller-runtime/pkg/client"
1818

19-
"github.com/crunchydata/postgres-operator/internal/controller/postgrescluster"
2019
"github.com/crunchydata/postgres-operator/internal/feature"
2120
"github.com/crunchydata/postgres-operator/internal/kubernetes"
2221
"github.com/crunchydata/postgres-operator/internal/logging"
@@ -128,7 +127,7 @@ func manageUpgradeCheckConfigMap(ctx context.Context, crClient crclient.Client,
128127
}
129128
}
130129

131-
err = applyConfigMap(ctx, crClient, cm, postgrescluster.ControllerName)
130+
err = applyConfigMap(ctx, crClient, cm, naming.ControllerPostgresCluster)
132131
if err != nil {
133132
log.V(1).Info("upgrade check issue: could not apply configmap",
134133
"response", err.Error())

0 commit comments

Comments
 (0)