Skip to content

Commit 810156e

Browse files
authored
Merge pull request #1486 from gruntwork-io/fix-render-remote-template
Fixing the TestRemoteChartRender Unit Test failure by pecifing remote chart version
2 parents 1389227 + 16160ea commit 810156e

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

modules/helm/template.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ func RenderRemoteTemplateE(t testing.TestingT, options *Options, chartURL string
110110

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

114117
// Finally, call out to helm template command
115118
return RunHelmCommandAndGetStdOutE(t, options, "template", args...)

modules/helm/template_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func TestRemoteChartRender(t *testing.T) {
2727
remoteChartSource = "https://charts.bitnami.com/bitnami"
2828
remoteChartName = "nginx"
2929
remoteChartVersion = "13.2.24"
30+
registry = "registry-1.docker.io"
3031
)
3132

3233
t.Parallel()
@@ -42,11 +43,12 @@ func TestRemoteChartRender(t *testing.T) {
4243
options := &Options{
4344
SetValues: map[string]string{
4445
"image.repository": remoteChartName,
45-
"image.registry": "",
46+
"image.registry": registry,
4647
"image.tag": remoteChartVersion,
4748
},
4849
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
4950
Logger: logger.Discard,
51+
Version: remoteChartVersion,
5052
}
5153

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

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

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

8284
initialSnapshot := t.TempDir()
8385
updatedSnapshot := t.TempDir()
84-
renderChartDump(t, "5.0.0", initialSnapshot)
85-
output := renderChartDump(t, "5.1.0", updatedSnapshot)
86+
renderChartDump(t, "13.2.20", initialSnapshot)
87+
output := renderChartDump(t, "13.2.24", updatedSnapshot)
8688

8789
options := &Options{
8890
Logger: logger.Default,
8991
SnapshotPath: initialSnapshot,
9092
}
9193
// diff in: spec.initContainers.preserve-logs-symlinks.imag, spec.containers.nginx.image, tls certificates
92-
require.Equal(t, 5, DiffAgainstSnapshot(t, options, output, "nginx"))
94+
require.Equal(t, 4, DiffAgainstSnapshot(t, options, output, "nginx"))
9395
}
9496

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

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

0 commit comments

Comments
 (0)