当前位置: 首页>>代码示例>>Golang>>正文


Golang skel.PluginMain函数代码示例

本文整理汇总了Golang中github.com/appc/cni/pkg/skel.PluginMain函数的典型用法代码示例。如果您正苦于以下问题:Golang PluginMain函数的具体用法?Golang PluginMain怎么用?Golang PluginMain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PluginMain函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	var (
		justVersion      bool
		cniNet           bool
		cniIpam          bool
		address          string
		meshAddress      string
		logLevel         string
		noMulticastRoute bool
	)

	flag.BoolVar(&justVersion, "version", false, "print version and exit")
	flag.BoolVar(&cniNet, "cni-net", false, "act as a CNI network plugin")
	flag.BoolVar(&cniIpam, "cni-ipam", false, "act as a CNI IPAM plugin")
	flag.StringVar(&logLevel, "log-level", "info", "logging level (debug, info, warning, error)")
	flag.StringVar(&address, "socket", "/run/docker/plugins/weave.sock", "socket on which to listen")
	flag.StringVar(&meshAddress, "meshsocket", "/run/docker/plugins/weavemesh.sock", "socket on which to listen in mesh mode")
	flag.BoolVar(&noMulticastRoute, "no-multicast-route", false, "deprecated (this is now the default)")

	flag.Parse()

	if justVersion {
		fmt.Printf("weave plugin %s\n", version)
		os.Exit(0)
	}

	common.SetLogLevel(logLevel)

	weave := weaveapi.NewClient(os.Getenv("WEAVE_HTTP_ADDR"), Log)

	switch {
	case cniIpam || strings.HasSuffix(os.Args[0], "weave-ipam"):
		i := ipamplugin.NewIpam(weave)
		cni.PluginMain(i.CmdAdd, i.CmdDel)
		os.Exit(0)
	case cniNet || strings.HasSuffix(os.Args[0], "weave-net"):
		n := netplugin.NewCNIPlugin(weave)
		cni.PluginMain(n.CmdAdd, n.CmdDel)
		os.Exit(0)
	}

	// API 1.21 is the first version that supports docker network commands
	dockerClient, err := docker.NewVersionedClientFromEnv("1.21")
	if err != nil {
		Log.Fatalf("unable to connect to docker: %s", err)
	}

	Log.Println("Weave plugin", version, "Command line options:", os.Args[1:])
	if noMulticastRoute {
		Log.Warning("--no-multicast-route option has been removed; multicast is off by default")
	}
	Log.Info(dockerClient.Info())

	err = run(dockerClient, weave, address, meshAddress)
	if err != nil {
		Log.Fatal(err)
	}
}
开发者ID:n054,项目名称:weave,代码行数:58,代码来源:main.go

示例2: main

func main() {
	if len(os.Args) > 1 && os.Args[1] == "daemon" {
		runDaemon()
	} else {
		skel.PluginMain(cmdAdd, cmdDel)
	}
}
开发者ID:NeilW,项目名称:cni,代码行数:7,代码来源:main.go

示例3: main

func main() {
	skel.PluginMain(cmdAdd, cmdDel)
}
开发者ID:sinfomicien,项目名称:rkt,代码行数:3,代码来源:ptp.go


注:本文中的github.com/appc/cni/pkg/skel.PluginMain函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。