Skip to content

Use r.Recorder.Eventf() like explained in the docs #1596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
guettli opened this issue May 6, 2025 · 0 comments
Open

Use r.Recorder.Eventf() like explained in the docs #1596

guettli opened this issue May 6, 2025 · 0 comments

Comments

@guettli
Copy link
Collaborator

guettli commented May 6, 2025

/kind feature

Current the code uses record.Eventf() (or Warnf()), which uses the cluster-api package record.

The code of Cluster-API does not use that anymore, and the kubebuilder docs align to the cluster-api code:

Each Reconciler has a field "Record" which gets used to create the events:

    if err = (&controller.MyKindReconciler{
        Client:   mgr.GetClient(),
        Scheme:   mgr.GetScheme(),
        Recorder: mgr.GetEventRecorderFor("mykind-controller"), // <<<===
    }).SetupWithManager(mgr); err != nil {
        setupLog.Error(err, "unable to create controller", "controller", "MyKind")
        os.Exit(1)
    }

Docs: https://book.kubebuilder.io/reference/raising-events

Currently, it is too difficult to get the events in unit-tests. After that change, we can easily overwrite the Recorder in tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant