From b0b0b5aae4884f1548e32fc2ff97ae6b01849476 Mon Sep 17 00:00:00 2001 From: JanhaviAlekar Date: Tue, 18 Jun 2024 18:21:06 +0530 Subject: [PATCH] Checking CIVersion at start Signed-off-by: JanhaviAlekar --- .../server/pkg/chaos_infrastructure/service.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go index e705c7bc355..b3d03df4d06 100644 --- a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go +++ b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go @@ -908,16 +908,17 @@ func fetchLatestVersion(versions map[int]string) int { // updateVersionFormat converts string array to int by removing decimal points, 1.0.0 will be returned as 100, 0.1.0 will be returned as 10, 0.0.1 will be returned as 1 func updateVersionFormat(str string) (int, error) { + if str == CIVersion { + return 0, nil + } var versionInt int versionSlice := strings.Split(str, ".") for i, val := range versionSlice { - if val != CIVersion { - x, err := strconv.Atoi(val) - if err != nil { - return -1, err - } - versionInt += x * int(math.Pow(10, float64(2-i))) + x, err := strconv.Atoi(val) + if err != nil { + return -1, err } + versionInt += x * int(math.Pow(10, float64(2-i))) } return versionInt, nil }