add proto5 feature flag

Add feature flag to allow special proto 5 behavior in helper/schema.
This is Meant to be used as a last resort for shim-related bugs.
This commit is contained in:
James Bardin 2019-02-04 19:01:28 -05:00
parent 81a4e705b1
commit 55b4307767
1 changed files with 22 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import (
"sort"
"strconv"
"strings"
"sync"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/terraform"
@ -32,6 +33,27 @@ const PanicOnErr = "TF_SCHEMA_PANIC_ON_ERROR"
// type used for schema package context keys
type contextKey string
var (
protoVersionMu sync.Mutex
protoVersion5 = false
)
func isProto5() bool {
protoVersionMu.Lock()
defer protoVersionMu.Unlock()
return protoVersion5
}
// SetProto5 enables a feature flag for any internal changes required required
// to work with the new plugin protocol. This should not be called by
// provider.
func SetProto5() {
protoVersionMu.Lock()
defer protoVersionMu.Unlock()
protoVersion5 = true
}
// Schema is used to describe the structure of a value.
//
// Read the documentation of the struct elements for important details.