schema: Return all validation errors together from InternalValidate

This commit is contained in:
Radek Simko 2016-08-27 10:33:19 +01:00
parent 37be25b312
commit b90ab0b705
No known key found for this signature in database
GPG Key ID: 6823F3DCCE01BB19
1 changed files with 6 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"sort" "sort"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -69,24 +70,25 @@ func (p *Provider) InternalValidate() error {
return errors.New("provider is nil") return errors.New("provider is nil")
} }
var validationErrors error
sm := schemaMap(p.Schema) sm := schemaMap(p.Schema)
if err := sm.InternalValidate(sm); err != nil { if err := sm.InternalValidate(sm); err != nil {
return err validationErrors = multierror.Append(validationErrors, err)
} }
for k, r := range p.ResourcesMap { for k, r := range p.ResourcesMap {
if err := r.InternalValidate(nil, true); err != nil { if err := r.InternalValidate(nil, true); err != nil {
return fmt.Errorf("resource %s: %s", k, err) validationErrors = multierror.Append(validationErrors, fmt.Errorf("resource %s: %s", k, err))
} }
} }
for k, r := range p.DataSourcesMap { for k, r := range p.DataSourcesMap {
if err := r.InternalValidate(nil, false); err != nil { if err := r.InternalValidate(nil, false); err != nil {
return fmt.Errorf("data source %s: %s", k, err) validationErrors = multierror.Append(validationErrors, fmt.Errorf("data source %s: %s", k, err))
} }
} }
return nil return validationErrors
} }
// Meta returns the metadata associated with this provider that was // Meta returns the metadata associated with this provider that was