當前位置: 首頁>>代碼示例>>Golang>>正文


Golang driverapi.ErrActiveRegistration函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。