Skip to content

Migrate deprecated controller-runtime/client-go APIs surfaced by go 1.27 / deps update #26

Description

@henryjarend

Summary

Updating to Go 1.27 and bumping dependencies (controller-runtime v0.24.1, client-go v0.37.0) surfaced two deprecation warnings that were suppressed with //nolint:staticcheck / left as-is rather than migrated, to keep the dependency bump PR minimal.

1. Manager.GetEventRecorderFor (controller-runtime)

Deprecated in favor of Manager.GetEventRecorder(name) events.EventRecorder (k8s.io/client-go/tools/events), but it is not a drop-in replacement — the new Eventf signature adds a related runtime.Object and an action string:

Eventf(regarding, related runtime.Object, eventtype, reason, action, note string, args ...any)

Migrating requires:

  • Changing the Recorder field type on TypesenseClusterReconciler and TypesenseApiKeyReconciler from record.EventRecorder to events.EventRecorder.
  • Rewriting all Recorder.Event/Recorder.Eventf call sites (internal/controller/typesensecluster_controller.go, internal/controller/typesensecluster_statefulset.go) to the new signature, deciding what related object and action string make sense for each event.

Current state: suppressed with //nolint:staticcheck at the two mgr.GetEventRecorderFor(...) call sites in cmd/main.go. Note controller-runtime's own internal code and tests still call the deprecated API with the same nolint pattern, so there's no urgency, but it should eventually move to the new API.

2. scheme.Builder (controller-runtime pkg/scheme) in api/v1alpha1/groupversion_info.go

Deprecated in favor of using k8s.io/apimachinery/pkg/runtime.SchemeBuilder directly, since api packages should minimize dependencies. Not a drop-in: runtime.SchemeBuilder doesn't have the .Register(objects ...runtime.Object) convenience method that scheme.Builder provides — migrating means restructuring how TypesenseCluster/TypesenseApiKey types register themselves in api/v1alpha1/typesensecluster_types.go and api/v1alpha1/typesenseapikey_types.go (registering an AddKnownTypes func with the GroupVersion explicitly instead).

Current state: left as-is, still flagged by golangci-lint (staticcheck SA1019). This is a common, still-widely-used kubebuilder v4 scaffold pattern, so no urgency, but worth revisiting in a deliberate pass.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions