Skip to content

Commit a9ecfff

Browse files
committed
Make TemporalWorkerDeploymentFinalizer constant internal
Changed the exported constant TemporalWorkerDeploymentFinalizer to temporalWorkerDeploymentFinalizer (lowercase) to make it package-private since it's only used within the controller package. Addresses: #97 (comment)
1 parent 650ba81 commit a9ecfff

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

internal/controller/finalizer_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestFinalizerAddition(t *testing.T) {
5454
}
5555

5656
// Verify finalizer is not present initially
57-
if controllerutil.ContainsFinalizer(workerDeploy, TemporalWorkerDeploymentFinalizer) {
57+
if controllerutil.ContainsFinalizer(workerDeploy, temporalWorkerDeploymentFinalizer) {
5858
t.Error("Finalizer should not be present initially")
5959
}
6060

@@ -79,7 +79,7 @@ func TestFinalizerAddition(t *testing.T) {
7979
}
8080

8181
// Verify finalizer was added
82-
if !controllerutil.ContainsFinalizer(updated, TemporalWorkerDeploymentFinalizer) {
82+
if !controllerutil.ContainsFinalizer(updated, temporalWorkerDeploymentFinalizer) {
8383
t.Error("Finalizer should be present after update")
8484
}
8585
}
@@ -202,7 +202,7 @@ func TestHandleDeletion(t *testing.T) {
202202
workerDeploy := testhelpers.ModifyObj(testhelpers.MakeTWDWithName("test-worker", "default"), func(twd *temporaliov1alpha1.TemporalWorkerDeployment) *temporaliov1alpha1.TemporalWorkerDeployment {
203203
twd.UID = "worker-uid-123"
204204
twd.DeletionTimestamp = &now
205-
twd.Finalizers = []string{TemporalWorkerDeploymentFinalizer}
205+
twd.Finalizers = []string{temporalWorkerDeploymentFinalizer}
206206
twd.Spec.WorkerOptions = temporaliov1alpha1.WorkerOptions{
207207
TemporalNamespace: "test-namespace",
208208
TemporalConnection: "test-connection",
@@ -222,7 +222,7 @@ func TestHandleDeletion(t *testing.T) {
222222
logger := testlogr.New(t)
223223

224224
// Verify finalizer is present before deletion
225-
if !controllerutil.ContainsFinalizer(workerDeploy, TemporalWorkerDeploymentFinalizer) {
225+
if !controllerutil.ContainsFinalizer(workerDeploy, temporalWorkerDeploymentFinalizer) {
226226
t.Error("Finalizer should be present before deletion handling")
227227
}
228228

internal/controller/worker_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ const (
3737
// TODO(jlegrone): add this everywhere
3838
deployOwnerKey = ".metadata.controller"
3939
buildIDLabel = "temporal.io/build-id"
40-
// TemporalWorkerDeploymentFinalizer is the finalizer used to ensure proper cleanup of resources
41-
TemporalWorkerDeploymentFinalizer = "temporal.io/temporal-worker-deployment-finalizer"
40+
// temporalWorkerDeploymentFinalizer is the finalizer used to ensure proper cleanup of resources
41+
temporalWorkerDeploymentFinalizer = "temporal.io/temporal-worker-deployment-finalizer"
4242

4343
// Cleanup timeout and polling constants
4444
cleanupTimeout = 2 * time.Minute
@@ -94,8 +94,8 @@ func (r *TemporalWorkerDeploymentReconciler) Reconcile(ctx context.Context, req
9494
}
9595

9696
// Add finalizer if it doesn't exist
97-
if !controllerutil.ContainsFinalizer(&workerDeploy, TemporalWorkerDeploymentFinalizer) {
98-
controllerutil.AddFinalizer(&workerDeploy, TemporalWorkerDeploymentFinalizer)
97+
if !controllerutil.ContainsFinalizer(&workerDeploy, temporalWorkerDeploymentFinalizer) {
98+
controllerutil.AddFinalizer(&workerDeploy, temporalWorkerDeploymentFinalizer)
9999
if err := r.Update(ctx, &workerDeploy); err != nil {
100100
l.Error(err, "unable to add finalizer")
101101
return ctrl.Result{}, err
@@ -217,7 +217,7 @@ func (r *TemporalWorkerDeploymentReconciler) Reconcile(ctx context.Context, req
217217
func (r *TemporalWorkerDeploymentReconciler) handleDeletion(ctx context.Context, l logr.Logger, workerDeploy *temporaliov1alpha1.TemporalWorkerDeployment) (ctrl.Result, error) {
218218
l.Info("Handling deletion of TemporalWorkerDeployment")
219219

220-
if !controllerutil.ContainsFinalizer(workerDeploy, TemporalWorkerDeploymentFinalizer) {
220+
if !controllerutil.ContainsFinalizer(workerDeploy, temporalWorkerDeploymentFinalizer) {
221221
// Finalizer has already been removed, allow deletion to proceed
222222
return ctrl.Result{}, nil
223223
}
@@ -229,7 +229,7 @@ func (r *TemporalWorkerDeploymentReconciler) handleDeletion(ctx context.Context,
229229
}
230230

231231
// Remove the finalizer to allow deletion
232-
controllerutil.RemoveFinalizer(workerDeploy, TemporalWorkerDeploymentFinalizer)
232+
controllerutil.RemoveFinalizer(workerDeploy, temporalWorkerDeploymentFinalizer)
233233
if err := r.Update(ctx, workerDeploy); err != nil {
234234
l.Error(err, "Failed to remove finalizer")
235235
return ctrl.Result{}, err

0 commit comments

Comments
 (0)