@@ -46,7 +46,7 @@ type MaintenanceWindowScheduleRecurring struct {
4646/* CREATE */
4747
4848func (model MaintenanceWindowModel ) toAPICreateRequest (ctx context.Context ) (kbapi.PostMaintenanceWindowJSONRequestBody , diag.Diagnostics ) {
49- var diags diag.Diagnostics
49+ var diags = diag.Diagnostics {}
5050
5151 body := kbapi.PostMaintenanceWindowJSONRequestBody {
5252 Enabled : model .Enabled .ValueBoolPointer (),
@@ -81,25 +81,24 @@ func (model MaintenanceWindowModel) toAPICreateRequest(ctx context.Context) (kba
8181
8282 if ! model .CustomSchedule .Recurring .OnWeekDay .IsNull () && ! model .CustomSchedule .Recurring .OnWeekDay .IsUnknown () {
8383 var onWeekDay []string
84- diags = model .CustomSchedule .Recurring .OnWeekDay .ElementsAs (ctx , & onWeekDay , true )
84+ diags . Append ( model .CustomSchedule .Recurring .OnWeekDay .ElementsAs (ctx , & onWeekDay , true ) ... )
8585 body .Schedule .Custom .Recurring .OnWeekDay = & onWeekDay
8686 }
8787
8888 if ! model .CustomSchedule .Recurring .OnMonth .IsNull () && ! model .CustomSchedule .Recurring .OnMonth .IsUnknown () {
8989 var onMonth []float32
90- diags = model .CustomSchedule .Recurring .OnMonth .ElementsAs (ctx , & onMonth , true )
90+ diags . Append ( model .CustomSchedule .Recurring .OnMonth .ElementsAs (ctx , & onMonth , true ) ... )
9191 body .Schedule .Custom .Recurring .OnMonth = & onMonth
9292 }
9393
9494 if ! model .CustomSchedule .Recurring .OnMonthDay .IsNull () && ! model .CustomSchedule .Recurring .OnMonthDay .IsUnknown () {
9595 var onMonthDay []float32
96- diags = model .CustomSchedule .Recurring .OnMonthDay .ElementsAs (ctx , & onMonthDay , true )
96+ diags . Append ( model .CustomSchedule .Recurring .OnMonthDay .ElementsAs (ctx , & onMonthDay , true ) ... )
9797 body .Schedule .Custom .Recurring .OnMonthDay = & onMonthDay
9898 }
9999 }
100100
101101 if model .Scope != nil {
102- // Yes, I hate it too
103102 body .Scope = & struct {
104103 Alerting struct {
105104 Query struct {
@@ -161,7 +160,7 @@ func (model *MaintenanceWindowModel) fromAPIReadResponse(ctx context.Context, da
161160/* UPDATE */
162161
163162func (model MaintenanceWindowModel ) toAPIUpdateRequest (ctx context.Context ) (kbapi.PatchMaintenanceWindowIdJSONRequestBody , diag.Diagnostics ) {
164- var diags diag.Diagnostics
163+ var diags = diag.Diagnostics {}
165164
166165 body := kbapi.PatchMaintenanceWindowIdJSONRequestBody {}
167166
@@ -238,19 +237,19 @@ func (model MaintenanceWindowModel) toAPIUpdateRequest(ctx context.Context) (kba
238237
239238 if ! model .CustomSchedule .Recurring .OnWeekDay .IsNull () && ! model .CustomSchedule .Recurring .OnWeekDay .IsUnknown () {
240239 var onWeekDay []string
241- diags = model .CustomSchedule .Recurring .OnWeekDay .ElementsAs (ctx , & onWeekDay , true )
240+ diags . Append ( model .CustomSchedule .Recurring .OnWeekDay .ElementsAs (ctx , & onWeekDay , true ) ... )
242241 body .Schedule .Custom .Recurring .OnWeekDay = & onWeekDay
243242 }
244243
245244 if ! model .CustomSchedule .Recurring .OnMonth .IsNull () && ! model .CustomSchedule .Recurring .OnMonth .IsUnknown () {
246245 var onMonth []float32
247- diags = model .CustomSchedule .Recurring .OnMonth .ElementsAs (ctx , & onMonth , true )
246+ diags . Append ( model .CustomSchedule .Recurring .OnMonth .ElementsAs (ctx , & onMonth , true ) ... )
248247 body .Schedule .Custom .Recurring .OnMonth = & onMonth
249248 }
250249
251250 if ! model .CustomSchedule .Recurring .OnMonthDay .IsNull () && ! model .CustomSchedule .Recurring .OnMonthDay .IsUnknown () {
252251 var onMonthDay []float32
253- diags = model .CustomSchedule .Recurring .OnMonthDay .ElementsAs (ctx , & onMonthDay , true )
252+ diags . Append ( model .CustomSchedule .Recurring .OnMonthDay .ElementsAs (ctx , & onMonthDay , true ) ... )
254253 body .Schedule .Custom .Recurring .OnMonthDay = & onMonthDay
255254 }
256255 }
@@ -315,8 +314,7 @@ func (model MaintenanceWindowModel) getMaintenanceWindowIDAndSpaceID() (maintena
315314/* RESPONSE HANDLER */
316315
317316func (model * MaintenanceWindowModel ) _fromAPIResponse (ctx context.Context , response ResponseJson ) diag.Diagnostics {
318-
319- var diags diag.Diagnostics
317+ var diags = diag.Diagnostics {}
320318
321319 resourceID := clients.CompositeId {
322320 ClusterId : model .SpaceID .ValueString (),
@@ -348,18 +346,33 @@ func (model *MaintenanceWindowModel) _fromAPIResponse(ctx context.Context, respo
348346 }
349347
350348 if response .Schedule .Custom .Recurring .OnWeekDay != nil {
351- onWeekDay , _ := types .ListValueFrom (ctx , types .StringType , response .Schedule .Custom .Recurring .OnWeekDay )
352- model .CustomSchedule .Recurring .OnWeekDay = onWeekDay
349+ onWeekDay , d := types .ListValueFrom (ctx , types .StringType , response .Schedule .Custom .Recurring .OnWeekDay )
350+
351+ if d .HasError () {
352+ diags .Append (d ... )
353+ } else {
354+ model .CustomSchedule .Recurring .OnWeekDay = onWeekDay
355+ }
353356 }
354357
355358 if response .Schedule .Custom .Recurring .OnMonth != nil {
356- onMonth , _ := types .ListValueFrom (ctx , types .Int32Type , response .Schedule .Custom .Recurring .OnMonth )
357- model .CustomSchedule .Recurring .OnMonth = onMonth
359+ onMonth , d := types .ListValueFrom (ctx , types .Int32Type , response .Schedule .Custom .Recurring .OnMonth )
360+
361+ if d .HasError () {
362+ diags .Append (d ... )
363+ } else {
364+ model .CustomSchedule .Recurring .OnMonth = onMonth
365+ }
358366 }
359367
360368 if response .Schedule .Custom .Recurring .OnMonthDay != nil {
361- onMonthDay , _ := types .ListValueFrom (ctx , types .Int32Type , response .Schedule .Custom .Recurring .OnMonthDay )
362- model .CustomSchedule .Recurring .OnMonthDay = onMonthDay
369+ onMonthDay , d := types .ListValueFrom (ctx , types .Int32Type , response .Schedule .Custom .Recurring .OnMonthDay )
370+
371+ if d .HasError () {
372+ diags .Append (d ... )
373+ } else {
374+ model .CustomSchedule .Recurring .OnMonthDay = onMonthDay
375+ }
363376 }
364377 }
365378
0 commit comments