Skip to content

Commit

Permalink
WIP: create tmp files in HOME when using snap
Browse files Browse the repository at this point in the history
  • Loading branch information
spowelljr committed Dec 24, 2020
1 parent 9a0be2e commit b41a3cd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/minikube/command/kic_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -185,7 +186,11 @@ func (k *kicRunner) Copy(f assets.CopyableFile) error {
}
}
klog.Infof("%s (temp): %s --> %s (%d bytes)", k.ociBin, src, dst, f.GetLength())
tf, err := ioutil.TempFile("", "tmpf-memory-asset")
tmpFolder := ""
if isSnapBinary() {
tmpFolder = os.Getenv("HOME")
}
tf, err := ioutil.TempFile(tmpFolder, "tmpf-memory-asset")
if err != nil {
return errors.Wrap(err, "creating temporary file")
}
Expand All @@ -197,6 +202,15 @@ func (k *kicRunner) Copy(f assets.CopyableFile) error {
return k.copy(tf.Name(), dst)
}

func isSnapBinary() bool {
ex, err := os.Executable()
if err != nil {
return false
}
exPath := filepath.Dir(ex)
return strings.Contains(exPath, "snap")
}

func (k *kicRunner) copy(src string, dst string) error {
fullDest := fmt.Sprintf("%s:%s", k.nameOrID, dst)
if k.ociBin == oci.Podman {
Expand Down

0 comments on commit b41a3cd

Please sign in to comment.