1cee2a1415
* plugins/gRPC: fix issues with reserved keywords in response data * Add the path raw file for mock plugin * Fix panic when special paths is nil * Add tests for Listing and raw requests from plugins * Add json.Number case when decoding the status * Bump the version required for gRPC defaults * Fix test for gRPC version check
43 lines
930 B
Go
43 lines
930 B
Go
package pluginutil
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/hashicorp/go-version"
|
|
)
|
|
|
|
var (
|
|
// PluginVaultVersionEnv is the ENV name used to pass the version of the
|
|
// vault server to the plugin
|
|
PluginVaultVersionEnv = "VAULT_VERSION"
|
|
)
|
|
|
|
// GRPCSupport defaults to returning true, unless VAULT_VERSION is missing or
|
|
// it fails to meet the version constraint.
|
|
func GRPCSupport() bool {
|
|
verString := os.Getenv(PluginVaultVersionEnv)
|
|
|
|
// If the env var is empty, we fall back to netrpc for backward compatibility.
|
|
if verString == "" {
|
|
return false
|
|
}
|
|
|
|
if verString != "unknown" {
|
|
ver, err := version.NewVersion(verString)
|
|
if err != nil {
|
|
return true
|
|
}
|
|
|
|
// Due to some regressions on 0.9.2 & 0.9.3 we now require version 0.9.4
|
|
// to allow the plugin framework to default to gRPC.
|
|
constraint, err := version.NewConstraint(">= 0.9.4")
|
|
if err != nil {
|
|
return true
|
|
}
|
|
|
|
return constraint.Check(ver)
|
|
}
|
|
|
|
return true
|
|
}
|