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

Enhance Code Readability: Cluster Name Comparison #40

Open
arkaprovob opened this issue Oct 17, 2023 · 0 comments
Open

Enhance Code Readability: Cluster Name Comparison #40

arkaprovob opened this issue Oct 17, 2023 · 0 comments

Comments

@arkaprovob
Copy link
Contributor

Description:
In the existing code, we have a hardcoded cluster name comparison, making the code less readable and maintainable. Let's improve code readability by using a constant or a variable for the cluster name comparison.

Code details

class name:

src/main/java/io/spaship/operator/service/k8s/Operator.java

existing code

    private void updateTenantEgressForIAD2Cluster(String namespace) {
        var domainName = ConfigProvider.getConfig().getValue("operator.domain.name", String.class);
        if (!domainName.contains("iad2")) {

proposed solution

String cluster = "iad2";
var domainName = ConfigProvider.getConfig().getValue(OPERATOR_DOMAIN_NAME, String.class);
        if (!domainName.contains(cluster)) {

Alternative solution

Create a ENum which will contain list of clusters and other relations related to it

Benefits:

  • Improved code readability and maintainability.
  • Reduced code redundancy.

Implementation:

  1. Introduce a constant or variable for the cluster name or create an Enum called cluster
  2. Replace the hardcoded value with the constant or variable or the Enum in the comparison.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants