Skip to content

Commit

Permalink
Cleanup mktmp func
Browse files Browse the repository at this point in the history
  • Loading branch information
Hagai Barel committed Jun 2, 2019
1 parent 4ef690b commit 9139ba8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
11 changes: 0 additions & 11 deletions pkg/utils/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utils

import (
"fmt"
"io/ioutil"
"log"
exec "os/exec"
"strings"
Expand Down Expand Up @@ -38,16 +37,6 @@ func Exec(cmd []string) (string, error) {
return string(output), nil
}

// MkRandomDir creates a new directory in the os tmp location
func MkRandomDir() string {
dir, err := ioutil.TempDir("", "")
if err != nil {
log.Fatal(err)
}

return dir
}

// AddIfNotContained adds a string to a slice if it is not contained in it and not empty
func AddIfNotContained(s []string, e string) (sout []string) {
if (!Contains(s, e)) && (e != "") {
Expand Down
7 changes: 6 additions & 1 deletion pkg/utils/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
"fmt"
"io/ioutil"
"log"
"math"
"os"
Expand Down Expand Up @@ -206,7 +207,11 @@ type DeployChartFromRepositoryOptions struct {

// DeployChartFromRepository deploys a Helm chart from a chart repository
func DeployChartFromRepository(o DeployChartFromRepositoryOptions) error {
tempDir := MkRandomDir()
tempDir, err := ioutil.TempDir("", "")
if err != nil {
return fmt.Errorf("failed to create tmp dir")
}

defer os.RemoveAll(tempDir)

if o.ReleaseName == "" {
Expand Down

0 comments on commit 9139ba8

Please sign in to comment.