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


Golang plugins.GetAll函数代码示例

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


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

示例1: GetAllDrivers

// GetAllDrivers lists all the registered drivers
func GetAllDrivers() ([]volume.Driver, error) {
	plugins, err := plugins.GetAll(extName)
	if err != nil {
		return nil, err
	}
	var ds []volume.Driver

	drivers.Lock()
	defer drivers.Unlock()

	for _, d := range drivers.extensions {
		ds = append(ds, d)
	}

	for _, p := range plugins {
		ext, ok := drivers.extensions[p.Name]
		if ok {
			continue
		}

		ext = NewVolumeDriver(p.Name, p.Client)
		drivers.extensions[p.Name] = ext
		ds = append(ds, ext)
	}
	return ds, nil
}
开发者ID:contiv,项目名称:docker,代码行数:27,代码来源:extpoint.go

示例2: FindWithCapability

// FindWithCapability returns a list of plugins matching the given capability.
func FindWithCapability(capability string) ([]Plugin, error) {
	handleLegacy := true
	result := make([]Plugin, 0, 1)
	if manager != nil {
		handleLegacy = manager.handleLegacy
		manager.RLock()
		defer manager.RUnlock()
	pluginLoop:
		for _, p := range manager.plugins {
			for _, typ := range p.PluginObj.Manifest.Interface.Types {
				if typ.Capability != capability || typ.Prefix != "docker" {
					continue pluginLoop
				}
			}
			result = append(result, p)
		}
	}
	if handleLegacy {
		pl, err := plugins.GetAll(capability)
		if err != nil {
			return nil, fmt.Errorf("legacy plugin: %v", err)
		}
		for _, p := range pl {
			if _, ok := manager.nameToID[p.Name()]; !ok {
				result = append(result, p)
			}
		}
	}
	return result, nil
}
开发者ID:ilkka,项目名称:docker,代码行数:31,代码来源:manager.go

示例3: GetAllByCap

// GetAllByCap returns a list of enabled plugins matching the given capability.
func (ps *Store) GetAllByCap(capability string) ([]plugingetter.CompatPlugin, error) {
	result := make([]plugingetter.CompatPlugin, 0, 1)

	/* Daemon start always calls plugin.Init thereby initializing a store.
	 * So store on experimental builds can never be nil, even while
	 * handling legacy plugins. However, there are legacy plugin unit
	 * tests where the volume subsystem directly talks with the plugin,
	 * bypassing the daemon. For such tests, this check is necessary.
	 */
	if ps != nil {
		ps.RLock()
		result = ps.getAllByCap(capability)
		ps.RUnlock()
	}

	// Lookup with legacy model
	if allowV1PluginsFallback {
		pl, err := plugins.GetAll(capability)
		if err != nil {
			return nil, fmt.Errorf("legacy plugin: %v", err)
		}
		for _, p := range pl {
			result = append(result, p)
		}
	}
	return result, nil
}
开发者ID:thinkingo,项目名称:docker,代码行数:28,代码来源:store.go

示例4: FindWithCapability

// FindWithCapability returns a list of plugins matching the given capability.
func FindWithCapability(capability string) ([]Plugin, error) {
	result := make([]Plugin, 0, 1)

	/* Daemon start always calls plugin.Init thereby initializing a manager.
	 * So manager on experimental builds can never be nil, even while
	 * handling legacy plugins. However, there are legacy plugin unit
	 * tests where volume subsystem directly talks with the plugin,
	 * bypassing the daemon. For such tests, this check is necessary.*/
	if manager != nil {
		manager.RLock()
		for _, p := range manager.plugins {
			for _, typ := range p.PluginObj.Manifest.Interface.Types {
				if strings.EqualFold(typ.Capability, capability) && typ.Prefix == "docker" {
					result = append(result, p)
					break
				}
			}
		}
		manager.RUnlock()
	}

	// Lookup with legacy model.
	if allowV1PluginsFallback {
		pl, err := plugins.GetAll(capability)
		if err != nil {
			return nil, fmt.Errorf("legacy plugin: %v", err)
		}
		for _, p := range pl {
			result = append(result, p)
		}
	}
	return result, nil
}
开发者ID:mtanlee,项目名称:docker,代码行数:34,代码来源:manager.go

示例5: FindWithCapability

// FindWithCapability returns a list of plugins matching the given capability.
func FindWithCapability(capability string) ([]CompatPlugin, error) {
	pl, err := plugins.GetAll(capability)
	if err != nil {
		return nil, err
	}
	result := make([]CompatPlugin, len(pl))
	for i, p := range pl {
		result[i] = p
	}
	return result, nil
}
开发者ID:movicha,项目名称:docker,代码行数:12,代码来源:legacy.go

示例6: GetAllByCap

// GetAllByCap returns a list of plugins matching the given capability.
func (ps Store) GetAllByCap(capability string) ([]getter.CompatPlugin, error) {
	pl, err := plugins.GetAll(capability)
	if err != nil {
		return nil, err
	}
	result := make([]getter.CompatPlugin, len(pl))
	for i, p := range pl {
		result[i] = p
	}
	return result, nil
}
开发者ID:SUSE,项目名称:docker.mirror,代码行数:12,代码来源:store.go


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