diff options
author | Radek Simko <radek.simko@gmail.com> | 2017-08-10 14:38:14 +0200 |
---|---|---|
committer | Radek Simko <radek.simko@gmail.com> | 2017-08-10 14:38:14 +0200 |
commit | c680a8e1622ed0f18751d9d167c836ee24f5e897 (patch) | |
tree | 864f925049d422033dd25a73bafce32b361c8827 /vendor/github.com/hashicorp/terraform/plugin/discovery/meta.go | |
parent | 38f8880ac81bfabc6d7f82e4dc89661f20fc559e (diff) | |
download | terraform-provider-statuscake-c680a8e1622ed0f18751d9d167c836ee24f5e897.tar.gz terraform-provider-statuscake-c680a8e1622ed0f18751d9d167c836ee24f5e897.tar.zst terraform-provider-statuscake-c680a8e1622ed0f18751d9d167c836ee24f5e897.zip |
vendor: github.com/hashicorp/terraform/...@v0.10.0
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/plugin/discovery/meta.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/plugin/discovery/meta.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/plugin/discovery/meta.go b/vendor/github.com/hashicorp/terraform/plugin/discovery/meta.go new file mode 100644 index 0000000..bdcebcb --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/plugin/discovery/meta.go | |||
@@ -0,0 +1,41 @@ | |||
1 | package discovery | ||
2 | |||
3 | import ( | ||
4 | "crypto/sha256" | ||
5 | "io" | ||
6 | "os" | ||
7 | ) | ||
8 | |||
9 | // PluginMeta is metadata about a plugin, useful for launching the plugin | ||
10 | // and for understanding which plugins are available. | ||
11 | type PluginMeta struct { | ||
12 | // Name is the name of the plugin, e.g. as inferred from the plugin | ||
13 | // binary's filename, or by explicit configuration. | ||
14 | Name string | ||
15 | |||
16 | // Version is the semver version of the plugin, expressed as a string | ||
17 | // that might not be semver-valid. | ||
18 | Version VersionStr | ||
19 | |||
20 | // Path is the absolute path of the executable that can be launched | ||
21 | // to provide the RPC server for this plugin. | ||
22 | Path string | ||
23 | } | ||
24 | |||
25 | // SHA256 returns a SHA256 hash of the content of the referenced executable | ||
26 | // file, or an error if the file's contents cannot be read. | ||
27 | func (m PluginMeta) SHA256() ([]byte, error) { | ||
28 | f, err := os.Open(m.Path) | ||
29 | if err != nil { | ||
30 | return nil, err | ||
31 | } | ||
32 | defer f.Close() | ||
33 | |||
34 | h := sha256.New() | ||
35 | _, err = io.Copy(h, f) | ||
36 | if err != nil { | ||
37 | return nil, err | ||
38 | } | ||
39 | |||
40 | return h.Sum(nil), nil | ||
41 | } | ||