Skip to content

Commit

Permalink
Merge branch 'main' into fix-azure-aks-example
Browse files Browse the repository at this point in the history
  • Loading branch information
james03160927 authored Dec 15, 2024
2 parents 77b75d8 + 810156e commit c8dae83
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Read the [Gruntwork contribution guidelines](https://gruntwork.notion.site/Grunt
- [ ] Run the relevant tests successfully, including pre-commit checks.
- [ ] Ensure any 3rd party code adheres with our [license policy](https://www.notion.so/gruntwork/Gruntwork-licenses-and-open-source-usage-policy-f7dece1f780341c7b69c1763f22b1378) or delete this line if its not applicable.
- [ ] Include release notes. If this PR is backward incompatible, include a migration guide.
- [ ] Make a plan for release of the functionality in this PR. If it delivers value to an end user, you are responsible for ensuring it is released promptly, and correctly. If you are not a maintainer, you are responsible for finding a maintainer to do this for you.

## Release Notes (draft)

Expand Down
3 changes: 3 additions & 0 deletions modules/helm/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ func RenderRemoteTemplateE(t testing.TestingT, options *Options, chartURL string

// ... and add the helm chart name, the remote repo and chart URL at the end
args = append(args, releaseName, "--repo", chartURL)
if options.Version != "" {
args = append(args, "--version", options.Version)
}

// Finally, call out to helm template command
return RunHelmCommandAndGetStdOutE(t, options, "template", args...)
Expand Down
15 changes: 9 additions & 6 deletions modules/helm/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestRemoteChartRender(t *testing.T) {
remoteChartSource = "https://charts.bitnami.com/bitnami"
remoteChartName = "nginx"
remoteChartVersion = "13.2.24"
registry = "registry-1.docker.io"
)

t.Parallel()
Expand All @@ -42,11 +43,12 @@ func TestRemoteChartRender(t *testing.T) {
options := &Options{
SetValues: map[string]string{
"image.repository": remoteChartName,
"image.registry": "",
"image.registry": registry,
"image.tag": remoteChartVersion,
},
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
Logger: logger.Discard,
Version: remoteChartVersion,
}

// Run RenderTemplate to render the template and capture the output. Note that we use the version without `E`, since
Expand All @@ -62,10 +64,10 @@ func TestRemoteChartRender(t *testing.T) {
require.Equal(t, namespaceName, deployment.Namespace)

// Finally, we verify the deployment pod template spec is set to the expected container image value
expectedContainerImage := remoteChartName + ":" + remoteChartVersion
expectedContainerImage := registry + "/" + remoteChartName + ":" + remoteChartVersion
deploymentContainers := deployment.Spec.Template.Spec.Containers
require.Equal(t, len(deploymentContainers), 1)
require.Equal(t, deploymentContainers[0].Image, expectedContainerImage)
require.Equal(t, expectedContainerImage, deploymentContainers[0].Image)
}

// Test that we can dump all the manifest locally a remote chart (e.g bitnami/nginx)
Expand All @@ -81,15 +83,15 @@ func TestRemoteChartRenderDiff(t *testing.T) {

initialSnapshot := t.TempDir()
updatedSnapshot := t.TempDir()
renderChartDump(t, "5.0.0", initialSnapshot)
output := renderChartDump(t, "5.1.0", updatedSnapshot)
renderChartDump(t, "13.2.20", initialSnapshot)
output := renderChartDump(t, "13.2.24", updatedSnapshot)

options := &Options{
Logger: logger.Default,
SnapshotPath: initialSnapshot,
}
// diff in: spec.initContainers.preserve-logs-symlinks.imag, spec.containers.nginx.image, tls certificates
require.Equal(t, 5, DiffAgainstSnapshot(t, options, output, "nginx"))
require.Equal(t, 4, DiffAgainstSnapshot(t, options, output, "nginx"))
}

// render chart dump and return the rendered output
Expand All @@ -111,6 +113,7 @@ func renderChartDump(t *testing.T, remoteChartVersion, snapshotDir string) strin
},
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
Logger: logger.Discard,
Version: remoteChartVersion,
}

// Run RenderTemplate to render the template and capture the output. Note that we use the version without `E`, since
Expand Down

0 comments on commit c8dae83

Please sign in to comment.