diff --git a/test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go b/test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go index a02ba5df9..ec734ffdf 100644 --- a/test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go +++ b/test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go @@ -328,8 +328,7 @@ func TestCloudSlackE2E(t *testing.T) { }) params := helmx.InstallChartParams{ - // TODO(https://github.com/kubeshop/botkube/issues/1203): Update Helm chart version to the latest released one - RepoURL: "https://charts.botkube.io", + RepoURL: "https://storage.googleapis.com/botkube-latest-main-charts", RepoName: "botkube", Name: "botkube", Namespace: "botkube", diff --git a/test/helmx/helm_helpers.go b/test/helmx/helm_helpers.go index f0b073f25..3eeec83f2 100644 --- a/test/helmx/helm_helpers.go +++ b/test/helmx/helm_helpers.go @@ -1,7 +1,9 @@ package helmx import ( + "encoding/json" "os/exec" + "regexp" "strings" "testing" @@ -17,10 +19,16 @@ type InstallChartParams struct { Command string } +type versionsResponse struct { + Version string `json:"version"` +} + // ToOptions converts Command to helm install options. -func (p *InstallChartParams) ToOptions() []string { +func (p *InstallChartParams) ToOptions(version string) []string { cmd := strings.Replace(p.Command, "\n", "", -1) cmd = strings.Replace(cmd, "\\", " ", -1) + versionRegex := regexp.MustCompile(`--version (\S+)`) + cmd = versionRegex.ReplaceAllString(cmd, "--version "+version) return strings.Fields(cmd)[1:] } @@ -42,9 +50,17 @@ func InstallChart(t *testing.T, params InstallChartParams) func(t *testing.T) { t.Log(string(repoUpdateOutput)) require.NoError(t, err) - t.Logf("Installing chart %s with command %s", params.Name, params.ToOptions()) + t.Log("Finding latest version...") + cmd = exec.Command("helm", "search", "repo", params.RepoName, "--devel", "--versions", "-o", "json") // #nosec G204 + versionsOutput, err := cmd.CombinedOutput() + require.NoError(t, err) + latestVersion := latestVersion(t, versionsOutput) + t.Logf("Found version: %s", latestVersion) + + helmOpts := params.ToOptions(latestVersion) + t.Logf("Installing chart %s with command %s", params.Name, helmOpts) //nolint:gosec // this is not production code - cmd = exec.Command("helm", params.ToOptions()...) + cmd = exec.Command("helm", helmOpts...) installOutput, err := cmd.CombinedOutput() t.Log(string(installOutput)) require.NoError(t, err) @@ -59,3 +75,11 @@ func InstallChart(t *testing.T, params InstallChartParams) func(t *testing.T) { require.NoError(t, err) } } + +func latestVersion(t *testing.T, versionsOutput []byte) string { + var versions []versionsResponse + err := json.Unmarshal(versionsOutput, &versions) + require.NoError(t, err) + require.NotEmpty(t, versions) + return versions[0].Version +}