From b8cf24874eeacc97094854c80325a72b52e9f786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yannig=20Perr=C3=A9?= Date: Wed, 1 Apr 2020 09:14:36 +0200 Subject: [PATCH] Read stdin only one time (fix for #7002). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yannig Perré --- pkg/cli/values/options.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/cli/values/options.go b/pkg/cli/values/options.go index e6ad71767..0dd09c619 100644 --- a/pkg/cli/values/options.go +++ b/pkg/cli/values/options.go @@ -104,10 +104,20 @@ func mergeMaps(a, b map[string]interface{}) map[string]interface{} { return out } +var stdin []byte = nil + // readFile load a file from stdin, the local directory, or a remote file with a url. func readFile(filePath string, p getter.Providers) ([]byte, error) { if strings.TrimSpace(filePath) == "-" { - return ioutil.ReadAll(os.Stdin) + var err error = nil + // Read stdin only if stdin is empty + // Avoid a bug where we read multiple times stdin when using + // upgrade with --install option + // Fix: https://github.com/helm/helm/issues/7002 + if stdin == nil { + stdin, err = ioutil.ReadAll(os.Stdin) + } + return stdin, err } u, _ := url.Parse(filePath)