cmd/k8s-operator: remove use of InjectClient (deprecated)

The dependency injection functionality has been deprecated a while back
and it'll be removed in the 0.15 release of Controller Runtime. This
changeset sets the Client after creating the Manager, instead of using
InjectClient.

Signed-off-by: Vince Prignano <vince@prigna.com>
pull/7057/head
Vince Prignano 2 years ago committed by Dave Anderson
parent b49aa6ac31
commit 30380403d0

@ -164,14 +164,6 @@ waitOnline:
time.Sleep(time.Second) time.Sleep(time.Second)
} }
sr := &ServiceReconciler{
tsClient: tsClient,
defaultTags: strings.Split(tags, ","),
operatorNamespace: tsNamespace,
proxyImage: image,
logger: zlog.Named("service-reconciler"),
}
// For secrets and statefulsets, we only get permission to touch the objects // For secrets and statefulsets, we only get permission to touch the objects
// in the controller's own namespace. This cannot be expressed by // in the controller's own namespace. This cannot be expressed by
// .Watches(...) below, instead you have to add a per-type field selector to // .Watches(...) below, instead you have to add a per-type field selector to
@ -193,6 +185,15 @@ waitOnline:
startlog.Fatalf("could not create manager: %v", err) startlog.Fatalf("could not create manager: %v", err)
} }
sr := &ServiceReconciler{
Client: mgr.GetClient(),
tsClient: tsClient,
defaultTags: strings.Split(tags, ","),
operatorNamespace: tsNamespace,
proxyImage: image,
logger: zlog.Named("service-reconciler"),
}
reconcileFilter := handler.EnqueueRequestsFromMapFunc(func(o client.Object) []reconcile.Request { reconcileFilter := handler.EnqueueRequestsFromMapFunc(func(o client.Object) []reconcile.Request {
ls := o.GetLabels() ls := o.GetLabels()
if ls[LabelManaged] != "true" { if ls[LabelManaged] != "true" {
@ -591,11 +592,6 @@ func (a *ServiceReconciler) reconcileSTS(ctx context.Context, logger *zap.Sugare
return createOrUpdate(ctx, a.Client, a.operatorNamespace, &ss, func(s *appsv1.StatefulSet) { s.Spec = ss.Spec }) return createOrUpdate(ctx, a.Client, a.operatorNamespace, &ss, func(s *appsv1.StatefulSet) { s.Spec = ss.Spec })
} }
func (a *ServiceReconciler) InjectClient(c client.Client) error {
a.Client = c
return nil
}
// ptrObject is a type constraint for pointer types that implement // ptrObject is a type constraint for pointer types that implement
// client.Object. // client.Object.
type ptrObject[T any] interface { type ptrObject[T any] interface {

Loading…
Cancel
Save