schema: Return all validation errors together from InternalValidate
This commit is contained in:
parent
37be25b312
commit
b90ab0b705
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue