From 72e279e6b24e714063fe61e5497197f0d777b449 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 29 Nov 2018 16:53:36 -0800 Subject: [PATCH] providers: Consistently use int64 for schema versions The rest of Terraform is still using uint64 for this in various spots, but we'll update that gradually later. We use int64 here because that matches what's used in our protobuf definition, and unsigned integers are not portable across all of the protobuf target languages anyway. --- helper/schema/shims_test.go | 4 ++-- plugin/convert/schema.go | 2 +- providers/provider.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/helper/schema/shims_test.go b/helper/schema/shims_test.go index 072c8ca7c..e3e9df745 100644 --- a/helper/schema/shims_test.go +++ b/helper/schema/shims_test.go @@ -34,7 +34,7 @@ func testApplyDiff(t *testing.T, diff *terraform.InstanceDiff) { testSchema := providers.Schema{ - Version: uint64(resource.SchemaVersion), + Version: int64(resource.SchemaVersion), Block: resourceSchemaToBlock(resource.Schema), } @@ -338,7 +338,7 @@ func TestShimResourceDiff_Timeout_diff(t *testing.T) { } testSchema := providers.Schema{ - Version: uint64(r.SchemaVersion), + Version: int64(r.SchemaVersion), Block: resourceSchemaToBlock(r.Schema), } diff --git a/plugin/convert/schema.go b/plugin/convert/schema.go index a9f0d9f7d..db879b54d 100644 --- a/plugin/convert/schema.go +++ b/plugin/convert/schema.go @@ -57,7 +57,7 @@ func protoSchemaNestedBlock(name string, b *configschema.NestedBlock) *proto.Sch // ProtoToProviderSchema takes a proto.Schema and converts it to a providers.Schema. func ProtoToProviderSchema(s *proto.Schema) providers.Schema { return providers.Schema{ - Version: uint64(s.Version), + Version: s.Version, Block: ProtoToConfigSchema(s.Block), } } diff --git a/providers/provider.go b/providers/provider.go index 2db1aba12..a4e05d80a 100644 --- a/providers/provider.go +++ b/providers/provider.go @@ -86,7 +86,7 @@ type GetSchemaResponse struct { // Schema pairs a provider or resource schema with that schema's version. // This is used to be able to upgrade the schema in UpgradeResourceState. type Schema struct { - Version uint64 + Version int64 Block *configschema.Block } @@ -135,7 +135,7 @@ type UpgradeResourceStateRequest struct { TypeName string // Version is version of the schema that created the current state. - Version int + Version int64 // RawStateJSON and RawStateFlatmap contiain the state that needs to be // upgraded to match the current schema version. Because the schema is