diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/plugin/discovery/find.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/plugin/discovery/find.go | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/vendor/github.com/hashicorp/terraform/plugin/discovery/find.go b/vendor/github.com/hashicorp/terraform/plugin/discovery/find.go index f5bc4c1..f053312 100644 --- a/vendor/github.com/hashicorp/terraform/plugin/discovery/find.go +++ b/vendor/github.com/hashicorp/terraform/plugin/discovery/find.go | |||
@@ -3,6 +3,7 @@ package discovery | |||
3 | import ( | 3 | import ( |
4 | "io/ioutil" | 4 | "io/ioutil" |
5 | "log" | 5 | "log" |
6 | "os" | ||
6 | "path/filepath" | 7 | "path/filepath" |
7 | "strings" | 8 | "strings" |
8 | ) | 9 | ) |
@@ -59,7 +60,6 @@ func findPluginPaths(kind string, dirs []string) []string { | |||
59 | fullName := item.Name() | 60 | fullName := item.Name() |
60 | 61 | ||
61 | if !strings.HasPrefix(fullName, prefix) { | 62 | if !strings.HasPrefix(fullName, prefix) { |
62 | log.Printf("[DEBUG] skipping %q, not a %s", fullName, kind) | ||
63 | continue | 63 | continue |
64 | } | 64 | } |
65 | 65 | ||
@@ -71,6 +71,12 @@ func findPluginPaths(kind string, dirs []string) []string { | |||
71 | continue | 71 | continue |
72 | } | 72 | } |
73 | 73 | ||
74 | // Check that the file we found is usable | ||
75 | if !pathIsFile(absPath) { | ||
76 | log.Printf("[ERROR] ignoring non-file %s", absPath) | ||
77 | continue | ||
78 | } | ||
79 | |||
74 | log.Printf("[DEBUG] found %s %q", kind, fullName) | 80 | log.Printf("[DEBUG] found %s %q", kind, fullName) |
75 | ret = append(ret, filepath.Clean(absPath)) | 81 | ret = append(ret, filepath.Clean(absPath)) |
76 | continue | 82 | continue |
@@ -83,7 +89,13 @@ func findPluginPaths(kind string, dirs []string) []string { | |||
83 | continue | 89 | continue |
84 | } | 90 | } |
85 | 91 | ||
86 | log.Printf("[WARNING] found legacy %s %q", kind, fullName) | 92 | // Check that the file we found is usable |
93 | if !pathIsFile(absPath) { | ||
94 | log.Printf("[ERROR] ignoring non-file %s", absPath) | ||
95 | continue | ||
96 | } | ||
97 | |||
98 | log.Printf("[WARN] found legacy %s %q", kind, fullName) | ||
87 | 99 | ||
88 | ret = append(ret, filepath.Clean(absPath)) | 100 | ret = append(ret, filepath.Clean(absPath)) |
89 | } | 101 | } |
@@ -92,6 +104,17 @@ func findPluginPaths(kind string, dirs []string) []string { | |||
92 | return ret | 104 | return ret |
93 | } | 105 | } |
94 | 106 | ||
107 | // Returns true if and only if the given path refers to a file or a symlink | ||
108 | // to a file. | ||
109 | func pathIsFile(path string) bool { | ||
110 | info, err := os.Stat(path) | ||
111 | if err != nil { | ||
112 | return false | ||
113 | } | ||
114 | |||
115 | return !info.IsDir() | ||
116 | } | ||
117 | |||
95 | // ResolvePluginPaths takes a list of paths to plugin executables (as returned | 118 | // ResolvePluginPaths takes a list of paths to plugin executables (as returned |
96 | // by e.g. FindPluginPaths) and produces a PluginMetaSet describing the | 119 | // by e.g. FindPluginPaths) and produces a PluginMetaSet describing the |
97 | // referenced plugins. | 120 | // referenced plugins. |