// GetPluginCaseInsensitive finds the first matching plugin name case
// insensitive and returns true if it exists.
504091
func (config *Config) GetPluginCaseInsensitive(pluginName string) (Plugin, bool) {
	for name, plugin := range config.pluginsConfig.Plugins {
		if strings.EqualFold(name, pluginName) {
			return plugin, true
		}
	}

	return Plugin{}, false
}
1337667
func (s *OsdCsiServer) GetPluginInfo(
	ctx context.Context,
	req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {

	return &csi.GetPluginInfoResponse{
		Name:          csiDriverNamePrefix + s.driver.Name(),
		VendorVersion: csiDriverVersion,

		// As OSD CSI Driver matures, add here more information
		Manifest: map[string]string{
			"driver": s.driver.Name(),
		},
	}, nil
}
600653
func GetGaugePluginVersion(pluginName string) (string, error) {
	pluginProperties, err := GetPluginProperties(fmt.Sprintf("%s.json", pluginName))
	if err != nil {
		return "", fmt.Errorf("Failed to get gauge %s properties file. %s", pluginName, err)
	}
	return pluginProperties["version"].(string), nil
}
686632
func formatPluginName(str string) string {
	str = strings.Replace(str, "_", " ", -1)
	str = strings.Title(str)
	return strings.Replace(str, " ", "", -1)
}
1301779
func (c *CNIConfig) validatePlugin(ctx context.Context, pluginName, expectedVersion string) error {
	pluginPath, err := invoke.FindInPath(pluginName, c.Path)
	if err != nil {
		return err
	}

	vi, err := invoke.GetVersionInfo(ctx, pluginPath, c.exec)
	if err != nil {
		return err
	}
	for _, vers := range vi.SupportedVersions() {
		if vers == expectedVersion {
			return nil
		}
	}
	return fmt.Errorf("plugin %s does not support config version %q", pluginName, expectedVersion)
}
261225
func (c *Client) GetPluginPrivileges(name string, ctx context.Context) ([]PluginPrivilege, error) {
	resp, err := c.do("GET", "/plugins/privileges?remote="+name, doOptions{
		context: ctx,
	})
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	var pluginPrivileges []PluginPrivilege
	if err := json.NewDecoder(resp.Body).Decode(&pluginPrivileges); err != nil {
		return nil, err
	}
	return pluginPrivileges, nil
}
393980
func GetInTreeNameFromCSIName(pluginName string) (string, error) {
	if plugin, ok := inTreePlugins[pluginName]; ok {
		return plugin.GetInTreePluginName(), nil
	}
	return "", fmt.Errorf("Could not find In-Tree driver name for CSI plugin %v", pluginName)
}
731929
func (i *InitContext) Get(t Type) (interface{}, error) {
	return i.plugins.Get(t)
}
170760
func GetPluginsInstallDir(pluginName string) (string, error) {
	pluginInstallPrefixes, err := GetPluginInstallPrefixes()
	if err != nil {
		return "", err
	}

	for _, prefix := range pluginInstallPrefixes {
		if SubDirectoryExists(prefix, pluginName) {
			return prefix, nil
		}
	}
	return "", fmt.Errorf("Plugin '%s' not installed on following locations : %s", pluginName, pluginInstallPrefixes)
}
1339904
func toCaseInsensitiveValue(value interface{}) interface{} {
	switch v := value.(type) {
	case map[interface{}]interface{}:
		value = copyAndInsensitiviseMap(cast.ToStringMap(v))
	case map[string]interface{}:
		value = copyAndInsensitiviseMap(v)
	}

	return value
}
16933
func (s *OsdCsiServer) GetPluginCapabilities(
	ctx context.Context,
	req *csi.GetPluginCapabilitiesRequest,
) (*csi.GetPluginCapabilitiesResponse, error) {
	return &csi.GetPluginCapabilitiesResponse{
		Capabilities: []*csi.PluginCapability{
			&csi.PluginCapability{
				Type: &csi.PluginCapability_Service_{
					Service: &csi.PluginCapability_Service{
						Type: csi.PluginCapability_Service_CONTROLLER_SERVICE,
					},
				},
			},
			&csi.PluginCapability{
				Type: &csi.PluginCapability_VolumeExpansion_{
					VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
						Type: csi.PluginCapability_VolumeExpansion_ONLINE,
					},
				},
			},
		},
	}, nil
}
12809
func (c Config) PluginsEnabled() bool {
	return c.Bundle != nil || c.DecisionLogs != nil || c.Status != nil || len(c.Plugins) > 0
}
1285398
func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
	pm.mutex.Lock()
	defer pm.mutex.Unlock()

	if spec == nil {
		return nil, fmt.Errorf("Could not find plugin because volume spec is nil")
	}

	matchedPluginNames := []string{}
	matches := []VolumePlugin{}
	for k, v := range pm.plugins {
		if v.CanSupport(spec) {
			matchedPluginNames = append(matchedPluginNames, k)
			matches = append(matches, v)
		}
	}

	pm.refreshProbedPlugins()
	for _, plugin := range pm.probedPlugins {
		if plugin.CanSupport(spec) {
			matchedPluginNames = append(matchedPluginNames, plugin.GetPluginName())
			matches = append(matches, plugin)
		}
	}

	if len(matches) == 0 {
		return nil, fmt.Errorf("no volume plugin matched")
	}
	if len(matches) > 1 {
		return nil, fmt.Errorf("multiple volume plugins matched: %s", strings.Join(matchedPluginNames, ","))
	}
	return matches[0], nil
}
275063
func (c *Client) HasPlugin(name string) (bool, error) {
	plugins, err := c.Plugins()
	if err != nil {
		return false, nil
	}
	for _, plugin := range plugins {
		if plugin == name {
			return true, nil
		}
	}
	return false, nil
}
479188
func GetPrimaryPluginsInstallDir() (string, error) {
	gaugeHome, err := GetGaugeHomeDirectory()
	if err != nil {
		return "", err
	}
	return filepath.Join(gaugeHome, Plugins), nil
}
121711
func (n *node) FindCaseInsensitivePath(path string, fixTrailingSlash bool) ([]byte, bool) {
	return n.findCaseInsensitivePathRec(
		path,
		toLower(path),
		make([]byte, zero, len(path)+one), // preallocate enough memory for new path
		[4]byte{},                         // empty rune buffer
		fixTrailingSlash,
	)
}
653184
func CaseInsensitiveContains(s, substr string) bool {
	s, substr = strings.ToLower(s), strings.ToLower(substr)
	return strings.Contains(s, substr)
}