From 028060958b37c5c16c729a1fdceed46cadfd6c7b Mon Sep 17 00:00:00 2001 From: Navratan Lal Gupta Date: Sat, 2 Nov 2024 16:53:54 +0530 Subject: [PATCH] makes sure patch version does not contain any build or subpatch version Signed-off-by: Navratan Lal Gupta --- internal/ikubernetes/version.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/ikubernetes/version.go b/internal/ikubernetes/version.go index 2136797..795ef5c 100644 --- a/internal/ikubernetes/version.go +++ b/internal/ikubernetes/version.go @@ -44,7 +44,16 @@ func GetK8sVersion() (*string, error) { return nil, err } - k8sSemversion := k8sVersion.String() + k8sSemversionSplit := strings.Split(k8sVersion.String(), ".") + + re := regexp.MustCompile(`[^0-9]`) + result := re.ReplaceAllString(k8sSemversionSplit[2], "/") + + resultSplit := strings.Split(result, "/") + + k8sSemversionPatch := resultSplit[0] + + k8sSemversion := k8sSemversionSplit[0] + "." + k8sSemversionSplit[1] + "." + k8sSemversionPatch return &k8sSemversion, nil