Skip to content

Commit

Permalink
Using Go's tmpDir instead of shell's mkdir
Browse files Browse the repository at this point in the history
  • Loading branch information
pamiel committed Apr 4, 2019
1 parent a8c27ef commit cbac289
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"strings"
"strconv"
"bufio"
"io/ioutil"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -304,12 +305,19 @@ func Status(chart string) HelmStatus {

// Fetch ...
func Fetch(chart string, version string) string {
tempDir, err := ioutil.TempDir("", "spray-")
if err != nil {
printError(err)
}
defer os.RemoveAll(tempDir)

var command string
if version != "" {
command = "mkdir /tmp/$$ && helm fetch " + chart + " --destination /tmp/$$ --version " + version + " && ls /tmp/$$ && mv /tmp/$$/* . && rmdir /tmp/$$"
command = "helm fetch " + chart + " --destination " + tempDir + " --version " + version
} else {
command = "mkdir /tmp/$$ && helm fetch " + chart + " --destination /tmp/$$ && ls /tmp/$$ && mv /tmp/$$/* . && rmdir /tmp/$$"
command = "helm fetch " + chart + " --destination " + tempDir
}
command = command + " && ls " + tempDir + " && cp " + tempDir + "/* ."

cmd := exec.Command("sh", "-c", command)
cmdOutput := &bytes.Buffer{}
Expand Down

0 comments on commit cbac289

Please sign in to comment.