@@ -16,6 +16,7 @@ import (
16
16
var scheduleTypeOptions = []string {
17
17
"ical" ,
18
18
"calendar" ,
19
+ "web" ,
19
20
}
20
21
21
22
func resourceSchedule () * common.Resource {
@@ -162,7 +163,7 @@ func resourceScheduleCreate(ctx context.Context, d *schema.ResourceData, client
162
163
163
164
shiftsData , shiftsOk := d .GetOk ("shifts" )
164
165
if shiftsOk {
165
- if typeData == "calendar" {
166
+ if isScheduleTypeCalendar ( typeData ) {
166
167
shiftsDataSlice := common .SetToStringSlice (shiftsData .(* schema.Set ))
167
168
createOptions .Shifts = & shiftsDataSlice
168
169
} else {
@@ -172,7 +173,7 @@ func resourceScheduleCreate(ctx context.Context, d *schema.ResourceData, client
172
173
173
174
timeZoneData , timeZoneOk := d .GetOk ("time_zone" )
174
175
if timeZoneOk {
175
- if typeData == "calendar" {
176
+ if isScheduleTypeCalendar ( typeData ) {
176
177
createOptions .TimeZone = timeZoneData .(string )
177
178
} else {
178
179
return diag .Errorf ("time_zone can not be set with type: %s" , typeData )
@@ -225,7 +226,7 @@ func resourceScheduleUpdate(ctx context.Context, d *schema.ResourceData, client
225
226
226
227
timeZoneData , timeZoneOk := d .GetOk ("time_zone" )
227
228
if timeZoneOk {
228
- if typeData == "calendar" {
229
+ if isScheduleTypeCalendar ( typeData ) {
229
230
updateOptions .TimeZone = timeZoneData .(string )
230
231
} else {
231
232
return diag .Errorf ("time_zone can not be set with type: %s" , typeData )
@@ -234,7 +235,7 @@ func resourceScheduleUpdate(ctx context.Context, d *schema.ResourceData, client
234
235
235
236
shiftsData , shiftsOk := d .GetOk ("shifts" )
236
237
if shiftsOk {
237
- if typeData == "calendar" {
238
+ if isScheduleTypeCalendar ( typeData ) {
238
239
shiftsDataSlice := common .SetToStringSlice (shiftsData .(* schema.Set ))
239
240
updateOptions .Shifts = & shiftsDataSlice
240
241
} else {
@@ -268,9 +269,12 @@ func resourceScheduleRead(ctx context.Context, d *schema.ResourceData, client *o
268
269
d .Set ("ical_url_primary" , schedule .ICalUrlPrimary )
269
270
d .Set ("ical_url_overrides" , schedule .ICalUrlOverrides )
270
271
d .Set ("enable_web_overrides" , schedule .EnableWebOverrides )
271
- d .Set ("time_zone" , schedule .TimeZone )
272
272
d .Set ("slack" , flattenScheduleSlack (schedule .Slack ))
273
- d .Set ("shifts" , schedule .Shifts )
273
+
274
+ if isScheduleTypeCalendar (schedule .Type ) {
275
+ d .Set ("time_zone" , schedule .TimeZone )
276
+ d .Set ("shifts" , schedule .Shifts )
277
+ }
274
278
275
279
return nil
276
280
}
@@ -317,3 +321,7 @@ func expandScheduleSlack(in []interface{}) *onCallAPI.SlackSchedule {
317
321
318
322
return & slackSchedule
319
323
}
324
+
325
+ func isScheduleTypeCalendar (t string ) bool {
326
+ return t == "calendar"
327
+ }
0 commit comments