Skip to content

Commit

Permalink
Eliminate overwriting of GKE maintenance exclusions, and prevent diff. (
Browse files Browse the repository at this point in the history
#4764)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and nat-henderson committed Oct 28, 2019
1 parent b86a93f commit 2c36238
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1748,12 +1748,19 @@ func expandMaintenancePolicy(d *schema.ResourceData, meta interface{}) *containe
if cluster != nil && cluster.MaintenancePolicy != nil {
resourceVersion = cluster.MaintenancePolicy.ResourceVersion
}
exclusions := make(map[string]containerBeta.TimeWindow, 0)
if cluster != nil && cluster.MaintenancePolicy != nil && cluster.MaintenancePolicy.Window != nil {
exclusions = cluster.MaintenancePolicy.Window.MaintenanceExclusions
}

configured := d.Get("maintenance_policy")
l := configured.([]interface{})
if len(l) == 0 || l[0] == nil {
return &containerBeta.MaintenancePolicy{
ResourceVersion: resourceVersion,
Window: &containerBeta.MaintenanceWindow{
MaintenanceExclusions: exclusions,
},
}
}
maintenancePolicy := l[0].(map[string]interface{})
Expand All @@ -1763,6 +1770,7 @@ func expandMaintenancePolicy(d *schema.ResourceData, meta interface{}) *containe
startTime := dmw["start_time"].(string)
return &containerBeta.MaintenancePolicy{
Window: &containerBeta.MaintenanceWindow{
MaintenanceExclusions: exclusions,
DailyMaintenanceWindow: &containerBeta.DailyMaintenanceWindow{
StartTime: startTime,
},
Expand Down

0 comments on commit 2c36238

Please sign in to comment.