Fix state diff logic for network subresource of compute
This commit is contained in:
@@ -394,9 +394,9 @@ func dataSourceCompute() *schema.Resource {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
"network": {
|
"network": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
// MaxItems: MaxNetworksPerCompute,
|
MaxItems: MaxNetworksPerCompute,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: networkSubresourceSchemaMake(),
|
Schema: networkSubresourceSchemaMake(),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
// "encoding/json"
|
// "encoding/json"
|
||||||
// "fmt"
|
// "fmt"
|
||||||
// "log"
|
log "github.com/sirupsen/logrus"
|
||||||
// "net/url"
|
// "net/url"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||||
@@ -30,6 +30,15 @@ import (
|
|||||||
|
|
||||||
// This is subresource of compute resource used when creating/managing compute network connections
|
// This is subresource of compute resource used when creating/managing compute network connections
|
||||||
|
|
||||||
|
func networkSubresIPAddreDiffSupperss(key, oldVal, newVal string, d *schema.ResourceData) bool {
|
||||||
|
if newVal != "" && newVal != oldVal {
|
||||||
|
log.Debugf("networkSubresIPAddreDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=FALSE", key, oldVal, newVal)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Debugf("networkSubresIPAddreDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=TRUE", key, oldVal, newVal)
|
||||||
|
return true // suppress difference
|
||||||
|
}
|
||||||
|
|
||||||
func networkSubresourceSchemaMake() map[string]*schema.Schema {
|
func networkSubresourceSchemaMake() map[string]*schema.Schema {
|
||||||
rets := map[string]*schema.Schema{
|
rets := map[string]*schema.Schema{
|
||||||
"net_type": {
|
"net_type": {
|
||||||
@@ -49,7 +58,7 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema {
|
|||||||
"ip_address": {
|
"ip_address": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
// DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {}
|
DiffSuppressFunc: networkSubresIPAddreDiffSupperss,
|
||||||
Description: "Optional IP address to assign to this connection. This IP should belong to the selected network and free for use.",
|
Description: "Optional IP address to assign to this connection. This IP should belong to the selected network and free for use.",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -380,9 +380,9 @@ func resourceCompute() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
"network": {
|
"network": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
// MaxItems: MaxNetworksPerCompute,
|
MaxItems: MaxNetworksPerCompute,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: networkSubresourceSchemaMake(),
|
Schema: networkSubresourceSchemaMake(),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user