Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.26.1 to 2.27.0. - [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases) - [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-plugin-sdk/compare/v2.26.1...v2.27.0) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
32 lines
709 B
Go
32 lines
709 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package plugin
|
|
|
|
import (
|
|
"path/filepath"
|
|
)
|
|
|
|
// Discover discovers plugins that are in a given directory.
|
|
//
|
|
// The directory doesn't need to be absolute. For example, "." will work fine.
|
|
//
|
|
// This currently assumes any file matching the glob is a plugin.
|
|
// In the future this may be smarter about checking that a file is
|
|
// executable and so on.
|
|
//
|
|
// TODO: test
|
|
func Discover(glob, dir string) ([]string, error) {
|
|
var err error
|
|
|
|
// Make the directory absolute if it isn't already
|
|
if !filepath.IsAbs(dir) {
|
|
dir, err = filepath.Abs(dir)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return filepath.Glob(filepath.Join(dir, glob))
|
|
}
|