From b90ab0b705f9c693038a0f508bb927cbcc367fa8 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Sat, 27 Aug 2016 10:33:19 +0100 Subject: [PATCH] schema: Return all validation errors together from InternalValidate --- helper/schema/provider.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/helper/schema/provider.go b/helper/schema/provider.go index c9ec7194e..546794f40 100644 --- a/helper/schema/provider.go +++ b/helper/schema/provider.go @@ -5,6 +5,7 @@ import ( "fmt" "sort" + "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform/terraform" ) @@ -69,24 +70,25 @@ func (p *Provider) InternalValidate() error { return errors.New("provider is nil") } + var validationErrors error sm := schemaMap(p.Schema) if err := sm.InternalValidate(sm); err != nil { - return err + validationErrors = multierror.Append(validationErrors, err) } for k, r := range p.ResourcesMap { 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 { 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