Skip to content

Commit 9cca986

Browse files
committed
Fix merge errors.
This includes moving the re-exported functions into the schema package, as the majority of the re-exported functions now reside in that package.
1 parent dbc9b51 commit 9cca986

File tree

3 files changed

+20
-32
lines changed

3 files changed

+20
-32
lines changed

helper/resource/exports.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

helper/schema/exports.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package schema
2+
3+
import (
4+
"github.com/hashicorp/go-cty/cty"
5+
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/configschema"
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/plans/objchange"
7+
)
8+
9+
func NormalizeObjectFromLegacySDK(val cty.Value, schema *configschema.Block) cty.Value {
10+
return objchange.NormalizeObjectFromLegacySDK(val, schema)
11+
}

helper/schema/grpc_provider.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func (s *GRPCProviderServer) UpgradeResourceState(ctx context.Context, req *tfpr
304304
}
305305

306306
// The provider isn't required to clean out removed fields
307-
s.removeAttributes(jsonMap, schemaBlock.ImpliedType())
307+
RemoveAttributes(jsonMap, schemaBlock.ImpliedType())
308308

309309
// now we need to turn the state into the default json representation, so
310310
// that it can be re-decoded using the actual schema.
@@ -336,12 +336,16 @@ func (s *GRPCProviderServer) UpgradeResourceState(ctx context.Context, req *tfpr
336336
return resp, nil
337337
}
338338

339-
// upgradeFlatmapState takes a legacy flatmap state, upgrades it using Migrate
339+
func (s *GRPCProviderServer) upgradeFlatmapState(ctx context.Context, version int, m map[string]string, res *Resource) (map[string]interface{}, int, error) {
340+
return UpgradeFlatmapState(ctx, version, m, res, s.provider.Meta())
341+
}
342+
343+
// UpgradeFlatmapState takes a legacy flatmap state, upgrades it using Migrate
340344
// state if necessary, and converts it to the new JSON state format decoded as a
341345
// map[string]interface{}.
342346
// upgradeFlatmapState returns the json map along with the corresponding schema
343347
// version.
344-
func (s *GRPCProviderServer) upgradeFlatmapState(ctx context.Context, version int, m map[string]string, res *Resource) (map[string]interface{}, int, error) {
348+
func UpgradeFlatmapState(ctx context.Context, version int, m map[string]string, res *Resource, meta interface{}) (map[string]interface{}, int, error) {
345349
// this will be the version we've upgraded so, defaulting to the given
346350
// version in case no migration was called.
347351
upgradedVersion := version
@@ -413,7 +417,7 @@ func (s *GRPCProviderServer) upgradeFlatmapState(ctx context.Context, version in
413417
return jsonMap, upgradedVersion, err
414418
}
415419

416-
func (s *GRPCProviderServer) upgradeJSONState(ctx context.Context, version int, m map[string]interface{}, res *Resource) (map[string]interface{}, error) {
420+
func UpgradeJSONState(ctx context.Context, version int, m map[string]interface{}, res *Resource, meta interface{}) (map[string]interface{}, error) {
417421
var err error
418422

419423
for _, upgrader := range res.StateUpgraders {
@@ -431,7 +435,7 @@ func (s *GRPCProviderServer) upgradeJSONState(ctx context.Context, version int,
431435
return m, nil
432436
}
433437

434-
func (s *GRPCProviderServer) upgradeJSONState(ctx context.Context, version int, m map[string]interface{}, res *schema.Resource) (map[string]interface{}, error) {
438+
func (s *GRPCProviderServer) upgradeJSONState(ctx context.Context, version int, m map[string]interface{}, res *Resource) (map[string]interface{}, error) {
435439
return UpgradeJSONState(ctx, version, m, res, s.provider.Meta())
436440
}
437441

0 commit comments

Comments
 (0)