forked from machine-drivers/docker-machine-driver-xhyve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (33 loc) · 872 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
"os"
"github.com/docker/machine/libmachine/drivers/plugin"
"github.com/zchee/docker-machine-driver-xhyve/xhyve"
hyperkit "github.com/zchee/libhyperkit"
)
func main() {
if len(os.Args) >= 2 && os.Args[1] == "xhyve" {
runXhyve()
} else {
plugin.RegisterDriver(xhyve.NewDriver("", ""))
}
}
func runXhyve() {
done := make(chan bool)
ptyCh := make(chan string)
args := os.Args[1:] // Technically we only need 2:, but a bug in hooklift/xhyve requires one arg in the beginning
go func() {
if err := hyperkit.Run(args, ptyCh); err != nil {
fmt.Println(err)
}
done <- true
}()
if os.Args[len(os.Args)-1] != "-M" {
fmt.Printf("Waiting on a pseudo-terminal to be ready... ")
pty := <-ptyCh
fmt.Printf("done\n")
fmt.Printf("Hook up your terminal emulator to %s in order to connect to your VM\n", pty)
}
<-done
}