コード例 #1
0
ファイル: extpoint.go プロジェクト: contiv/docker
// 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
}
コード例 #2
0
ファイル: manager.go プロジェクト: ilkka/docker
// 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
}
コード例 #3
0
ファイル: store.go プロジェクト: thinkingo/docker
// 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
}
コード例 #4
0
ファイル: manager.go プロジェクト: mtanlee/docker
// 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
}
コード例 #5
0
ファイル: legacy.go プロジェクト: movicha/docker
// 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
}
コード例 #6
0
ファイル: store.go プロジェクト: SUSE/docker.mirror
// 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
}