Merge pull request #30571 from yardenshoham/exec-no-output

feat: error out when post-renderer produces no output
pull/30582/head
Matt Farina 7 months ago committed by GitHub
commit bff495510d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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-renderer %q produced empty output", p.binaryPath)
}
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…
Cancel
Save