From c680a8e1622ed0f18751d9d167c836ee24f5e897 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Thu, 10 Aug 2017 14:38:14 +0200 Subject: vendor: github.com/hashicorp/terraform/...@v0.10.0 --- .../hashicorp/terraform/plugin/discovery/meta.go | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 vendor/github.com/hashicorp/terraform/plugin/discovery/meta.go (limited to 'vendor/github.com/hashicorp/terraform/plugin/discovery/meta.go') 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 @@ +package discovery + +import ( + "crypto/sha256" + "io" + "os" +) + +// PluginMeta is metadata about a plugin, useful for launching the plugin +// and for understanding which plugins are available. +type PluginMeta struct { + // Name is the name of the plugin, e.g. as inferred from the plugin + // binary's filename, or by explicit configuration. + Name string + + // Version is the semver version of the plugin, expressed as a string + // that might not be semver-valid. + Version VersionStr + + // Path is the absolute path of the executable that can be launched + // to provide the RPC server for this plugin. + Path string +} + +// SHA256 returns a SHA256 hash of the content of the referenced executable +// file, or an error if the file's contents cannot be read. +func (m PluginMeta) SHA256() ([]byte, error) { + f, err := os.Open(m.Path) + if err != nil { + return nil, err + } + defer f.Close() + + h := sha256.New() + _, err = io.Copy(h, f) + if err != nil { + return nil, err + } + + return h.Sum(nil), nil +} -- cgit v1.2.3