From 9684c8b0b65b3353aea4e0bfbeaf21986282812b Mon Sep 17 00:00:00 2001 From: sawanoboly Date: Fri, 20 Jan 2017 23:05:42 +0900 Subject: [PATCH] Exclusion of `network_id`, `vpc_id` and `zone_id` --- .../cloudstack/resource_cloudstack_ipaddress.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go b/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go index c2de438101..a32a7221a4 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go +++ b/builtin/providers/cloudstack/resource_cloudstack_ipaddress.go @@ -155,9 +155,19 @@ func verifyIPAddressParams(d *schema.ResourceData) error { _, vpc := d.GetOk("vpc_id") _, zone := d.GetOk("zone_id") - if (network && vpc) || (!network && !vpc && !zone) { + f := func(bs ...bool) int { + cnt := 0 + for _, b := range bs { + if b { + cnt++ + } + } + return cnt + } + + if f(network, vpc, zone) >= 2 || (!network && !vpc && !zone) { return fmt.Errorf( - "You must supply a value for either (so not both) the 'network_id' or 'vpc_id' parameter") + "You must supply one value for either (so not more than two) the 'network_id' or 'vpc_id' or 'zone_id' parameter") } return nil