Open
Description
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:
- Introduce a constant or variable for the cluster name or create an Enum called cluster
- Replace the hardcoded value with the constant or variable or the Enum in the comparison.