@@ -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