From 55b43077673de272f6aeae99afee1c2dbf5d8050 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Mon, 4 Feb 2019 19:01:28 -0500 Subject: [PATCH] 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. --- helper/schema/schema.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/helper/schema/schema.go b/helper/schema/schema.go index ac1c1eb42..31b236072 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -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.