From ffcd6bc4dcada8187db9a59141938a020907fced Mon Sep 17 00:00:00 2001 From: Alexander Sowitzki Date: Thu, 6 Jun 2019 17:18:10 +0200 Subject: [PATCH] Repair ability to read terraform output from stdin Signed-off-by: Alexander Sowitzki --- pkg/util/config/cluster.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/util/config/cluster.go b/pkg/util/config/cluster.go index 9c226d475..7a6631778 100644 --- a/pkg/util/config/cluster.go +++ b/pkg/util/config/cluster.go @@ -18,6 +18,7 @@ package config import ( "io/ioutil" + "os" "github.com/pkg/errors" @@ -108,9 +109,12 @@ func LoadKubeOneCluster(clusterCfgPath, tfOutputPath string) (*kubeoneapi.KubeOn } var tfOutput []byte - if len(tfOutputPath) > 0 { - tfOutput, err = ioutil.ReadFile(tfOutputPath) - if err != nil { + if tfOutputPath == "-" { + if tfOutput, err = ioutil.ReadAll(os.Stdin); err != nil { + return nil, errors.Wrap(err, "unable to read terraform output from stdin") + } + } else if len(tfOutputPath) > 0 { + if tfOutput, err = ioutil.ReadFile(tfOutputPath); err != nil { return nil, errors.Wrap(err, "unable to read the given terraform output file") } }