Merge pull request #30572 from yardenshoham/post-renderer-once

fix: error when more than one post-renderer is specified
pull/11326/merge
Robert Sirchia 7 months ago committed by GitHub
commit c95d8cefcd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -143,6 +143,9 @@ func (p *postRendererString) Set(val string) error {
if val == "" {
return nil
}
if p.options.binaryPath != "" {
return fmt.Errorf("cannot specify --post-renderer flag more than once")
}
p.options.binaryPath = val
pr, err := postrender.NewExec(p.options.binaryPath, p.options.args...)
if err != nil {

@ -20,6 +20,9 @@ import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
"helm.sh/helm/v4/pkg/action"
chart "helm.sh/helm/v4/pkg/chart/v2"
"helm.sh/helm/v4/pkg/release"
helmtime "helm.sh/helm/v4/pkg/time"
@ -93,3 +96,24 @@ func outputFlagCompletionTest(t *testing.T, cmdName string) {
}}
runTestCmd(t, tests)
}
func TestPostRendererFlagSetOnce(t *testing.T) {
cfg := action.Configuration{}
client := action.NewInstall(&cfg)
str := postRendererString{
options: &postRendererOptions{
renderer: &client.PostRenderer,
},
}
// Set the binary once
err := str.Set("echo")
require.NoError(t, err)
// Set the binary again to the same value is not ok
err = str.Set("echo")
require.Error(t, err)
// Set the binary again to a different value is not ok
err = str.Set("cat")
require.Error(t, err)
}

Loading…
Cancel
Save