Skip to content
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

Remove usage of global variable in operatorrules #14

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

machadovilaca
Copy link
Owner

Before this PR operator rules were stored in a global variable. This prevented a project from having multiple instances with different alerts and recording rules. This PR follows a structured approach where library users create a new instance of the registry where they can register the alerts and recording rules and old functions are now instance methods.

To keep backward compatibility pkg/operatorrules/compatibility.go was created that delegates previous functions to the instance methods of a global variable. This is deprecated and should be removed in the future.

Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Copy link
Owner Author

@machadovilaca machadovilaca Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg/operatorrules/compatibility_test.go is the old pkg/operatorrules/registry_test.go (which was updated to use the instance methods) and ensures the compatibility passover functions are working

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep backward compatibility pkg/operatorrules/compatibility.go delegates previous existing functions to the instance methods of a global variable. This is deprecated and should be removed in the future.

@machadovilaca
Copy link
Owner Author

@sradco can you also take a look?

@machadovilaca machadovilaca merged commit 8d1631c into main Jul 30, 2024
1 check passed
@machadovilaca machadovilaca deleted the operatorrules-remove-usage-of-global-variables branch July 30, 2024 16:11
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

Successfully merging this pull request may close these issues.

2 participants