Skip to content

Commit 52b39ef

Browse files
amisevskAObuchow
authored andcommitted
Drop github.com/redhat-cop/operator-utils dependency
The functionality from operator-utils is now available in controller-runtime, making the additional dependency unnecessary as its functions just wrap controller-runtime The operator-utils dependency makes updating controller-runtime difficult as operator-utils itself depends on k8s.io/api and controller-runtime. Signed-off-by: Angel Misevski <[email protected]>
1 parent c8017af commit 52b39ef

File tree

5 files changed

+17
-310
lines changed

5 files changed

+17
-310
lines changed

controllers/workspace/devworkspace_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import (
4545
"github.com/devfile/devworkspace-operator/pkg/provision/workspace/rbac"
4646
"github.com/go-logr/logr"
4747
"github.com/google/uuid"
48-
coputil "github.com/redhat-cop/operator-utils/pkg/util"
4948
appsv1 "k8s.io/api/apps/v1"
5049
batchv1 "k8s.io/api/batch/v1"
5150
corev1 "k8s.io/api/core/v1"
@@ -58,6 +57,7 @@ import (
5857
"sigs.k8s.io/controller-runtime/pkg/builder"
5958
"sigs.k8s.io/controller-runtime/pkg/client"
6059
"sigs.k8s.io/controller-runtime/pkg/controller"
60+
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
6161
"sigs.k8s.io/controller-runtime/pkg/handler"
6262
"sigs.k8s.io/controller-runtime/pkg/reconcile"
6363
"sigs.k8s.io/controller-runtime/pkg/source"
@@ -291,8 +291,8 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
291291

292292
// Set finalizer on DevWorkspace if necessary
293293
// Note: we need to check the flattened workspace to see if a finalizer is needed, as plugins could require storage
294-
if storageProvisioner.NeedsStorage(&workspace.Spec.Template) && !coputil.HasFinalizer(clusterWorkspace, constants.StorageCleanupFinalizer) {
295-
coputil.AddFinalizer(clusterWorkspace, constants.StorageCleanupFinalizer)
294+
if storageProvisioner.NeedsStorage(&workspace.Spec.Template) && !controllerutil.ContainsFinalizer(clusterWorkspace, constants.StorageCleanupFinalizer) {
295+
controllerutil.AddFinalizer(clusterWorkspace, constants.StorageCleanupFinalizer)
296296
if err := r.Update(ctx, clusterWorkspace.DevWorkspace); err != nil {
297297
return reconcile.Result{}, err
298298
}
@@ -349,8 +349,8 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
349349

350350
// Add finalizer to ensure workspace rolebinding gets cleaned up when workspace
351351
// is deleted.
352-
if !coputil.HasFinalizer(clusterWorkspace, constants.RBACCleanupFinalizer) {
353-
coputil.AddFinalizer(clusterWorkspace, constants.RBACCleanupFinalizer)
352+
if !controllerutil.ContainsFinalizer(clusterWorkspace, constants.RBACCleanupFinalizer) {
353+
controllerutil.AddFinalizer(clusterWorkspace, constants.RBACCleanupFinalizer)
354354
if err := r.Update(ctx, clusterWorkspace.DevWorkspace); err != nil {
355355
return reconcile.Result{}, err
356356
}

controllers/workspace/finalize.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import (
2727
"github.com/devfile/devworkspace-operator/pkg/provision/workspace/rbac"
2828

2929
"github.com/go-logr/logr"
30-
coputil "github.com/redhat-cop/operator-utils/pkg/util"
3130
corev1 "k8s.io/api/core/v1"
3231
"k8s.io/apimachinery/pkg/types"
32+
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
3333
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3434

3535
"github.com/devfile/devworkspace-operator/pkg/provision/storage"
@@ -94,7 +94,7 @@ func (r *DevWorkspaceReconciler) finalizeStorage(ctx context.Context, log logr.L
9494
} else if terminating {
9595
// Namespace is terminating, it's redundant to clean PVC files since it's going to be removed
9696
log.Info("Namespace is terminating; clearing storage finalizer")
97-
coputil.RemoveFinalizer(workspace, constants.StorageCleanupFinalizer)
97+
controllerutil.RemoveFinalizer(workspace, constants.StorageCleanupFinalizer)
9898
return reconcile.Result{}, r.Update(ctx, workspace.DevWorkspace)
9999
}
100100

@@ -129,7 +129,7 @@ func (r *DevWorkspaceReconciler) finalizeStorage(ctx context.Context, log logr.L
129129
}
130130
}
131131
log.Info("PVC clean up successful; clearing finalizer")
132-
coputil.RemoveFinalizer(workspace, constants.StorageCleanupFinalizer)
132+
controllerutil.RemoveFinalizer(workspace, constants.StorageCleanupFinalizer)
133133
return reconcile.Result{}, r.Update(ctx, workspace.DevWorkspace)
134134
}
135135

@@ -140,7 +140,7 @@ func (r *DevWorkspaceReconciler) finalizeRBAC(ctx context.Context, log logr.Logg
140140
} else if terminating {
141141
// Namespace is terminating, it's redundant to update roles/rolebindings since they will be removed with the workspace
142142
log.Info("Namespace is terminating; clearing storage finalizer")
143-
coputil.RemoveFinalizer(workspace, constants.RBACCleanupFinalizer)
143+
controllerutil.RemoveFinalizer(workspace, constants.RBACCleanupFinalizer)
144144
return reconcile.Result{}, r.Update(ctx, workspace.DevWorkspace)
145145
}
146146

@@ -167,7 +167,7 @@ func (r *DevWorkspaceReconciler) finalizeRBAC(ctx context.Context, log logr.Logg
167167
}
168168
}
169169
log.Info("RBAC cleanup successful; clearing finalizer")
170-
coputil.RemoveFinalizer(workspace, constants.RBACCleanupFinalizer)
170+
controllerutil.RemoveFinalizer(workspace, constants.RBACCleanupFinalizer)
171171
return reconcile.Result{}, r.Update(ctx, workspace.DevWorkspace)
172172
}
173173

@@ -185,7 +185,7 @@ func (r *DevWorkspaceReconciler) finalizeServiceAccount(ctx context.Context, log
185185
return reconcile.Result{Requeue: true}, nil
186186
}
187187
log.Info("ServiceAccount clean up successful; clearing finalizer")
188-
coputil.RemoveFinalizer(workspace, constants.ServiceAccountCleanupFinalizer)
188+
controllerutil.RemoveFinalizer(workspace, constants.ServiceAccountCleanupFinalizer)
189189
return reconcile.Result{}, r.Update(ctx, workspace.DevWorkspace)
190190
}
191191

go.mod

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ require (
1414
github.com/onsi/gomega v1.24.1
1515
github.com/openshift/api v0.0.0-20200205133042-34f0ec8dab87
1616
github.com/prometheus/client_golang v1.14.0
17-
github.com/redhat-cop/operator-utils v1.1.4
1817
github.com/stretchr/testify v1.8.0
1918
golang.org/x/crypto v0.3.0
2019
golang.org/x/net v0.7.0
@@ -28,10 +27,6 @@ require (
2827
)
2928

3029
require (
31-
github.com/BurntSushi/toml v0.3.1 // indirect
32-
github.com/Masterminds/goutils v1.1.1 // indirect
33-
github.com/Masterminds/semver/v3 v3.1.1 // indirect
34-
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
3530
github.com/Microsoft/go-winio v0.5.2 // indirect
3631
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4 // indirect
3732
github.com/acomagu/bufpipe v1.0.3 // indirect
@@ -41,31 +36,27 @@ require (
4136
github.com/davecgh/go-spew v1.1.1 // indirect
4237
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
4338
github.com/emirpasic/gods v1.18.1 // indirect
44-
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
39+
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
4540
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
4641
github.com/fsnotify/fsnotify v1.6.0 // indirect
4742
github.com/go-git/gcfg v1.5.0 // indirect
4843
github.com/go-git/go-billy/v5 v5.3.1 // indirect
4944
github.com/go-logr/zapr v1.2.3 // indirect
5045
github.com/go-openapi/jsonpointer v0.19.5 // indirect
5146
github.com/go-openapi/jsonreference v0.20.0 // indirect
52-
github.com/go-openapi/spec v0.19.5 // indirect
5347
github.com/go-openapi/swag v0.19.14 // indirect
5448
github.com/gogo/protobuf v1.3.2 // indirect
5549
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
5650
github.com/golang/protobuf v1.5.2 // indirect
5751
github.com/google/gnostic v0.5.7-v3refs // indirect
58-
github.com/googleapis/gnostic v0.5.5 // indirect
5952
github.com/hashicorp/errwrap v1.0.0 // indirect
6053
github.com/hashicorp/go-multierror v1.1.1 // indirect
61-
github.com/huandu/xstrings v1.3.1 // indirect
6254
github.com/imdario/mergo v0.3.13 // indirect
6355
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
6456
github.com/josharian/intern v1.0.0 // indirect
6557
github.com/json-iterator/go v1.1.12 // indirect
6658
github.com/mailru/easyjson v0.7.6 // indirect
6759
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
68-
github.com/mitchellh/copystructure v1.0.0 // indirect
6960
github.com/mitchellh/reflectwalk v1.0.1 // indirect
7061
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
7162
github.com/modern-go/reflect2 v1.0.2 // indirect
@@ -77,9 +68,7 @@ require (
7768
github.com/prometheus/common v0.37.0 // indirect
7869
github.com/prometheus/procfs v0.8.0 // indirect
7970
github.com/sergi/go-diff v1.1.0 // indirect
80-
github.com/shopspring/decimal v1.2.0 // indirect
8171
github.com/skeema/knownhosts v1.1.0 // indirect
82-
github.com/spf13/cast v1.3.1 // indirect
8372
github.com/spf13/pflag v1.0.5 // indirect
8473
github.com/xanzy/ssh-agent v0.3.3 // indirect
8574
go.uber.org/atomic v1.7.0 // indirect
@@ -100,7 +89,6 @@ require (
10089
k8s.io/component-base v0.26.1 // indirect
10190
k8s.io/klog/v2 v2.80.1 // indirect
10291
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
103-
k8s.io/kubectl v0.20.2 // indirect
10492
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
10593
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
10694
)

0 commit comments

Comments
 (0)