diff --git a/decort/data_source_compute.go b/decort/data_source_compute.go index 98c99c2..f98ac58 100644 --- a/decort/data_source_compute.go +++ b/decort/data_source_compute.go @@ -394,9 +394,9 @@ func dataSourceCompute() *schema.Resource { */ "network": { - Type: schema.TypeSet, + Type: schema.TypeList, Optional: true, - // MaxItems: MaxNetworksPerCompute, + MaxItems: MaxNetworksPerCompute, Elem: &schema.Resource{ Schema: networkSubresourceSchemaMake(), }, diff --git a/decort/network_subresource.go b/decort/network_subresource.go index 81dfc28..01a7c47 100644 --- a/decort/network_subresource.go +++ b/decort/network_subresource.go @@ -21,7 +21,7 @@ import ( // "encoding/json" // "fmt" - // "log" + log "github.com/sirupsen/logrus" // "net/url" "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 +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 { rets := map[string]*schema.Schema{ "net_type": { @@ -49,7 +58,7 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema { "ip_address": { Type: schema.TypeString, 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.", }, diff --git a/decort/resource_compute.go b/decort/resource_compute.go index 45e1e95..f17356a 100644 --- a/decort/resource_compute.go +++ b/decort/resource_compute.go @@ -380,9 +380,9 @@ func resourceCompute() *schema.Resource { }, "network": { - Type: schema.TypeSet, + Type: schema.TypeList, Optional: true, - // MaxItems: MaxNetworksPerCompute, + MaxItems: MaxNetworksPerCompute, Elem: &schema.Resource{ Schema: networkSubresourceSchemaMake(), },