Skip to content

Commit

Permalink
azurerm_redis_cache - only update patch_schedule when it has chan…
Browse files Browse the repository at this point in the history
…ged in the config file (#22661)
  • Loading branch information
mbfrahry authored Jul 25, 2023
1 parent 2d28f48 commit a61dfd8
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions internal/services/redis/redis_cache_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,18 +601,20 @@ func resourceRedisCacheUpdate(d *pluginsdk.ResourceData, meta interface{}) error
}
}

patchSchedule := expandRedisPatchSchedule(d)
if d.HasChange("patch_schedule") {
patchSchedule := expandRedisPatchSchedule(d)

patchSchedulesRedisId := patchschedules.NewRediID(id.SubscriptionId, id.ResourceGroupName, id.RedisName)
if patchSchedule == nil || len(patchSchedule.Properties.ScheduleEntries) == 0 {
_, err = patchClient.Delete(ctx, patchSchedulesRedisId)
if err != nil {
return fmt.Errorf("deleting Patch Schedule for %s: %+v", *id, err)
}
} else {
_, err = patchClient.CreateOrUpdate(ctx, patchSchedulesRedisId, *patchSchedule)
if err != nil {
return fmt.Errorf("setting Patch Schedule for %s: %+v", *id, err)
patchSchedulesRedisId := patchschedules.NewRediID(id.SubscriptionId, id.ResourceGroupName, id.RedisName)
if patchSchedule == nil || len(patchSchedule.Properties.ScheduleEntries) == 0 {
_, err = patchClient.Delete(ctx, patchSchedulesRedisId)
if err != nil {
return fmt.Errorf("deleting Patch Schedule for %s: %+v", *id, err)
}
} else {
_, err = patchClient.CreateOrUpdate(ctx, patchSchedulesRedisId, *patchSchedule)
if err != nil {
return fmt.Errorf("setting Patch Schedule for %s: %+v", *id, err)
}
}
}

Expand Down

0 comments on commit a61dfd8

Please sign in to comment.