Skip to content

Commit b41a3cd

Browse files
committed
WIP: create tmp files in HOME when using snap
1 parent 9a0be2e commit b41a3cd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Diff for: pkg/minikube/command/kic_runner.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"os"
2525
"os/exec"
2626
"path"
27+
"path/filepath"
2728
"runtime"
2829
"strconv"
2930
"strings"
@@ -185,7 +186,11 @@ func (k *kicRunner) Copy(f assets.CopyableFile) error {
185186
}
186187
}
187188
klog.Infof("%s (temp): %s --> %s (%d bytes)", k.ociBin, src, dst, f.GetLength())
188-
tf, err := ioutil.TempFile("", "tmpf-memory-asset")
189+
tmpFolder := ""
190+
if isSnapBinary() {
191+
tmpFolder = os.Getenv("HOME")
192+
}
193+
tf, err := ioutil.TempFile(tmpFolder, "tmpf-memory-asset")
189194
if err != nil {
190195
return errors.Wrap(err, "creating temporary file")
191196
}
@@ -197,6 +202,15 @@ func (k *kicRunner) Copy(f assets.CopyableFile) error {
197202
return k.copy(tf.Name(), dst)
198203
}
199204

205+
func isSnapBinary() bool {
206+
ex, err := os.Executable()
207+
if err != nil {
208+
return false
209+
}
210+
exPath := filepath.Dir(ex)
211+
return strings.Contains(exPath, "snap")
212+
}
213+
200214
func (k *kicRunner) copy(src string, dst string) error {
201215
fullDest := fmt.Sprintf("%s:%s", k.nameOrID, dst)
202216
if k.ociBin == oci.Podman {

0 commit comments

Comments
 (0)