@@ -49,12 +49,14 @@ func (r *GCPEnvResource) Create(ctx context.Context, req resource.CreateRequest,
4949 return
5050 }
5151
52- tflog .Trace (ctx , "created resource" , map [string ]interface {}{"name" : name })
52+ // Reorder node groups to respect order in the user's configuration
53+ apiResp .CreateGCPEnv .Spec .NodeGroups = reorderNodeGroups (data .NodeGroups , apiResp .CreateGCPEnv .Spec .NodeGroups )
5354 data .Id = data .Name
5455 data .Zones = common .ListToModel (apiResp .CreateGCPEnv .Spec .Zones )
5556 data .NodeGroups = nodeGroupsToModel (apiResp .CreateGCPEnv .Spec .NodeGroups )
5657 data .SpecRevision = types .Int64Value (apiResp .CreateGCPEnv .SpecRevision )
5758
59+ tflog .Trace (ctx , "created resource" , map [string ]interface {}{"name" : name })
5860 diags = resp .State .Set (ctx , & data )
5961 resp .Diagnostics .Append (diags ... )
6062}
@@ -83,8 +85,11 @@ func (r *GCPEnvResource) Read(ctx context.Context, req resource.ReadRequest, res
8385 return
8486 }
8587
88+ // Reorder node groups to respect order in the user's configuration
89+ apiResp .GcpEnv .Spec .NodeGroups = reorderNodeGroups (data .NodeGroups , apiResp .GcpEnv .Spec .NodeGroups )
8690 data .toModel (* apiResp .GcpEnv )
8791 data .Id = data .Name
92+
8893 diags = resp .State .Set (ctx , & data )
8994 resp .Diagnostics .Append (diags ... )
9095}
@@ -109,11 +114,13 @@ func (r *GCPEnvResource) Update(ctx context.Context, req resource.UpdateRequest,
109114 return
110115 }
111116
112- tflog .Trace (ctx , "updated resource" , map [string ]interface {}{"name" : name })
117+ // Reorder node groups to respect order in the user's configuration
118+ apiResp .UpdateGCPEnv .Spec .NodeGroups = reorderNodeGroups (data .NodeGroups , apiResp .UpdateGCPEnv .Spec .NodeGroups )
113119 data .Zones = common .ListToModel (apiResp .UpdateGCPEnv .Spec .Zones )
114120 data .NodeGroups = nodeGroupsToModel (apiResp .UpdateGCPEnv .Spec .NodeGroups )
115121 data .SpecRevision = types .Int64Value (apiResp .UpdateGCPEnv .SpecRevision )
116122
123+ tflog .Trace (ctx , "updated resource" , map [string ]interface {}{"name" : name })
117124 diags = resp .State .Set (ctx , & data )
118125 resp .Diagnostics .Append (diags ... )
119126}
0 commit comments