Skip to content

Commit

Permalink
ToOptions change for latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
huseyinbabal committed Oct 10, 2023
1 parent 257d429 commit 909ccb7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/helmx/helm_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package helmx
import (
"encoding/json"
"os/exec"
"regexp"
"strings"
"testing"

Expand All @@ -23,9 +24,11 @@ type versionsResponse struct {
}

// 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:]
}

Expand Down Expand Up @@ -54,9 +57,10 @@ func InstallChart(t *testing.T, params InstallChartParams) func(t *testing.T) {
latestVersion := latestVersion(t, versionsOutput)
t.Logf("Found version: %s", latestVersion)

t.Logf("Installing chart %s with command %s", params.Name, params.ToOptions())
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)
Expand Down

0 comments on commit 909ccb7

Please sign in to comment.