@@ -3,11 +3,12 @@ package castai
33import (
44 "context"
55 "fmt"
6- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
76 "net/http"
87 "strings"
98 "time"
109
10+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
11+
1112 "github.com/castai/terraform-provider-castai/castai/sdk"
1213 "github.com/google/uuid"
1314 "github.com/hashicorp/terraform-plugin-log/tflog"
@@ -65,7 +66,7 @@ func resourceRebalancingJobCreate(ctx context.Context, d *schema.ResourceData, m
6566 return diag .FromErr (err )
6667 }
6768
68- jobByScheduleId , found , err := getRebalancingJobByScheduleId (ctx , client , * job .ClusterId , * job .RebalancingScheduleId )
69+ jobByScheduleId , found , err := getRebalancingJobByScheduleId (ctx , client , * job .ClusterId , job .RebalancingScheduleId )
6970 if err != nil {
7071 return diag .FromErr (err )
7172 }
@@ -184,7 +185,7 @@ func stateToRebalancingJob(d *schema.ResourceData) (*sdk.ScheduledrebalancingV1R
184185 Id : lo .ToPtr (d .Id ()),
185186 Enabled : lo .ToPtr (d .Get ("enabled" ).(bool )),
186187 ClusterId : lo .ToPtr (d .Get ("cluster_id" ).(string )),
187- RebalancingScheduleId : lo . ToPtr ( d .Get ("rebalancing_schedule_id" ).(string ) ),
188+ RebalancingScheduleId : d .Get ("rebalancing_schedule_id" ).(string ),
188189 }
189190
190191 return & result , nil
@@ -220,8 +221,8 @@ func getRebalancingJobByScheduleName(ctx context.Context, client sdk.ClientWithR
220221 }
221222
222223 scheduleID := * schedule .Id
223- for _ , job := range * resp .JSON200 .Jobs {
224- if * job .RebalancingScheduleId == scheduleID {
224+ for _ , job := range resp .JSON200 .Jobs {
225+ if job .RebalancingScheduleId == scheduleID {
225226 tflog .Debug (ctx , "job found" , map [string ]interface {}{
226227 "cluster_id" : clusterID ,
227228 "schedule_id" : scheduleID ,
@@ -257,8 +258,8 @@ func getRebalancingJobByScheduleId(ctx context.Context, client sdk.ClientWithRes
257258 if checkErr := sdk .CheckOKResponse (listResp , err ); checkErr != nil {
258259 return nil , false , checkErr
259260 }
260- for _ , j := range * listResp .JSON200 .Jobs {
261- if * j .RebalancingScheduleId == scheduleID {
261+ for _ , j := range listResp .JSON200 .Jobs {
262+ if j .RebalancingScheduleId == scheduleID {
262263 return & j , true , nil
263264 }
264265 }
0 commit comments