Skip to content

Commit

Permalink
dynamic increase version
Browse files Browse the repository at this point in the history
  • Loading branch information
leiicamundi committed Apr 12, 2024
1 parent 25d0cc0 commit 6257243
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/src/upgrade_eks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ func (suite *UpgradeEKSTestSuite) TestUpgradeEKS() {
)

// upgrade the cluster
suite.varTf["kubernetes_version"] = "1.29"
var errIncVersion error
suite.varTf["kubernetes_version"], errIncVersion = utils.IncrementMinorVersionTwoParts(suite.kubeVersion)
suite.Require().NoError(errIncVersion)

suite.sugaredLogger.Infow(fmt.Sprintf("Upgrading the EKS cluster to v%s using aws sdk", suite.varTf["kubernetes_version"]), "extraVars", suite.varTf)
errUpdate := utils.UpgradeEKS(context.Background(), eksSvc, suite.clusterName, suite.varTf["kubernetes_version"].(string))
suite.Require().NoError(errUpdate)
Expand Down
20 changes: 20 additions & 0 deletions test/src/utils/helper.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package utils

import (
"fmt"
"os"
"strconv"
"strings"
)

func GetEnv(key, fallback string) string {
Expand All @@ -11,3 +14,20 @@ func GetEnv(key, fallback string) string {
}
return value
}

func IncrementMinorVersionTwoParts(version string) (string, error) {
parts := strings.Split(version, ".")

if len(parts) != 2 {
return "", fmt.Errorf("invalid version format, expected 2 parts got %d", len(parts))
}

minor, err := strconv.Atoi(parts[1])
if err != nil {
return "", err
}

newVersion := fmt.Sprintf("%s.%d", parts[0], minor+1)

return newVersion, nil
}

0 comments on commit 6257243

Please sign in to comment.