Ignore case on protocol and allocation types (#12176)

This commit is contained in:
Seth Vargo 2017-02-22 15:30:07 -05:00 committed by Paul Stack
parent ad2860cabe
commit 9d34612be0
8 changed files with 45 additions and 22 deletions

View File

@ -311,3 +311,15 @@ func azureStateRefreshFunc(resourceURI string, client *ArmClient, command rivier
func resourceAzurermResourceGroupNameDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
return strings.ToLower(old) == strings.ToLower(new)
}
// ignoreCaseDiffSuppressFunc is a DiffSuppressFunc from helper/schema that is
// used to ignore any case-changes in a return value.
func ignoreCaseDiffSuppressFunc(k, old, new string, d *schema.ResourceData) bool {
return strings.ToLower(old) == strings.ToLower(new)
}
// ignoreCaseStateFunc is a StateFunc from helper/schema that converts the
// supplied value to lower before saving to state for consistency.
func ignoreCaseStateFunc(val interface{}) string {
return strings.ToLower(val.(string))
}

View File

@ -67,10 +67,12 @@ func resourceArmLoadBalancer() *schema.Resource {
},
"private_ip_address_allocation": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validateLoadBalancerPrivateIpAddressAllocation,
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validateLoadBalancerPrivateIpAddressAllocation,
StateFunc: ignoreCaseStateFunc,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},
"load_balancer_rules": {

View File

@ -51,8 +51,10 @@ func resourceArmLoadBalancerNatPool() *schema.Resource {
},
"protocol": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
StateFunc: ignoreCaseStateFunc,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},
"frontend_port_start": {

View File

@ -51,8 +51,10 @@ func resourceArmLoadBalancerNatRule() *schema.Resource {
},
"protocol": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
StateFunc: ignoreCaseStateFunc,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},
"frontend_port": {

View File

@ -51,9 +51,11 @@ func resourceArmLoadBalancerProbe() *schema.Resource {
},
"protocol": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Type: schema.TypeString,
Computed: true,
Optional: true,
StateFunc: ignoreCaseStateFunc,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},
"port": {

View File

@ -69,8 +69,10 @@ func resourceArmLoadBalancerRule() *schema.Resource {
},
"protocol": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
StateFunc: ignoreCaseStateFunc,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},
"frontend_port": {

View File

@ -79,9 +79,11 @@ func resourceArmNetworkInterface() *schema.Resource {
},
"private_ip_address_allocation": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validateNetworkInterfacePrivateIpAddressAllocation,
Type: schema.TypeString,
Required: true,
ValidateFunc: validateNetworkInterfacePrivateIpAddressAllocation,
StateFunc: ignoreCaseStateFunc,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},
"public_ip_address_id": {

View File

@ -37,12 +37,11 @@ func resourceArmPublicIp() *schema.Resource {
},
"public_ip_address_allocation": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validatePublicIpAllocation,
StateFunc: func(val interface{}) string {
return strings.ToLower(val.(string))
},
Type: schema.TypeString,
Required: true,
ValidateFunc: validatePublicIpAllocation,
StateFunc: ignoreCaseStateFunc,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},
"idle_timeout_in_minutes": {