From 3866b67dd5021e1fc1d0ccefaf8b18b8bbca9db0 Mon Sep 17 00:00:00 2001 From: bharathappali Date: Fri, 3 Nov 2023 11:35:43 +0530 Subject: [PATCH] Adds constants for each api version in kruize, and changes the list recommendation SO to have specific version of API rather than having the kruize object version Signed-off-by: bharathappali --- .../analyzer/kruizeObject/KruizeObject.java | 1 + .../analyzer/serviceObjects/Converters.java | 4 ++-- .../analyzer/utils/AnalyzerConstants.java | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/autotune/analyzer/kruizeObject/KruizeObject.java b/src/main/java/com/autotune/analyzer/kruizeObject/KruizeObject.java index 65a7a89f3..d187a4957 100644 --- a/src/main/java/com/autotune/analyzer/kruizeObject/KruizeObject.java +++ b/src/main/java/com/autotune/analyzer/kruizeObject/KruizeObject.java @@ -82,6 +82,7 @@ public KruizeObject(String experimentName, StringBuilder error = ValidateKruizeObject.validate(map); if (error.toString().isEmpty()) { + this.apiVersion = AnalyzerConstants.VersionConstants.CURRENT_KRUIZE_OBJECT_VERSION; this.experimentName = experimentName; this.mode = mode; this.targetCluster = targetCluster; diff --git a/src/main/java/com/autotune/analyzer/serviceObjects/Converters.java b/src/main/java/com/autotune/analyzer/serviceObjects/Converters.java index 88452c681..e25295fc9 100644 --- a/src/main/java/com/autotune/analyzer/serviceObjects/Converters.java +++ b/src/main/java/com/autotune/analyzer/serviceObjects/Converters.java @@ -98,7 +98,7 @@ public static ListRecommendationsAPIObject convertKruizeObjectToListRecommendati Timestamp monitoringEndTime) { ListRecommendationsAPIObject listRecommendationsAPIObject = new ListRecommendationsAPIObject(); try { - listRecommendationsAPIObject.setApiVersion(kruizeObject.getApiVersion()); + listRecommendationsAPIObject.setApiVersion(AnalyzerConstants.VersionConstants.APIVersionConstants.CURRENT_LIST_RECOMMENDATIONS_VERSION); listRecommendationsAPIObject.setExperimentName(kruizeObject.getExperimentName()); listRecommendationsAPIObject.setClusterName(kruizeObject.getClusterName()); List kubernetesAPIObjects = new ArrayList<>(); @@ -190,7 +190,7 @@ public static ListRecommendationsAPIObject convertKruizeObjectToListRecommendati String monitoringEndTimestamp) { ListRecommendationsAPIObject listRecommendationsAPIObject = new ListRecommendationsAPIObject(); try { - listRecommendationsAPIObject.setApiVersion(kruizeObject.getApiVersion()); + listRecommendationsAPIObject.setApiVersion(AnalyzerConstants.VersionConstants.APIVersionConstants.CURRENT_LIST_RECOMMENDATIONS_VERSION); listRecommendationsAPIObject.setExperimentName(kruizeObject.getExperimentName()); listRecommendationsAPIObject.setClusterName(kruizeObject.getClusterName()); List kubernetesAPIObjects = new ArrayList<>(); diff --git a/src/main/java/com/autotune/analyzer/utils/AnalyzerConstants.java b/src/main/java/com/autotune/analyzer/utils/AnalyzerConstants.java index 0fb0bf328..e9607410c 100644 --- a/src/main/java/com/autotune/analyzer/utils/AnalyzerConstants.java +++ b/src/main/java/com/autotune/analyzer/utils/AnalyzerConstants.java @@ -531,4 +531,20 @@ private BooleanString() { } } + + public static final class VersionConstants { + public static final class APIVersionConstants { + public static final String CURRENT_CREATE_EXPERIMENT_VERSION = "v1.0"; + public static final String CURRENT_UPDATE_RESULTS_VERSION = "v1.0"; + public static final String CURRENT_LIST_RECOMMENDATIONS_VERSION = "v2.0"; + public static final String CURRENT_UPDATE_RECOMMENDATIONS_VERSION = "v2.0"; + private APIVersionConstants() { + + } + } + public static final String CURRENT_KRUIZE_OBJECT_VERSION = "v1.0"; + private VersionConstants() { + + } + } }