mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
feat: error out when post-renderer produces no output
When the templating post-renderer produces no output, something went wrong so we error out. Signed-off-by: Yarden Shoham <git@yardenshoham.com>
This commit is contained in:
parent
2cda65d444
commit
f475f3e1fd
2 changed files with 21 additions and 0 deletions
|
|
@ -64,6 +64,12 @@ func (p *execRender) Run(renderedManifests *bytes.Buffer) (*bytes.Buffer, error)
|
|||
return nil, errors.Wrapf(err, "error while running command %s. error output:\n%s", p.binaryPath, stderr.String())
|
||||
}
|
||||
|
||||
// If the binary returned almost nothing, it's likely that it didn't
|
||||
// successfully render anything
|
||||
if len(bytes.TrimSpace(postRendered.Bytes())) == 0 {
|
||||
return nil, errors.Errorf("post render binary %s did not produce any output %s", p.binaryPath, postRendered.String())
|
||||
}
|
||||
|
||||
return postRendered, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,21 @@ func TestExecRun(t *testing.T) {
|
|||
is.Contains(output.String(), "BARTEST")
|
||||
}
|
||||
|
||||
func TestExecRunWithNoOutput(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
// the actual Run test uses a basic sed example, so skip this test on windows
|
||||
t.Skip("skipping on windows")
|
||||
}
|
||||
is := assert.New(t)
|
||||
testpath := setupTestingScript(t)
|
||||
|
||||
renderer, err := NewExec(testpath)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = renderer.Run(bytes.NewBufferString(""))
|
||||
is.Error(err)
|
||||
}
|
||||
|
||||
func TestNewExecWithOneArgsRun(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
// the actual Run test uses a basic sed example, so skip this test on windows
|
||||
|
|
|
|||
Loading…
Reference in a new issue