Skip to content

Commit

Permalink
Merge pull request #95 from utilitywarehouse/discard-kustomize-pipe
Browse files Browse the repository at this point in the history
discard the contents of the kustomize pipe before calling Wait()
  • Loading branch information
ribbybibby authored Jan 31, 2020
2 parents 2603150 + 8122e9b commit 9484efd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package kube
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
Expand Down Expand Up @@ -142,18 +143,19 @@ func (c *Client) Apply(path, namespace string, dryRun, prune, kustomize bool, pr
if kustomize {
cmdStr = "kustomize build " + path + " | " + strings.Join(args, " ")
kustomizeCmd := exec.Command("kustomize", "build", path)
pipe, err := kustomizeCmd.StdoutPipe()
kustomizeStdout, err := kustomizeCmd.StdoutPipe()
if err != nil {
return cmdStr, "", err
}
kubectlCmd.Stdin = pipe
kubectlCmd.Stdin = kustomizeStdout

err = kustomizeCmd.Start()
if err != nil {
fmt.Printf("%s", err)
return cmdStr, "", err
}
defer func() {
io.Copy(ioutil.Discard, kustomizeStdout)
err = kustomizeCmd.Wait()
if err != nil {
fmt.Printf("%s", err)
Expand Down

0 comments on commit 9484efd

Please sign in to comment.