Skip to content

Commit

Permalink
fix: customize diff validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jrauschenbusch committed Oct 6, 2019
1 parent ec512c5 commit 6e0078c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions azurerm/resource_arm_kusto_eventhub_data_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,27 @@ func resourceArmKustoEventHubDataConnection() *schema.Resource {
_, hasMappingRuleName := d.GetOk("mapping_rule_name")
_, hasDataFormat := d.GetOk("data_format")

if !(hasTableName && hasMappingRuleName && hasDataFormat) {
return fmt.Errorf("if `table_name`, `mapping_rule_name` or `data_format` is set, the other values must also be defined")
if !(AllEquals(hasTableName, hasMappingRuleName, hasDataFormat)) {
return fmt.Errorf("if one of the target table properties `table_name`, `mapping_rule_name` or `data_format` are set, the other values must also be defined")
}

return nil
},
}
}

func AllEquals(v ...interface{}) bool {
if len(v) > 1 {
a := v[0]
for _, s := range v {
if a != s {
return false
}
}
}
return true
}

func resourceArmKustoEventHubDataConnectionCreateUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).kusto.DataConnectionsClient
ctx := meta.(*ArmClient).StopContext
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ github.com/Azure/azure-sdk-for-go v32.5.0+incompatible h1:Hn/DsObfmw0M7dMGS/c0Ml
github.com/Azure/azure-sdk-for-go v32.5.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v33.2.0+incompatible h1:eDPeIqsD1UxYEcrn/DMxhfA47QcvaOXGtj4MkGIHIio=
github.com/Azure/azure-sdk-for-go v33.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v34.0.0+incompatible h1:4uQN/1HmJCkxYOnK3MUBUhHW7dxWUABOOr/LgxkkYKM=
github.com/Azure/go-autorest v10.15.4+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
github.com/Azure/go-autorest v13.0.0+incompatible h1:56c11ykhsFSPNNQuS73Ri8h/ezqVhr2h6t9LJIEKVO0=
github.com/Azure/go-autorest v13.0.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
Expand Down

0 comments on commit 6e0078c

Please sign in to comment.