core: Implement ValidateFn shim for MockProvider

This commit is contained in:
Martin Atkins 2018-09-07 16:21:49 -07:00
parent d1da65b6be
commit 54be8c02d4
1 changed files with 10 additions and 2 deletions

View File

@ -151,8 +151,16 @@ func (p *MockProvider) ValidateResourceTypeConfig(r providers.ValidateResourceTy
p.ValidateResourceTypeConfigRequest = r
if p.ValidateFn != nil {
return providers.ValidateResourceTypeConfigResponse{
Diagnostics: tfdiags.Diagnostics(nil).Append(fmt.Errorf("legacy ValidateFn handling in MockProvider not actually implemented yet")),
resp := p.getSchema()
schema := resp.Provider.Block
rc := NewResourceConfigShimmed(r.Config, schema)
warns, errs := p.ValidateFn(rc)
ret := providers.ValidateResourceTypeConfigResponse{}
for _, warn := range warns {
ret.Diagnostics = ret.Diagnostics.Append(tfdiags.SimpleWarning(warn))
}
for _, err := range errs {
ret.Diagnostics = ret.Diagnostics.Append(err)
}
}
if p.ValidateResourceTypeConfigFn != nil {