func FindPlugins() ([]*Plugin, error) {
	var plugins []*Plugin
	homePath, err := fetchHomeDir()
	if err != nil {
		return nil, fmt.Errorf("fetch home path: %w", err)
	}

	pluginsCacheDirPath := filepath.Join(homePath, conftestDir, pluginsCacheDir)
	if _, err := os.Stat(pluginsCacheDirPath); os.IsNotExist(err) {
		// No plugins, so just return the empty slice
		return plugins, nil
	}

	files, err := ioutil.ReadDir(pluginsCacheDirPath)
	if err != nil {
		return nil, fmt.Errorf("read plugin cache directory: %w", err)
	}

	for _, file := range files {
		if file.IsDir() {
			path := filepath.Join(pluginsCacheDirPath, file.Name())
			plugin, err := LoadPlugin(path)
			if err != nil {
				return nil, fmt.Errorf("load plugin from cache directory: %w", err)
			}

			plugins = append(plugins, plugin)
		} else if file.Mode()&os.ModeSymlink != 0 {
			// go-getter symlinks if it is a plugin on the local file system.
			symlinkPath := filepath.Join(pluginsCacheDirPath, file.Name())
			path, err := os.Readlink(symlinkPath)
			if err != nil {
				return nil, fmt.Errorf("resolve plugin symlink: %w", err)
			}

			plugin, err := LoadPlugin(path)
			if err != nil {
				return nil, fmt.Errorf("load plugin from cache directory: %w", err)
			}

			plugins = append(plugins, plugin)
		}
	}

	return plugins, nil
}
// FindPlugins returns a list of all plugins available on the local file system.
FindPlugins returns a list of all plugins available on the local file system.
// FindPlugins returns a list of all plugins available on the local file system .
func FindPlugins() ([]*Plugin, error) {
	var plugins []*Plugin
	homePath, err := fetchHomeDir()
	if err != nil {
		return nil, fmt.Errorf("fetch home path: %w", err)
	}
	pluginsCacheDirPath := filepath.Join(homePath, conftestDir, pluginsCacheDir)
	if _, err := os.Stat(pluginsCacheDirPath); os.IsNotExist(err) {
		return plugins, nil
	}
	files, err := ioutil.ReadDir(pluginsCacheDirPath)
	if err != nil {
		return nil, fmt.Errorf("read plugin cache directory: %w", err)
	}
	for _, file := range files {
		if file.IsDir() {
			path := filepath.Join(pluginsCacheDirPath, file.Name())
			plugin, err := LoadPlugin(path)
			if err != nil {
				return nil, fmt.Errorf("load plugin from cache directory: %w", err)
			}
			plugins = append(plugins, plugin)
		} else if file.Mode()&os.ModeSymlink != 0 {
			symlinkPath := filepath.Join(pluginsCacheDirPath, file.Name())
			path, err := os.Readlink(symlinkPath)
			if err != nil {
				return nil, fmt.Errorf("resolve plugin symlink: %w", err)
			}
			plugin, err := LoadPlugin(path)
			if err != nil {
				return nil, fmt.Errorf("load plugin from cache directory: %w", err)
			}
			plugins = append(plugins, plugin)
		}
	}
	return plugins, nil
}
func FindPlugins ( ) ( [ ] * Plugin , error ) { var plugins [ ] * Plugin homePath , err := fetchHomeDir ( ) if err != nil { return nil , fmt . Errorf ( " " , err ) } pluginsCacheDirPath := filepath . Join ( homePath , conftestDir , pluginsCacheDir ) if _ , err := os . Stat ( pluginsCacheDirPath ) ; os . IsNotExist ( err ) { return plugins , nil } files , err := ioutil . ReadDir ( pluginsCacheDirPath ) if err != nil { return nil , fmt . Errorf ( " " , err ) } for _ , file := range files { if file . IsDir ( ) { path := filepath . Join ( pluginsCacheDirPath , file . Name ( ) ) plugin , err := LoadPlugin ( path ) if err != nil { return nil , fmt . Errorf ( " " , err ) } plugins = append ( plugins , plugin ) } else if file . Mode ( ) & os . ModeSymlink != 0 { symlinkPath := filepath . Join ( pluginsCacheDirPath , file . Name ( ) ) path , err := os . Readlink ( symlinkPath ) if err != nil { return nil , fmt . Errorf ( " " , err ) } plugin , err := LoadPlugin ( path ) if err != nil { return nil , fmt . Errorf ( " " , err ) } plugins = append ( plugins , plugin ) } } return plugins , nil }
FindPlugins returns a list of all plugins available on the local file system.
FindPlugins returns a list of all plugins available on the local file system .
// No plugins, so just return the empty slice // go-getter symlinks if it is a plugin on the local file system.