forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Delayed Deletion for Vmwareengine Private Cloud (GoogleCloudP…
- Loading branch information
1 parent
c8f8065
commit 32eebe8
Showing
11 changed files
with
149 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
mmv1/templates/terraform/constants/vmwareengine_private_cloud.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
func vmwareenginePrivateCloudStandardTypeDiffSuppressFunc(_, old, new string, d *schema.ResourceData) bool { | ||
if (old == "STANDARD" && new == "") || (old == "" && new == "STANDARD") { | ||
return true | ||
} | ||
if (isMultiNodePrivateCloud(d) && old == "TIME_LIMITED" && new == "STANDARD") { | ||
log.Printf("[DEBUG] Multinode Private Cloud found, facilitating TYPE change to STANDARD") | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
func isMultiNodePrivateCloud(d *schema.ResourceData) bool { | ||
nodeConfigMap := d.Get("management_cluster.0.node_type_configs").(*schema.Set).List() | ||
totalNodeCount := 0 | ||
for _, nodeConfig := range nodeConfigMap { | ||
configMap, ok := nodeConfig.(map[string]interface{}) | ||
if !ok { | ||
log.Printf("[DEBUG] Invalid node configuration format for private cloud.") | ||
continue | ||
} | ||
nodeCount, ok := configMap["node_count"].(int) | ||
if !ok { | ||
log.Printf("[DEBUG] Invalid node_count format for private cloud.") | ||
continue | ||
} | ||
totalNodeCount += nodeCount | ||
} | ||
log.Printf("[DEBUG] The node count of the private cloud is found to be %v nodes.", totalNodeCount) | ||
if totalNodeCount > 2 { | ||
return true | ||
} | ||
return false | ||
} |
6 changes: 0 additions & 6 deletions
6
mmv1/templates/terraform/constants/vmwareengine_private_cloud_type.go.erb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
mmv1/templates/terraform/pre_delete/vmwareengine_private_cloud.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Delay deletion of the Private Cloud if delationDelayHours value is set | ||
delationDelayHours := d.Get("deletion_delay_hours").(int) | ||
if delationDelayHours > 0 || (delationDelayHours == 0 && d.Get("send_deletion_delay_hours_if_zero").(bool) == true) { | ||
log.Printf("[DEBUG] Triggering delete of the Private Cloud with a delay of %v hours.\n", delationDelayHours) | ||
url = url + "?delay_hours=" + fmt.Sprintf("%v", delationDelayHours) | ||
} else { | ||
log.Printf("[DEBUG] No deletion delay provided, triggering DELETE API without setting delay hours.\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters