From 51e7a7dad06a20de48de03abc44f7950df8121de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sun, 10 May 2020 14:12:09 +0200 Subject: [PATCH] The podman cp command is not in podman-remote So use podman exec stdin/stdout as a workaround. --- pkg/minikube/command/kic_runner.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/command/kic_runner.go b/pkg/minikube/command/kic_runner.go index 667b3cb1e6c5..18134e2a150f 100644 --- a/pkg/minikube/command/kic_runner.go +++ b/pkg/minikube/command/kic_runner.go @@ -24,7 +24,9 @@ import ( "os" "os/exec" "path" + "runtime" "strconv" + "strings" "time" "github.com/golang/glog" @@ -202,8 +204,27 @@ func (k *kicRunner) chmod(dst string, perm string) error { // Podman cp command doesn't match docker and doesn't have -a func copyToPodman(src string, dest string) error { - if out, err := oci.PrefixCmd(exec.Command(oci.Podman, "cp", src, dest)).CombinedOutput(); err != nil { - return errors.Wrapf(err, "podman copy %s into %s, output: %s", src, dest, string(out)) + if runtime.GOOS == "linux" { + cmd := oci.PrefixCmd(exec.Command(oci.Podman, "cp", src, dest)) + glog.Infof("Run: %v", cmd) + if out, err := cmd.CombinedOutput(); err != nil { + return errors.Wrapf(err, "podman copy %s into %s, output: %s", src, dest, string(out)) + } + } else { + file, err := os.Open(src) + if err != nil { + return err + } + defer file.Close() + parts := strings.Split(dest, ":") + container := parts[0] + path := parts[1] + cmd := exec.Command(oci.Podman, "exec", "-it", container, "tee", path) + cmd.Stdin = file + glog.Infof("Run: %v", cmd) + if err := cmd.Run(); err != nil { + return errors.Wrapf(err, "podman copy %s into %s", src, dest) + } } return nil }