-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add version-check command for vendored helm charts (#1018)
* Add version-check command for vendored helm charts * Provide additional information in version check return. Return map of requirements rather than list
- Loading branch information
Showing
5 changed files
with
291 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,3 +278,102 @@ repositories: | |
assert.NoError(t, err) | ||
assert.Contains(t, string(chartContent), `version: 11.12.1`) | ||
} | ||
|
||
func TestChartsVersionCheck(t *testing.T) { | ||
tempDir := t.TempDir() | ||
c, err := InitChartfile(filepath.Join(tempDir, Filename)) | ||
require.NoError(t, err) | ||
|
||
err = c.Add([]string{"stable/[email protected]"}, "") | ||
assert.NoError(t, err) | ||
|
||
// Having multiple versions of the same chart should only return one update | ||
err = c.Add([]string{"stable/[email protected]:old"}, "") | ||
assert.NoError(t, err) | ||
|
||
chartVersions, err := c.VersionCheck("") | ||
assert.NoError(t, err) | ||
|
||
// stable/prometheus is deprecated so only the 11.12.1 should ever be returned as latest | ||
latestPrometheusChartVersion := ChartSearchVersion{ | ||
Name: "stable/prometheus", | ||
Version: "11.12.1", | ||
AppVersion: "2.20.1", | ||
Description: "DEPRECATED Prometheus is a monitoring system and time series database.", | ||
} | ||
stableExpected := RequiresVersionInfo{ | ||
Name: "stable/prometheus", | ||
Directory: "", | ||
CurrentVersion: "11.12.0", | ||
UsingLatestVersion: false, | ||
LatestVersion: latestPrometheusChartVersion, | ||
LatestMatchingMajorVersion: latestPrometheusChartVersion, | ||
LatestMatchingMinorVersion: latestPrometheusChartVersion, | ||
} | ||
oldExpected := RequiresVersionInfo{ | ||
Name: "stable/prometheus", | ||
Directory: "old", | ||
CurrentVersion: "11.11.0", | ||
UsingLatestVersion: false, | ||
LatestVersion: latestPrometheusChartVersion, | ||
LatestMatchingMajorVersion: latestPrometheusChartVersion, | ||
LatestMatchingMinorVersion: ChartSearchVersion{ | ||
Name: "stable/prometheus", | ||
Version: "11.11.1", | ||
AppVersion: "2.19.0", | ||
Description: "Prometheus is a monitoring system and time series database.", | ||
}, | ||
} | ||
assert.Equal(t, 2, len(chartVersions)) | ||
assert.Equal(t, stableExpected, chartVersions["stable/[email protected]"]) | ||
assert.Equal(t, oldExpected, chartVersions["stable/[email protected]"]) | ||
} | ||
|
||
func TestVersionCheckWithConfig(t *testing.T) { | ||
tempDir := t.TempDir() | ||
c, err := InitChartfile(filepath.Join(tempDir, Filename)) | ||
require.NoError(t, err) | ||
|
||
// Don't want to commit credentials so we just verify the "private" repo reference will make | ||
// use of this helm config since the InitChartfile does not have a reference to it. | ||
require.NoError(t, os.WriteFile(filepath.Join(tempDir, "helmConfig.yaml"), []byte(` | ||
apiVersion: "" | ||
generated: "0001-01-01T00:00:00Z" | ||
repositories: | ||
- caFile: "" | ||
certFile: "" | ||
insecure_skip_tls_verify: false | ||
keyFile: "" | ||
name: private | ||
pass_credentials_all: false | ||
password: "" | ||
url: https://charts.helm.sh/stable | ||
username: "" | ||
`), 0644)) | ||
c.Manifest.Requires = append(c.Manifest.Requires, Requirement{ | ||
Chart: "private/prometheus", | ||
Version: "11.12.0", | ||
}) | ||
|
||
chartVersions, err := c.VersionCheck(filepath.Join(tempDir, "helmConfig.yaml")) | ||
assert.NoError(t, err) | ||
|
||
// stable/prometheus is deprecated so only the 11.12.1 should ever be returned as latest | ||
latestPrometheusChartVersion := ChartSearchVersion{ | ||
Name: "private/prometheus", | ||
Version: "11.12.1", | ||
AppVersion: "2.20.1", | ||
Description: "DEPRECATED Prometheus is a monitoring system and time series database.", | ||
} | ||
expected := RequiresVersionInfo{ | ||
Name: "private/prometheus", | ||
Directory: "", | ||
CurrentVersion: "11.12.0", | ||
UsingLatestVersion: false, | ||
LatestVersion: latestPrometheusChartVersion, | ||
LatestMatchingMajorVersion: latestPrometheusChartVersion, | ||
LatestMatchingMinorVersion: latestPrometheusChartVersion, | ||
} | ||
assert.Equal(t, 1, len(chartVersions)) | ||
assert.Equal(t, expected, chartVersions["private/[email protected]"]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.