mirror of
https://github.com/linka-cloud/d2vm.git
synced 2024-11-22 15:56:24 +00:00
d2vm/run: hetzner: do not use sparsecat if not on linux
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
parent
96026b88ab
commit
7ee4e251e8
@ -22,6 +22,7 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
@ -194,7 +195,13 @@ func runHetzner(ctx context.Context, imgPath string, stdin io.Reader, stderr io.
|
||||
logrus.Infof("writing image to %s", vmBlockPath)
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
pr := newProgressReader(sparsecat.NewEncoder(src))
|
||||
var r io.Reader
|
||||
if runtime.GOOS == "linux" {
|
||||
r = sparsecat.NewEncoder(src)
|
||||
} else {
|
||||
r = src
|
||||
}
|
||||
pr := newProgressReader(r)
|
||||
wses.Stdin = pr
|
||||
go func() {
|
||||
tk := time.NewTicker(time.Second)
|
||||
@ -214,7 +221,13 @@ func runHetzner(ctx context.Context, imgPath string, stdin io.Reader, stderr io.
|
||||
}
|
||||
}
|
||||
}()
|
||||
if b, err := wses.CombinedOutput(fmt.Sprintf("%s -r -disable-sparse-target -of %s", sparsecatPath, vmBlockPath)); err != nil {
|
||||
var cmd string
|
||||
if runtime.GOOS == "linux" {
|
||||
cmd = fmt.Sprintf("%s -r -disable-sparse-target -of %s", sparsecatPath, vmBlockPath)
|
||||
} else {
|
||||
cmd = fmt.Sprintf("dd of=%s", vmBlockPath)
|
||||
}
|
||||
if b, err := wses.CombinedOutput(cmd); err != nil {
|
||||
return fmt.Errorf("%v: %s", err, string(b))
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user