store memory assets in home dir when using snap
parent
92511decd0
commit
b28c1ec4f6
|
@ -24,6 +24,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -185,7 +186,18 @@ func (k *kicRunner) Copy(f assets.CopyableFile) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
klog.Infof("%s (temp): %s --> %s (%d bytes)", k.ociBin, src, dst, f.GetLength())
|
klog.Infof("%s (temp): %s --> %s (%d bytes)", k.ociBin, src, dst, f.GetLength())
|
||||||
tf, err := ioutil.TempFile("", "tmpf-memory-asset")
|
tmpFolder := ""
|
||||||
|
|
||||||
|
// Snap only allows an application to see its own files in /tmp, making Docker unable to copy memory assets
|
||||||
|
// https://github.com/kubernetes/minikube/issues/10020
|
||||||
|
if isSnapBinary() {
|
||||||
|
home, err := os.UserHomeDir()
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "detecting home dir")
|
||||||
|
}
|
||||||
|
tmpFolder = os.Getenv(home)
|
||||||
|
}
|
||||||
|
tf, err := ioutil.TempFile(tmpFolder, "tmpf-memory-asset")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "creating temporary file")
|
return errors.Wrap(err, "creating temporary file")
|
||||||
}
|
}
|
||||||
|
@ -197,6 +209,15 @@ func (k *kicRunner) Copy(f assets.CopyableFile) error {
|
||||||
return k.copy(tf.Name(), dst)
|
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 {
|
func (k *kicRunner) copy(src string, dst string) error {
|
||||||
fullDest := fmt.Sprintf("%s:%s", k.nameOrID, dst)
|
fullDest := fmt.Sprintf("%s:%s", k.nameOrID, dst)
|
||||||
if k.ociBin == oci.Podman {
|
if k.ociBin == oci.Podman {
|
||||||
|
|
Loading…
Reference in New Issue