better error handling for type assertions
This commit is contained in:
parent
a56e53ec5b
commit
c993fc3c1b
|
@ -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…
Reference in New Issue