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

Cleanup: Centralize Plugin Names in Plugin Interfaces #4309

Open
camilamacedo86 opened this issue Nov 9, 2024 · 1 comment
Open

Cleanup: Centralize Plugin Names in Plugin Interfaces #4309

camilamacedo86 opened this issue Nov 9, 2024 · 1 comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Comments

@camilamacedo86
Copy link
Member

What do you want to happen?

Description: Currently, in various parts of the code, we use hardcoded constants to represent plugin names or keys, such as grafanaPluginKey and deployImagePluginKey in pkg/cli/alpha/internal/generate.go. This approach leads to redundant declarations of plugin names across different locations. For example, in the alpha generate command:

const (
defaultOutputDir = "output-dir"
grafanaPluginKey = "grafana.kubebuilder.io/v1-alpha"
deployImagePluginKey = "deploy-image.go.kubebuilder.io/v1-alpha"
)

Proposal

To improve maintainability and readability, we should:

  1. Refactor to use centralized plugin name retrieval: Replace direct constant usage with Plugin{}.Name() or equivalent methods wherever possible.
  2. Review existing plugins for potential updates: Ensure all plugins have a standardized method (like Name()) in their interface for retrieving their identifiers or names.
  3. Reduce redundancy: Centralize and reuse plugin keys within the plugin interfaces rather than hardcoding them in multiple files.

This will help ensure consistency and make it easier to update plugin keys in the future.

Examples

By leveraging similar methods across plugins, we can avoid the need for hardcoded keys like grafanaPluginKey or deployImagePluginKey.

Extra Labels

No response

@camilamacedo86 camilamacedo86 added kind/feature Categorizes issue or PR as related to a new feature. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed kind/feature Categorizes issue or PR as related to a new feature. labels Nov 9, 2024
@camilamacedo86 camilamacedo86 added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Nov 10, 2024
@camilamacedo86
Copy link
Member Author

camilamacedo86 commented Nov 11, 2024

Hi @bavarianbidi,

This PR is unrelated to the changes made in kubebuilder/pull/4319. The focus here is on improving maintainability by centralizing the plugin’s name retrieval.

Instead of defining constants with the full plugin name across various files, we can initialize the plugin and access its name dynamically using Plugin{}.Name()(for example). This cleanup has no impact on end-users and is purely for maintainers to streamline the codebase. PS.: this change would be applied ONLY in go files, no shell or md ones

This simplifies our work, ensuring consistency and reducing duplication.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.
Projects
None yet
Development

No branches or pull requests

1 participant