@ -116,8 +116,8 @@ func (o *outputValue) Set(s string) error {
func bindPostRenderFlag ( cmd * cobra . Command , varRef * postrender . PostRenderer ) {
func bindPostRenderFlag ( cmd * cobra . Command , varRef * postrender . PostRenderer ) {
p := & postRendererOptions { varRef , "" , [ ] string { } }
p := & postRendererOptions { varRef , "" , [ ] string { } }
cmd . Flags ( ) . Var ( & postRenderer ExecFla g{ 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 ( & postRenderer Strin g{ 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 ( & postRendererArgs Flag { p } , postRenderArgsFlag , "the args to an executable to be used for post rendering. (can specify multiple)" )
cmd . Flags ( ) . Var ( & postRendererArgs Slice { p } , postRenderArgsFlag , "the args to an executable to be used for post rendering. (can specify multiple)" )
}
}
type postRendererOptions struct {
type postRendererOptions struct {
@ -126,24 +126,24 @@ type postRendererOptions struct {
args [ ] string
args [ ] string
}
}
type postRenderer ExecFla g struct {
type postRenderer Strin g struct {
options * postRendererOptions
options * postRendererOptions
}
}
func ( p postRendererExecFla g) String ( ) string {
func ( p * postRendererStrin g) String ( ) string {
return ""
return p . options . binaryPath
}
}
func ( p postRendererExecFla g) Type ( ) string {
func ( p * postRendererStrin g) Type ( ) string {
return "post renderer-exec "
return "post RendererString "
}
}
func ( p postRendererExecFlag ) Set ( s string ) error {
func ( p * postRendererString ) Set ( val string ) error {
if s == "" {
if val == "" {
return nil
return nil
}
}
p . options . binaryPath = s
p . options . binaryPath = val
pr , err := postrender . NewExec WithArgs ( p . options . binaryPath , p . options . args )
pr , err := postrender . NewExec ( p . options . binaryPath , p . options . args ... )
if err != nil {
if err != nil {
return err
return err
}
}
@ -151,37 +151,46 @@ func (p postRendererExecFlag) Set(s string) error {
return nil
return nil
}
}
type postRendererArgs Flag struct {
type postRendererArgs Slice struct {
options * postRendererOptions
options * postRendererOptions
}
}
func ( p postRendererArgsFlag ) String ( ) string {
func ( p * postRendererArgsSlice ) String ( ) string {
return " "
return " [" + strings . Join ( p . options . args , "," ) + "] "
}
}
func ( p postRendererArgsFlag ) Type ( ) string {
func ( p * postRendererArgsSlice ) Type ( ) string {
return "post renderer-args "
return "post RendererArgsSlice "
}
}
func ( p postRendererArgsFlag ) Set ( s string ) error {
func ( p * postRendererArgsSlice ) Set ( val string ) error {
if s == "" {
if val == "" || p . option s. binaryPath == "" {
return nil
return nil
}
}
p . options . args = append ( p . options . args , s )
p . options . args = append ( p . options . args , val )
// skip if postRenderFlag not set or parsed
// overwrite if already create PostRenderer by `post-renderer` flags
if len ( p . options . binaryPath ) == 0 {
pr , err := postrender . NewExec ( p . options . binaryPath , p . options . args ... )
return nil
}
// update if already create PostRenderer
pr , err := postrender . NewExecWithArgs ( p . options . binaryPath , p . options . args )
if err != nil {
if err != nil {
return err
return err
}
}
* p . options . renderer = pr
* p . options . renderer = pr
return nil
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 ) {
func compVersionFlag ( chartRef string , toComplete string ) ( [ ] string , cobra . ShellCompDirective ) {
chartInfo := strings . Split ( chartRef , "/" )
chartInfo := strings . Split ( chartRef , "/" )
if len ( chartInfo ) != 2 {
if len ( chartInfo ) != 2 {