Skip to content

Commit bf84803

Browse files
committed
Remove occurrences from maintenance window resource.
1 parent fcec64a commit bf84803

File tree

5 files changed

+30
-52
lines changed

5 files changed

+30
-52
lines changed

internal/clients/kibana/maintenance_window.go

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ func maintenanceWindowResponseToModel(spaceId string, res *alerting.MaintenanceW
2626
unwrappedRecurring := unwrapOptionalField(res.Schedule.Custom.Recurring)
2727

2828
recurring = &models.MaintenanceWindowScheduleRecurring{
29-
End: unwrappedRecurring.End,
30-
Every: unwrappedRecurring.Every,
31-
Occurrences: unwrappedRecurring.Occurrences,
32-
OnWeekDay: &unwrappedRecurring.OnWeekDay,
33-
OnMonthDay: &unwrappedRecurring.OnMonthDay,
34-
OnMonth: &unwrappedRecurring.OnMonth,
29+
End: unwrappedRecurring.End,
30+
Every: unwrappedRecurring.Every,
31+
OnWeekDay: &unwrappedRecurring.OnWeekDay,
32+
OnMonthDay: &unwrappedRecurring.OnMonthDay,
33+
OnMonth: &unwrappedRecurring.OnMonth,
3534
}
3635
}
3736

@@ -91,12 +90,11 @@ func CreateMaintenanceWindow(ctx context.Context, apiClient ApiClient, maintenan
9190
unwrappedOnMonth := unwrapOptionalField(unwrappedRecurring.OnMonth)
9291

9392
recurring = &alerting.CreateMaintenanceWindowRequestScheduleCustomRecurring{
94-
End: unwrappedRecurring.End,
95-
Every: unwrappedRecurring.Every,
96-
Occurrences: unwrappedRecurring.Occurrences,
97-
OnWeekDay: unwrappedOnWeekDay,
98-
OnMonthDay: unwrappedOnMonthDay,
99-
OnMonth: unwrappedOnMonth,
93+
End: unwrappedRecurring.End,
94+
Every: unwrappedRecurring.Every,
95+
OnWeekDay: unwrappedOnWeekDay,
96+
OnMonthDay: unwrappedOnMonthDay,
97+
OnMonth: unwrappedOnMonth,
10098
}
10199
}
102100

@@ -215,12 +213,11 @@ func UpdateMaintenanceWindow(ctx context.Context, apiClient ApiClient, maintenan
215213
unwrappedOnMonth := unwrapOptionalField(unwrappedRecurring.OnMonth)
216214

217215
recurring = &alerting.CreateMaintenanceWindowRequestScheduleCustomRecurring{
218-
End: unwrappedRecurring.End,
219-
Every: unwrappedRecurring.Every,
220-
Occurrences: unwrappedRecurring.Occurrences,
221-
OnWeekDay: unwrappedOnWeekDay,
222-
OnMonthDay: unwrappedOnMonthDay,
223-
OnMonth: unwrappedOnMonth,
216+
End: unwrappedRecurring.End,
217+
Every: unwrappedRecurring.Every,
218+
OnWeekDay: unwrappedOnWeekDay,
219+
OnMonthDay: unwrappedOnMonthDay,
220+
OnMonth: unwrappedOnMonth,
224221
}
225222
}
226223

internal/clients/kibana/maintenance_window_test.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,11 @@ func Test_maintenanceWindowResponseToModel(t *testing.T) {
8080
Start: "1999-02-02T05:00:00.200Z",
8181
Timezone: utils.Pointer("Asia/Taipei"),
8282
Recurring: &alerting.MaintenanceWindowResponsePropertiesScheduleCustomRecurring{
83-
End: utils.Pointer("2029-05-17T05:05:00.000Z"),
84-
Every: utils.Pointer("20d"),
85-
Occurrences: utils.Pointer(float32(30)),
86-
OnMonth: []float32{2},
87-
OnMonthDay: []float32{1},
88-
OnWeekDay: []string{"WE", "TU"},
83+
End: utils.Pointer("2029-05-17T05:05:00.000Z"),
84+
Every: utils.Pointer("20d"),
85+
OnMonth: []float32{2},
86+
OnMonthDay: []float32{1},
87+
OnWeekDay: []string{"WE", "TU"},
8988
},
9089
},
9190
},
@@ -107,12 +106,11 @@ func Test_maintenanceWindowResponseToModel(t *testing.T) {
107106
Start: "1999-02-02T05:00:00.200Z",
108107
Timezone: utils.Pointer("Asia/Taipei"),
109108
Recurring: &models.MaintenanceWindowScheduleRecurring{
110-
End: utils.Pointer("2029-05-17T05:05:00.000Z"),
111-
Every: utils.Pointer("20d"),
112-
Occurrences: utils.Pointer(float32(30)),
113-
OnMonth: &[]float32{2},
114-
OnMonthDay: &[]float32{1},
115-
OnWeekDay: &[]string{"WE", "TU"},
109+
End: utils.Pointer("2029-05-17T05:05:00.000Z"),
110+
Every: utils.Pointer("20d"),
111+
OnMonth: &[]float32{2},
112+
OnMonthDay: &[]float32{1},
113+
OnWeekDay: &[]string{"WE", "TU"},
116114
},
117115
},
118116
Scope: &models.MaintenanceWindowScope{

internal/kibana/maintenance_window.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,6 @@ func ResourceMaintenanceWindow() *schema.Resource {
116116
ValidateFunc: validation.IntBetween(1, 12),
117117
},
118118
},
119-
"occurrences": {
120-
Description: "The total number of recurrences of the schedule.",
121-
Type: schema.TypeInt,
122-
Optional: true,
123-
ValidateFunc: validation.IntAtLeast(0),
124-
},
125119
},
126120
},
127121
},
@@ -250,11 +244,6 @@ func getScheduleFromResourceData(d *schema.ResourceData) (models.MaintenanceWind
250244

251245
}
252246

