-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
47 lines (42 loc) · 858 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
41
42
43
44
45
46
47
package main
import (
"github.com/docker/go-plugins-helpers/network"
"github.com/urfave/cli"
"github.com/yunify/docker-plugin-hostnic/driver"
"github.com/yunify/docker-plugin-hostnic/log"
"os"
)
const (
version = "0.1"
)
func main() {
var flagDebug = cli.BoolFlag{
Name: "debug, d",
Usage: "enable debugging",
}
app := cli.NewApp()
app.Name = "hostnic"
app.Usage = "Docker Host Nic Network Plugin"
app.Version = version
app.Flags = []cli.Flag{
flagDebug,
}
app.Action = Run
app.Run(os.Args)
}
// Run initializes the driver
func Run(ctx *cli.Context) {
if ctx.Bool("debug") {
log.SetLevel("debug")
}
log.Info("Run %s", ctx.App.Name)
d, err := driver.New()
if err == nil {
h := network.NewHandler(d)
err = h.ServeUnix("root", "hostnic")
}
if err != nil {
log.Fatal("Run app error: %s", err.Error())
os.Exit(1)
}
}