@@ -22,15 +22,23 @@ func (r *rs) MoveState(context.Context) []resource.StateMover {
2222 return []resource.StateMover {{StateMover : stateMover }}
2323}
2424
25+ func (r * rs ) UpgradeState (ctx context.Context ) map [int64 ]resource.StateUpgrader {
26+ return map [int64 ]resource.StateUpgrader {
27+ 1 : {StateUpgrader : stateUpgraderFromV1 },
28+ }
29+ }
30+
2531func stateMover (ctx context.Context , req resource.MoveStateRequest , resp * resource.MoveStateResponse ) {
26- diags := & resp .Diagnostics
2732 if req .SourceTypeName != "mongodbatlas_cluster" || ! strings .HasSuffix (req .SourceProviderAddress , "/mongodbatlas" ) {
2833 return
2934 }
30- setStateResponse (ctx , diags , req .SourceRawState , & resp .TargetState )
35+ setStateResponse (ctx , & resp .Diagnostics , req .SourceRawState , & resp .TargetState )
36+ }
37+
38+ func stateUpgraderFromV1 (ctx context.Context , req resource.UpgradeStateRequest , resp * resource.UpgradeStateResponse ) {
39+ setStateResponse (ctx , & resp .Diagnostics , req .RawState , & resp .State )
3140}
3241
33- // setStateResponse is used in Move State and Upgrade State
3442func setStateResponse (ctx context.Context , diags * diag.Diagnostics , stateIn * tfprotov6.RawState , stateOut * tfsdk.State ) {
3543 rawStateValue , err := stateIn .UnmarshalWithOpts (tftypes.Object {
3644 AttributeTypes : map [string ]tftypes.Type {
0 commit comments