Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the type of internal_ips and external_ips to Set instead of List. #7205

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func resourceComputeInstanceGroupManager() *schema.Resource {
},
<% unless version == "ga" -%>
"stateful_internal_ip": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Description: `External IPs considered stateful by the instance group. `,
Elem: &schema.Resource{
Expand All @@ -348,7 +348,7 @@ func resourceComputeInstanceGroupManager() *schema.Resource {
},
},
"stateful_external_ip": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Description: `External IPs considered stateful by the instance group. `,
Elem: &schema.Resource{
Expand Down Expand Up @@ -1035,34 +1035,30 @@ func expandStatefulPolicy(d *schema.ResourceData) *compute.StatefulPolicy {
<% unless version == "ga" -%>
if d.HasChange("stateful_internal_ip") {
oldInternalIps, newInternalIps := d.GetChange("stateful_internal_ip")
preservedState.InternalIPs = expandStatefulIps(newInternalIps.([]interface{}))
preservedState.InternalIPs = expandStatefulIps(newInternalIps.(*schema.Set).List())
// Remove Internal Ips
for _, raw := range oldInternalIps.([]interface{}) {
for _, raw := range oldInternalIps.(*schema.Set).List() {
data := raw.(map[string]interface{})
networkIp := data["interface_name"].(string)
if _, exist := preservedState.InternalIPs[networkIp]; !exist {
preservedState.NullFields = append(preservedState.NullFields, "InternalIPs." + networkIp)
}
}
preservedState.ForceSendFields = append(preservedState.ForceSendFields, "InternalIPs")


}
if d.HasChange("stateful_external_ip") {
oldExternalIps, newExternalIps := d.GetChange("stateful_external_ip")
preservedState.ExternalIPs = expandStatefulIps(newExternalIps.([]interface{}))
preservedState.ExternalIPs = expandStatefulIps(newExternalIps.(*schema.Set).List())
// Remove External Ips
for _, raw := range oldExternalIps.([]interface{}) {
for _, raw := range oldExternalIps.(*schema.Set).List() {
data := raw.(map[string]interface{})
networkIp := data["interface_name"].(string)
if _, exist := preservedState.ExternalIPs[networkIp]; !exist {
preservedState.NullFields = append(preservedState.NullFields, "ExternalIPs." + networkIp)
}
}
preservedState.ForceSendFields = append(preservedState.ForceSendFields, "ExternalIPs")

}

<% end -%>
statefulPolicy := &compute.StatefulPolicy{PreservedState: preservedState}
statefulPolicy.ForceSendFields = append(statefulPolicy.ForceSendFields, "PreservedState")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource {
<% end -%>
<% unless version == "ga" -%>
"stateful_internal_ip": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Description: `External IPs considered stateful by the instance group. `,
Elem: &schema.Resource{
Expand All @@ -381,7 +381,7 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource {
},
},
"stateful_external_ip": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Description: `External IPs considered stateful by the instance group. `,
Elem: &schema.Resource{
Expand Down