FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix render error not being propogated · 51coder/helm@7b9dc71 · GitHub

Repository navigation

Commit 7b9dc71

Browse files
committed
Fix render error not being propogated
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
1 parent 722042e commit 7b9dc71

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎pkg/action/action_test.go‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,20 @@ func withSampleTemplates() chartOption {
230230
}
231231
}
232232

233+
func withSampleIncludingIncorrectTemplates() chartOption {
234+
return func(opts *chartOptions) {
235+
sampleTemplates := []*chart.File{
236+
// This adds basic templates and partials.
237+
{Name: "templates/goodbye", Data: []byte("goodbye: world")},
238+
{Name: "templates/empty", Data: []byte("")},
239+
{Name: "templates/incorrect", Data: []byte("{{ .Values.bad.doh }}")},
240+
{Name: "templates/with-partials", Data: []byte(`hello: {{ template "_planet" . }}`)},
241+
{Name: "templates/partials/_planet", Data: []byte(`{{define "_planet"}}Earth{{end}}`)},
242+
}
243+
opts.Templates = append(opts.Templates, sampleTemplates...)
244+
}
245+
}
246+
233247
func withMultipleManifestTemplate() chartOption {
234248
return func(opts *chartOptions) {
235249
sampleTemplates := []*chart.File{

‎pkg/action/install.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values
460460
}
461461

462462
if err2 != nil {
463-
return hs, b, "", err
463+
return hs, b, "", err2
464464
}
465465

466466
// NOTES.txt gets rendered like all the other files, but because it's not a hook nor a resource,

‎pkg/action/install_test.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,21 @@ func TestInstallRelease_DryRun(t *testing.T) {
240240
is.Equal(res.Info.Description, "Dry run complete")
241241
}
242242

243+
func TestInstallReleaseIncorrectTemplate_DryRun(t *testing.T) {
244+
is := assert.New(t)
245+
instAction := installAction(t)
246+
instAction.DryRun = true
247+
vals := map[string]interface{}{}
248+
_, err := instAction.Run(buildChart(withSampleIncludingIncorrectTemplates()), vals)
249+
expectedErr := "\"hello/templates/incorrect\" at <.Values.bad.doh>: nil pointer evaluating interface {}.doh"
250+
if err == nil {
251+
t.Fatalf("Install should fail containing error: %s", expectedErr)
252+
}
253+
if err != nil {
254+
is.Contains(err.Error(), expectedErr)
255+
}
256+
}
257+
243258
func TestInstallRelease_NoHooks(t *testing.T) {
244259
is := assert.New(t)
245260
instAction := installAction(t)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL