本文整理汇总了Golang中github.com/docker/libnetwork/driverapi.ErrActiveRegistration函数的典型用法代码示例。如果您正苦于以下问题:Golang ErrActiveRegistration函数的具体用法?Golang ErrActiveRegistration怎么用?Golang ErrActiveRegistration使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ErrActiveRegistration函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: RegisterDriver
// RegisterDriver registers the network driver when it gets discovered.
func (r *DrvRegistry) RegisterDriver(ntype string, driver driverapi.Driver, capability driverapi.Capability) error {
if strings.TrimSpace(ntype) == "" {
return fmt.Errorf("network type string cannot be empty")
}
r.Lock()
_, ok := r.drivers[ntype]
r.Unlock()
if ok {
return driverapi.ErrActiveRegistration(ntype)
}
if r.dfn != nil {
if err := r.dfn(ntype, driver, capability); err != nil {
return err
}
}
dData := &driverData{driver, capability}
r.Lock()
r.drivers[ntype] = dData
r.Unlock()
return nil
}
开发者ID:CWSpear,项目名称:docker,代码行数:28,代码来源:drvregistry.go
示例2: RegisterDriver
func (c *controller) RegisterDriver(networkType string, driver driverapi.Driver) error {
c.Lock()
defer c.Unlock()
if _, ok := c.drivers[networkType]; ok {
return driverapi.ErrActiveRegistration(networkType)
}
c.drivers[networkType] = driver
return nil
}
开发者ID:colebrumley,项目名称:docker,代码行数:9,代码来源:controller.go
示例3: RegisterDriver
func (c *controller) RegisterDriver(networkType string, driver driverapi.Driver, capability driverapi.Capability) error {
if !config.IsValidName(networkType) {
return ErrInvalidName(networkType)
}
c.Lock()
if _, ok := c.drivers[networkType]; ok {
c.Unlock()
return driverapi.ErrActiveRegistration(networkType)
}
c.drivers[networkType] = &driverData{driver, capability}
c.Unlock()
return nil
}
开发者ID:wangxujun163163,项目名称:libnetwork,代码行数:15,代码来源:controller.go
示例4: RegisterDriver
func (c *controller) RegisterDriver(networkType string, driver driverapi.Driver, capability driverapi.Capability) error {
c.Lock()
if !config.IsValidName(networkType) {
c.Unlock()
return ErrInvalidName(networkType)
}
if _, ok := c.drivers[networkType]; ok {
c.Unlock()
return driverapi.ErrActiveRegistration(networkType)
}
c.drivers[networkType] = &driverData{driver, capability}
if c.cfg == nil {
c.Unlock()
return nil
}
opt := make(map[string]interface{})
for _, label := range c.cfg.Daemon.Labels {
if strings.HasPrefix(label, netlabel.DriverPrefix+"."+networkType) {
opt[netlabel.Key(label)] = netlabel.Value(label)
}
}
if capability.DataScope == datastore.GlobalScope && c.validateGlobalStoreConfig() {
opt[netlabel.KVProvider] = c.cfg.GlobalStore.Client.Provider
opt[netlabel.KVProviderURL] = c.cfg.GlobalStore.Client.Address
}
if capability.DataScope == datastore.LocalScope {
localStoreConfig := c.getLocalStoreConfig(c.cfg)
opt[netlabel.KVProvider] = localStoreConfig.Client.Provider
opt[netlabel.KVProviderURL] = localStoreConfig.Client.Address
opt[netlabel.KVProviderConfig] = localStoreConfig.Client.Config
}
c.Unlock()
if len(opt) != 0 {
if err := driver.Config(opt); err != nil {
return err
}
}
return nil
}
开发者ID:wcwxyz,项目名称:libnetwork,代码行数:46,代码来源:controller.go
示例5: RegisterDriver
func (c *controller) RegisterDriver(networkType string, driver driverapi.Driver, capability driverapi.Capability) error {
if !config.IsValidName(networkType) {
return ErrInvalidName(networkType)
}
c.Lock()
if _, ok := c.drivers[networkType]; ok {
c.Unlock()
return driverapi.ErrActiveRegistration(networkType)
}
dData := &driverData{driver, capability}
c.drivers[networkType] = dData
hd := c.discovery
c.Unlock()
if hd != nil {
c.pushNodeDiscovery(dData, hd.Fetch(), true)
}
return nil
}
开发者ID:maaquib,项目名称:docker,代码行数:21,代码来源:controller.go
示例6: RegisterIpamDriver
func (c *controller) RegisterIpamDriver(name string, driver ipamapi.Ipam) error {
if !config.IsValidName(name) {
return ErrInvalidName(name)
}
c.Lock()
_, ok := c.ipamDrivers[name]
c.Unlock()
if ok {
return driverapi.ErrActiveRegistration(name)
}
locAS, glbAS, err := driver.GetDefaultAddressSpaces()
if err != nil {
return fmt.Errorf("ipam driver %s failed to return default address spaces: %v", name, err)
}
c.Lock()
c.ipamDrivers[name] = &ipamData{driver: driver, defaultLocalAddressSpace: locAS, defaultGlobalAddressSpace: glbAS}
c.Unlock()
log.Debugf("Registering ipam provider: %s", name)
return nil
}
开发者ID:maaquib,项目名称:docker,代码行数:23,代码来源:controller.go
注:本文中的github.com/docker/libnetwork/driverapi.ErrActiveRegistration函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论