Skip to content

Enhance Code Readability: Cluster Name Comparison #40

Open
@arkaprovob

Description

@arkaprovob

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions