better error handling for type assertions

pull/22382/head
Alex Pilon 7 years ago
parent a56e53ec5b
commit c993fc3c1b
No known key found for this signature in database
GPG Key ID: 95659F6AEFC48D7E

@ -293,8 +293,13 @@ func validateFn(c *terraform.ResourceConfig) (ws []string, es []error) {
// Validate service level configs
services, ok := c.Get("service")
if ok {
for _, svc := range services.([]interface{}) {
service := svc.(map[string]interface{})
for i, svc := range services.([]interface{}) {
service, ok := svc.(map[string]interface{})
if !ok {
es = append(es, fmt.Errorf("service %d: must be a block", i))
continue
}
strategy, ok := service["strategy"].(string)
if ok && !updateStrategies[strategy] {
es = append(es, errors.New(strategy+" is not a valid update strategy."))

Loading…
Cancel
Save