@ -36,8 +36,11 @@ import (
"helm.sh/helm/v3/pkg/repo"
)
const outputFlag = "output"
const postRenderFlag = "post-renderer"
const (
outputFlag = "output"
postRenderFlag = "post-renderer"
postRenderArgsFlag = "post-renderer-args"
)
func addValueOptionsFlags ( f * pflag . FlagSet , v * values . Options ) {
f . StringSliceVarP ( & v . ValueFiles , "values" , "f" , [ ] string { } , "specify values in a YAML file or a URL (can specify multiple)" )
@ -110,31 +113,83 @@ func (o *outputValue) Set(s string) error {
}
func bindPostRenderFlag ( cmd * cobra . Command , varRef * postrender . PostRenderer ) {
cmd . Flags ( ) . Var ( & postRenderer { varRef } , postRenderFlag , "the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path" )
p := & postRendererOptions { varRef , "" , [ ] string { } }
cmd . Flags ( ) . Var ( & postRendererString { p } , postRenderFlag , "the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path" )
cmd . Flags ( ) . Var ( & postRendererArgsSlice { p } , postRenderArgsFlag , "an argument to the post-renderer (can specify multiple)" )
}
type postRenderer struct {
type postRenderer Options struct {
renderer * postrender . PostRenderer
binaryPath string
args [ ] string
}
type postRendererString struct {
options * postRendererOptions
}
func ( p postRenderer ) String ( ) string {
return "exec"
func ( p * postRenderer String ) String ( ) string {
return p . options . binaryPath
}
func ( p postRenderer ) Type ( ) string {
return "post renderer "
func ( p * postRenderer String ) Type ( ) string {
return "post RendererString "
}
func ( p postRenderer ) Set ( s string ) error {
if s == "" {
func ( p * postRendererString ) Set ( val string ) error {
if val == "" {
return nil
}
pr , err := postrender . NewExec ( s )
p . options . binaryPath = val
pr , err := postrender . NewExec ( p . options . binaryPath , p . options . args ... )
if err != nil {
return err
}
* p . renderer = pr
* p . options . renderer = pr
return nil
}
type postRendererArgsSlice struct {
options * postRendererOptions
}
func ( p * postRendererArgsSlice ) String ( ) string {
return "[" + strings . Join ( p . options . args , "," ) + "]"
}
func ( p * postRendererArgsSlice ) Type ( ) string {
return "postRendererArgsSlice"
}
func ( p * postRendererArgsSlice ) Set ( val string ) error {
// a post-renderer defined by a user may accept empty arguments
p . options . args = append ( p . options . args , val )
if p . options . binaryPath == "" {
return nil
}
// overwrite if already create PostRenderer by `post-renderer` flags
pr , err := postrender . NewExec ( p . options . binaryPath , p . options . args ... )
if err != nil {
return err
}
* p . options . renderer = pr
return nil
}
func ( p * postRendererArgsSlice ) Append ( val string ) error {
p . options . args = append ( p . options . args , val )
return nil
}
func ( p * postRendererArgsSlice ) Replace ( val [ ] string ) error {
p . options . args = val
return nil
}
func ( p * postRendererArgsSlice ) GetSlice ( ) [ ] string {
return p . options . args
}
func compVersionFlag ( chartRef string , toComplete string ) ( [ ] string , cobra . ShellCompDirective ) {