253-
if v, ok := d.GetOk("custom_schedule.0.recurring.0.occurrences"); ok {
254-
occurrences := v.(int)
255-
recurring.Occurrences = utils.Pointer(float32(occurrences))
256-
}
257-
258247
schedule.Recurring = &recurring
259248
}
260249

@@ -402,7 +391,6 @@ func resourceMaintenanceWindowRead(ctx context.Context, d *schema.ResourceData,
402391
"on_week_day": maintenanceWindow.CustomSchedule.Recurring.OnWeekDay,
403392
"on_month_day": maintenanceWindow.CustomSchedule.Recurring.OnMonthDay,
404393
"on_month": maintenanceWindow.CustomSchedule.Recurring.OnMonth,
405-
"occurrences": maintenanceWindow.CustomSchedule.Recurring.Occurrences,
406394
})
407395
} else {
408396
recurring = nil

internal/kibana/maintenance_window_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func TestAccResourceMaintenanceWindow(t *testing.T) {
3737
resource.TestCheckResourceAttr("elasticstack_kibana_maintenance_window.test_maintenance_window", "custom_schedule.0.recurring.0.end", "2029-05-17T05:05:00.000Z"),
3838
resource.TestCheckResourceAttr("elasticstack_kibana_maintenance_window.test_maintenance_window", "custom_schedule.0.recurring.0.on_week_day.0", "MO"),
3939
resource.TestCheckResourceAttr("elasticstack_kibana_maintenance_window.test_maintenance_window", "custom_schedule.0.recurring.0.on_week_day.1", "TU"),
40-
resource.TestCheckResourceAttr("elasticstack_kibana_maintenance_window.test_maintenance_window", "custom_schedule.0.recurring.0.occurrences", "0"),
4140
resource.TestCheckResourceAttr("elasticstack_kibana_maintenance_window.test_maintenance_window", "scope.0.alerting.0.kql", "_id: '1234'"),
4241
),
4342
},
@@ -57,7 +56,6 @@ func TestAccResourceMaintenanceWindow(t *testing.T) {
5756
resource.TestCheckResourceAttr("elasticstack_kibana_maintenance_window.test_maintenance_window", "custom_schedule.0.recurring.0.on_month_day.2", "3"),
5857
resource.TestCheckResourceAttr("elasticstack_kibana_maintenance_window.test_maintenance_window", "custom_schedule.0.recurring.0.on_month.0", "4"),
5958
resource.TestCheckResourceAttr("elasticstack_kibana_maintenance_window.test_maintenance_window", "custom_schedule.0.recurring.0.on_month.1", "5"),
60-
resource.TestCheckResourceAttr("elasticstack_kibana_maintenance_window.test_maintenance_window", "custom_schedule.0.recurring.0.occurrences", "10"),
6159
resource.TestCheckResourceAttr("elasticstack_kibana_maintenance_window.test_maintenance_window", "scope.0.alerting.0.kql", "_id: 'foobar'"),
6260
),
6361
},
@@ -82,7 +80,6 @@ resource "elasticstack_kibana_maintenance_window" "test_maintenance_window" {
8280
every = "20d"
8381
end = "2029-05-17T05:05:00.000Z"
8482
on_week_day = ["MO", "TU"]
85-
occurrences = 0
8683
}
8784
}
8885
@@ -111,7 +108,6 @@ resource "elasticstack_kibana_maintenance_window" "test_maintenance_window" {
111108
every = "21d"
112109
on_month_day = [1, 2, 3]
113110
on_month = [4, 5]
114-
occurrences = 10
115111
}
116112
}
117113

internal/models/maintenance_window.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ type MaintenanceWindowSchedule struct {
2525
}
2626

2727
type MaintenanceWindowScheduleRecurring struct {
28-
End *string
29-
Every *string
30-
OnWeekDay *[]string
31-
OnMonthDay *[]float32
32-
OnMonth *[]float32
33-
Occurrences *float32
28+
End *string
29+
Every *string
30+
OnWeekDay *[]string
31+
OnMonthDay *[]float32
32+
OnMonth *[]float32
3433
}

0 commit comments

Comments
 (0)