mirror of https://github.com/hashicorp/packer
With the next minor version of the SDK, we'll introduce experimental protobuf support for serialising data between Packer and plugins. This is exposed to plugins under the `PACKER_PLUGIN_PB` environment variable, which is automatically set when all the plugins able to be loaded by Packer (i.e. the highest version compatible with Packer's loading process) are capable to communicate with Protobuf. If any plugin uses version 5.0 of the API, we default to using Gob, thereby maintaining retro-compatibility will all the existing plugins.protobuf_and_gob_support
parent
7c16133e5c
commit
bda59b4d0a
@ -0,0 +1,25 @@
|
||||
package packer
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/rpc"
|
||||
)
|
||||
|
||||
// MayUseProtobuf is meant to look into the environment to prohibit protobuf
|
||||
//
|
||||
// If the PACKER_USE_PB environment variable is unset or set to a non-empty
|
||||
// string that is neither "0", "no", or "false", Packer will choose dynamically
|
||||
// which protocol to use when communicating with plugins.
|
||||
//
|
||||
// If however it is explicitly set to one of the false values, Packer will not
|
||||
// attempt to detect which protocol to use, and instead will forcibly use gob.
|
||||
func MayUseProtobuf() bool {
|
||||
usePB := os.Getenv(rpc.PackerUsePBEnvVar)
|
||||
switch usePB {
|
||||
case "0", "no", "false":
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
Loading…
Reference in new issue