Skip to content

Commit

Permalink
chore: pull Helm test version from Renovate (#5087)
Browse files Browse the repository at this point in the history
  • Loading branch information
rainest committed Nov 6, 2023
1 parent 498f38b commit a2d1fca
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ require (
github.com/sourcegraph/conc v0.3.0
github.com/spf13/cast v1.5.1 // indirect
github.com/ssgelm/cookiejarparser v1.0.1 // indirect
github.com/tidwall/gjson v1.17.0 // indirect
github.com/tidwall/gjson v1.17.0
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
Expand Down
47 changes: 45 additions & 2 deletions test/internal/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,45 @@ import (
"fmt"
"os"
"time"

"github.com/tidwall/gjson"
"sigs.k8s.io/yaml"
)

// -----------------------------------------------------------------------------
// Dependency manifest reader
// -----------------------------------------------------------------------------

const dependencyFilePath = "../../.github/test_dependencies.yaml"

// GetDependencyVersion returns the version of a dependency specified by the dependency tracker file given a YAML path.
func GetDependencyVersion(path string) (string, error) {
source, err := os.Open(dependencyFilePath)
if err != nil {
return "", fmt.Errorf("could not open %s: %w", dependencyFilePath, err)
}
defer source.Close()
info, err := source.Stat()
if err != nil {
return "", fmt.Errorf("could not stat %s: %w", dependencyFilePath, err)
}

raw := make([]byte, info.Size())
_, err = source.Read(raw)
if err != nil {
return "", fmt.Errorf("could not read %s: %w", dependencyFilePath, err)
}
deps, err := yaml.YAMLToJSON(raw)
if err != nil {
return "", fmt.Errorf("could not parse %s: %w", dependencyFilePath, err)
}
found := gjson.GetBytes(deps, path)
if !found.Exists() {
return "", fmt.Errorf("path %s not found in %s", path, dependencyFilePath)
}
return found.String(), nil
}

// -----------------------------------------------------------------------------
// Testing Helpers for Environment Variables Overrides
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -74,12 +111,18 @@ func KongEffectiveVersion() string {
return os.Getenv("TEST_KONG_EFFECTIVE_VERSION")
}

const helmChartDependencyPath = "integration.helm.kong"

// KongHelmChartVersion is the 'kong' helm chart version to use in tests.
func KongHelmChartVersion() string {
var err error
v := os.Getenv("TEST_KONG_HELM_CHART_VERSION")
if v == "" {
fmt.Println("ERROR: missing required TEST_KONG_HELM_CHART_VERSION")
os.Exit(1)
v, err = GetDependencyVersion(helmChartDependencyPath)
if err != nil {
fmt.Println(fmt.Printf("WARN: could not get kong/kong chart dependency version: %s", err))
fmt.Println("WARN: will use whatever kong/kong chart version is installed locally")
}
}
return v
}
Expand Down

0 comments on commit a2d1fca

Please sign in to comment.