Skip to content

Commit

Permalink
Add support for Vmwareengine Stretch Private Clouds. (#10340) (#17803)
Browse files Browse the repository at this point in the history
[upstream:d4184550975bcc25e7e1402835a198698c7f2deb]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Apr 9, 2024
1 parent 8c446f3 commit 95e6f84
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/10340.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
vmwareengine: added support for stretch private clouds
```
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,23 @@ the form: projects/{project_number}/locations/{location}/vmwareEngineNetworks/{v
Optional: true,
Description: `User-provided description for this private cloud.`,
},
"preferred_zone": {
Type: schema.TypeString,
Optional: true,
Description: `The preferred single failure domain within a region.`,
},
"secondary_zone": {
Type: schema.TypeString,
Optional: true,
Description: `The secondary single failure domain within a region.`,
},
"type": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: verify.ValidateEnum([]string{"STANDARD", "TIME_LIMITED", ""}),
ValidateFunc: verify.ValidateEnum([]string{"STANDARD", "TIME_LIMITED", "STRETCHED", ""}),
DiffSuppressFunc: vmwareenginePrivateCloudStandardTypeDiffSuppressFunc,
Description: `Initial type of the private cloud. Possible values: ["STANDARD", "TIME_LIMITED"]`,
Description: `Initial type of the private cloud. Possible values: ["STANDARD", "TIME_LIMITED", "STRETCHED"]`,
},
"hcx": {
Type: schema.TypeList,
Expand Down Expand Up @@ -321,6 +331,18 @@ func resourceVmwareenginePrivateCloudCreate(d *schema.ResourceData, meta interfa
} else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) {
obj["type"] = typeProp
}
preferredZoneProp, err := expandVmwareenginePrivateCloudPreferredZone(d.Get("preferred_zone"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("preferred_zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(preferredZoneProp)) && (ok || !reflect.DeepEqual(v, preferredZoneProp)) {
obj["preferredZone"] = preferredZoneProp
}
secondaryZoneProp, err := expandVmwareenginePrivateCloudSecondaryZone(d.Get("secondary_zone"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("secondary_zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(secondaryZoneProp)) && (ok || !reflect.DeepEqual(v, secondaryZoneProp)) {
obj["secondaryZone"] = secondaryZoneProp
}

url, err := tpgresource.ReplaceVars(d, config, "{{VmwareengineBasePath}}projects/{{project}}/locations/{{location}}/privateClouds?privateCloudId={{name}}")
if err != nil {
Expand Down Expand Up @@ -454,6 +476,12 @@ func resourceVmwareenginePrivateCloudRead(d *schema.ResourceData, meta interface
if err := d.Set("vcenter", flattenVmwareenginePrivateCloudVcenter(res["vcenter"], d, config)); err != nil {
return fmt.Errorf("Error reading PrivateCloud: %s", err)
}
if err := d.Set("preferred_zone", flattenVmwareenginePrivateCloudPreferredZone(res["preferredZone"], d, config)); err != nil {
return fmt.Errorf("Error reading PrivateCloud: %s", err)
}
if err := d.Set("secondary_zone", flattenVmwareenginePrivateCloudSecondaryZone(res["secondaryZone"], d, config)); err != nil {
return fmt.Errorf("Error reading PrivateCloud: %s", err)
}

return nil
}
Expand Down Expand Up @@ -486,6 +514,18 @@ func resourceVmwareenginePrivateCloudUpdate(d *schema.ResourceData, meta interfa
} else if v, ok := d.GetOkExists("management_cluster"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, managementClusterProp)) {
obj["managementCluster"] = managementClusterProp
}
preferredZoneProp, err := expandVmwareenginePrivateCloudPreferredZone(d.Get("preferred_zone"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("preferred_zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, preferredZoneProp)) {
obj["preferredZone"] = preferredZoneProp
}
secondaryZoneProp, err := expandVmwareenginePrivateCloudSecondaryZone(d.Get("secondary_zone"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("secondary_zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, secondaryZoneProp)) {
obj["secondaryZone"] = secondaryZoneProp
}

obj, err = resourceVmwareenginePrivateCloudUpdateEncoder(d, meta, obj)
if err != nil {
Expand Down Expand Up @@ -939,6 +979,14 @@ func flattenVmwareenginePrivateCloudVcenterFqdn(v interface{}, d *schema.Resourc
return v
}

func flattenVmwareenginePrivateCloudPreferredZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenVmwareenginePrivateCloudSecondaryZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func expandVmwareenginePrivateCloudDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Expand Down Expand Up @@ -1084,6 +1132,14 @@ func expandVmwareenginePrivateCloudType(v interface{}, d tpgresource.TerraformRe
return v, nil
}

func expandVmwareenginePrivateCloudPreferredZone(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandVmwareenginePrivateCloudSecondaryZone(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func resourceVmwareenginePrivateCloudUpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
delete(obj, "managementCluster")
return obj, nil
Expand Down
10 changes: 9 additions & 1 deletion website/docs/r/vmwareengine_private_cloud.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,15 @@ The following arguments are supported:
* `type` -
(Optional)
Initial type of the private cloud.
Possible values are: `STANDARD`, `TIME_LIMITED`.
Possible values are: `STANDARD`, `TIME_LIMITED`, `STRETCHED`.

* `preferred_zone` -
(Optional)
The preferred single failure domain within a region.

* `secondary_zone` -
(Optional)
The secondary single failure domain within a region.

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
Expand Down

0 comments on commit 95e6f84

Please sign in to comment.