diff --git a/pluginInterface/v1/plugin.go b/pluginInterface/v1/plugin.go index c9c8c7fb..bed84829 100644 --- a/pluginInterface/v1/plugin.go +++ b/pluginInterface/v1/plugin.go @@ -1,7 +1,6 @@ package plugin import ( - "github.com/Masterminds/semver/v3" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hcldec" "github.com/zclconf/go-cty/cty" @@ -24,7 +23,7 @@ type Plugin struct { // "text", "plugin_a", etc. Name string // version of the plugin `Kind Name` that is provided by the current binary - Version semver.Version + Version Version // Specification of the `config` block for this plugin // If nil - providing a `config Kind Name` is an error ConfigSpec hcldec.Spec @@ -36,7 +35,7 @@ type Args struct { // Specifies which kind, name and version of plugin to execute Kind string Name string - Version semver.Version + Version Version // Result of decoding a config block with ConfigSpec Config cty.Value diff --git a/pluginInterface/v1/semver.go b/pluginInterface/v1/semver.go new file mode 100644 index 00000000..7109847b --- /dev/null +++ b/pluginInterface/v1/semver.go @@ -0,0 +1,23 @@ +package plugin + +import "github.com/Masterminds/semver/v3" + +// semver.Version doesn't implement MarshalBinary/UnmarshalBinary required for +// gob (which is required by net/rpc, which is required by go-plugin). +// This is a temporary workaround, I expect they are going to add these methods +// after [my PR](https://github.com/Masterminds/semver/pull/228) is accepted + +type Version semver.Version + +func (v Version) MarshalBinary() ([]byte, error) { + return semver.Version(v).MarshalText() +} + +func (v *Version) UnmarshalBinary(data []byte) error { + return (*semver.Version)(v).UnmarshalText(data) +} + +// Returns the wrapped `semver.Version`. +func (v *Version) Cast() *semver.Version { + return (*semver.Version)(v) +}