本文整理汇总了Golang中github.com/docker/libnetwork/ipamapi.Callback.GetPluginGetter方法的典型用法代码示例。如果您正苦于以下问题:Golang Callback.GetPluginGetter方法的具体用法?Golang Callback.GetPluginGetter怎么用?Golang Callback.GetPluginGetter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/docker/libnetwork/ipamapi.Callback
的用法示例。
在下文中一共展示了Callback.GetPluginGetter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Init
// Init registers a remote ipam when its plugin is activated
func Init(cb ipamapi.Callback, l, g interface{}) error {
newPluginHandler := func(name string, client *plugins.Client) {
a := newAllocator(name, client)
if cps, err := a.(*allocator).getCapabilities(); err == nil {
if err := cb.RegisterIpamDriverWithCapabilities(name, a, cps); err != nil {
logrus.Errorf("error registering remote ipam driver %s due to %v", name, err)
}
} else {
logrus.Infof("remote ipam driver %s does not support capabilities", name)
logrus.Debug(err)
if err := cb.RegisterIpamDriver(name, a); err != nil {
logrus.Errorf("error registering remote ipam driver %s due to %v", name, err)
}
}
}
// Unit test code is unaware of a true PluginStore. So we fall back to v1 plugins.
handleFunc := plugins.Handle
if pg := cb.GetPluginGetter(); pg != nil {
handleFunc = pg.Handle
activePlugins := pg.GetAllManagedPluginsByCap(ipamapi.PluginEndpointType)
for _, ap := range activePlugins {
newPluginHandler(ap.Name(), ap.Client())
}
}
handleFunc(ipamapi.PluginEndpointType, newPluginHandler)
return nil
}