summaryrefslogtreecommitdiff
path: root/internal/config
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2021-01-17 15:46:57 -0500
committerDave Henderson <dhenderson@gmail.com>2021-01-17 16:48:48 -0500
commitd6c72218477357bc855f700ca6134d40cd96adf0 (patch)
tree0eb5a3f593fde1aafac6988aafe5ffbe197c2568 /internal/config
parent5835d0d688525716be902297193f78227994f5bf (diff)
Inject stdin/out/err instead of always using os.Stdin/out/err
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/configfile.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/internal/config/configfile.go b/internal/config/configfile.go
index a20c95cb..9969648e 100644
--- a/internal/config/configfile.go
+++ b/internal/config/configfile.go
@@ -14,6 +14,7 @@ import (
"strings"
"time"
+ "github.com/hairyhenderson/gomplate/v3/internal/iohelpers"
"github.com/pkg/errors"
"gopkg.in/yaml.v3"
)
@@ -59,8 +60,11 @@ type Config struct {
ExtraHeaders map[string]http.Header `yaml:"-"`
// internal use only, can't be injected in YAML
- PostExecInput io.ReadWriter `yaml:"-"`
- OutWriter io.Writer `yaml:"-"`
+ PostExecInput io.Reader `yaml:"-"`
+
+ Stdin io.Reader `yaml:"-"`
+ Stdout io.Writer `yaml:"-"`
+ Stderr io.Writer `yaml:"-"`
}
var cfgContextKey = struct{}{}
@@ -452,12 +456,14 @@ func (c *Config) ApplyDefaults() {
}
if c.ExecPipe {
- c.PostExecInput = &bytes.Buffer{}
- c.OutWriter = c.PostExecInput
+ pipe := &bytes.Buffer{}
+ c.PostExecInput = pipe
c.OutputFiles = []string{"-"}
+
+ // --exec-pipe redirects standard out to the out pipe
+ c.Stdout = &iohelpers.NopCloser{Writer: pipe}
} else {
- c.PostExecInput = os.Stdin
- c.OutWriter = os.Stdout
+ c.PostExecInput = c.Stdin
}
if c.PluginTimeout == 0 {