-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Delayed Deletion Hours parameter to Vmwareengine Private Cloud
- Loading branch information
1 parent
7f7c253
commit bf09ae3
Showing
8 changed files
with
190 additions
and
45 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
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
func isPrivateCloudInDeletedState(config *transport_tpg.Config, d *schema.ResourceData, billingProject string, userAgent string) (bool, error) { | ||
baseurl, err := tpgresource.ReplaceVars(d, config, "{{<%=object.__product.name-%>BasePath}}<%=object.self_link_uri-%>") | ||
if err != nil { | ||
return false, err | ||
} | ||
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ | ||
Config: config, | ||
Method: "GET", | ||
Project: billingProject, | ||
RawURL: baseurl, | ||
UserAgent: userAgent, | ||
}) | ||
// if resource does not exist | ||
if err != nil { | ||
log.Printf("[DEBUG] The Private cloud does not exist.") | ||
return false, nil | ||
} | ||
// if resource exists but is marked for deletion | ||
v, ok := res["state"] | ||
if ok && v.(string) == "DELETED" { | ||
log.Printf("[DEBUG] The Private cloud exists and is marked for deletion.") | ||
return true, nil | ||
} | ||
return false, nil | ||
} | ||
|
||
func vmwareenginePrivateCloudStandardTypeDiffSuppressFunc(_, old, new string, _ *schema.ResourceData) bool { | ||
if (old == "STANDARD" && new == "") || (old == "" && new == "STANDARD") { | ||
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
9 changes: 9 additions & 0 deletions
9
mmv1/templates/terraform/pre_create/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,9 @@ | ||
// Check if the project exists in a deleted state | ||
pcMarkedForDeletion, err := isPrivateCloudInDeletedState(config, d, billingProject, userAgent) | ||
if err != nil { | ||
return fmt.Errorf("Error checking if Private Cloud exists and is marked for deletion: %s", err) | ||
} | ||
if pcMarkedForDeletion { | ||
log.Printf("[DEBUG] Private Cloud exists and is marked for deletion. Triggering undelete of the Private Cloud.\n") | ||
url = url + ":undelete" | ||
} |
5 changes: 5 additions & 0 deletions
5
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,5 @@ | ||
// Delay deletion of the Private Cloud if delationDelayHours value is set | ||
if deletionDelayHours := d.Get("deletionDelayHours"); deletionDelayHours != "" { | ||
log.Printf("[DEBUG] Triggering delete of the Private Cloud with a delay of %v hours.\n", deletionDelayHours) | ||
url = url + "?delay_hours=" + fmt.Sprintf("%v", deletionDelayHours) | ||
} |
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