mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-10-04 14:44:26 +00:00
infrakit: Use the new HyperKit go package
Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
@@ -5,24 +5,16 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/infrakit/pkg/cli"
|
||||
"github.com/docker/infrakit/pkg/discovery"
|
||||
"github.com/docker/infrakit/pkg/plugin/metadata"
|
||||
instance_plugin "github.com/docker/infrakit/pkg/rpc/instance"
|
||||
metadata_plugin "github.com/docker/infrakit/pkg/rpc/metadata"
|
||||
instance_spi "github.com/docker/infrakit/pkg/spi/instance"
|
||||
"github.com/docker/infrakit/pkg/template"
|
||||
)
|
||||
|
||||
const (
|
||||
// Default path when used with Docker for Mac
|
||||
defaultHyperKit = "/Applications/Docker.app/Contents/MacOS/com.docker.hyperkit"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -31,9 +23,6 @@ var (
|
||||
|
||||
// Revision is the build source control revision.
|
||||
Revision = "Unspecified"
|
||||
|
||||
// Default path to the VPNKit socket on Docker for Mac
|
||||
defaultVPNKitSock = "Library/Containers/com.docker.docker/Data/s50"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -44,34 +33,21 @@ func main() {
|
||||
}
|
||||
|
||||
defaultVMDir := filepath.Join(getHome(), ".infrakit/hyperkit-vms")
|
||||
defaultVPNKitSock = path.Join(getHome(), defaultVPNKitSock)
|
||||
|
||||
name := cmd.Flags().String("name", "instance-hyperkit", "Plugin name to advertise for discovery")
|
||||
logLevel := cmd.Flags().Int("log", cli.DefaultLogLevel, "Logging level. 0 is least verbose. Max is 5")
|
||||
|
||||
vmDir := cmd.Flags().String("vm-dir", defaultVMDir, "Directory where to store VM state")
|
||||
hyperkit := cmd.Flags().String("hyperkit", defaultHyperKit, "Path to HyperKit executable")
|
||||
hyperkit := cmd.Flags().String("hyperkit", "", "Path to HyperKit executable")
|
||||
|
||||
vpnkitSock := cmd.Flags().String("vpnkit-sock", defaultVPNKitSock, "Path to VPNKit UNIX domain socket")
|
||||
vpnkitSock := cmd.Flags().String("vpnkit-sock", "auto", "Path to VPNKit UNIX domain socket")
|
||||
|
||||
cmd.RunE = func(c *cobra.Command, args []string) error {
|
||||
opts := template.Options{
|
||||
SocketDir: discovery.Dir(),
|
||||
}
|
||||
thyper, err := template.NewTemplate("str://"+hyperkitArgs, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tkern, err := template.NewTemplate("str://"+hyperkitKernArgs, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
os.MkdirAll(*vmDir, os.ModePerm)
|
||||
|
||||
cli.SetLogLevel(*logLevel)
|
||||
cli.RunPlugin(*name,
|
||||
instance_plugin.PluginServer(NewHyperKitPlugin(*vmDir, *hyperkit, *vpnkitSock, thyper, tkern)),
|
||||
instance_plugin.PluginServer(NewHyperKitPlugin(*vmDir, *hyperkit, *vpnkitSock)),
|
||||
metadata_plugin.PluginServer(metadata.NewPluginFromData(
|
||||
map[string]interface{}{
|
||||
"version": Version,
|
||||
|
Reference in New Issue
Block a user