update terraform with PrepareProviderConfig

Change the call sites and update the MockProvider. No core behavior is
changed yet.
This commit is contained in:
James Bardin 2018-10-17 21:29:15 -04:00
parent 3bdd3b2a6e
commit 155f899249
3 changed files with 15 additions and 15 deletions

View File

@ -603,7 +603,7 @@ func TestContext2Validate_providerConfig_bad(t *testing.T) {
), ),
}) })
p.ValidateProviderConfigResponse = providers.ValidateProviderConfigResponse{ p.PrepareProviderConfigResponse = providers.PrepareProviderConfigResponse{
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")), Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")),
} }
@ -641,7 +641,7 @@ func TestContext2Validate_providerConfig_badEmpty(t *testing.T) {
), ),
}) })
p.ValidateProviderConfigResponse = providers.ValidateProviderConfigResponse{ p.PrepareProviderConfigResponse = providers.PrepareProviderConfigResponse{
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")), Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")),
} }
@ -709,7 +709,7 @@ func TestContext2Validate_provisionerConfig_bad(t *testing.T) {
}, },
}) })
p.ValidateProviderConfigResponse = providers.ValidateProviderConfigResponse{ p.PrepareProviderConfigResponse = providers.PrepareProviderConfigResponse{
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")), Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")),
} }

View File

@ -98,11 +98,11 @@ func (n *EvalValidateProvider) Eval(ctx EvalContext) (interface{}, error) {
return nil, diags.NonFatalErr() return nil, diags.NonFatalErr()
} }
req := providers.ValidateProviderConfigRequest{ req := providers.PrepareProviderConfigRequest{
Config: configVal, Config: configVal,
} }
validateResp := provider.ValidateProviderConfig(req) validateResp := provider.PrepareProviderConfig(req)
diags = diags.Append(validateResp.Diagnostics) diags = diags.Append(validateResp.Diagnostics)
return nil, diags.NonFatalErr() return nil, diags.NonFatalErr()

View File

@ -26,10 +26,10 @@ type MockProvider struct {
GetSchemaCalled bool GetSchemaCalled bool
GetSchemaReturn *ProviderSchema // This is using ProviderSchema directly rather than providers.GetSchemaResponse for compatibility with old tests GetSchemaReturn *ProviderSchema // This is using ProviderSchema directly rather than providers.GetSchemaResponse for compatibility with old tests
ValidateProviderConfigCalled bool PrepareProviderConfigCalled bool
ValidateProviderConfigResponse providers.ValidateProviderConfigResponse PrepareProviderConfigResponse providers.PrepareProviderConfigResponse
ValidateProviderConfigRequest providers.ValidateProviderConfigRequest PrepareProviderConfigRequest providers.PrepareProviderConfigRequest
ValidateProviderConfigFn func(providers.ValidateProviderConfigRequest) providers.ValidateProviderConfigResponse PrepareProviderConfigFn func(providers.PrepareProviderConfigRequest) providers.PrepareProviderConfigResponse
ValidateResourceTypeConfigCalled bool ValidateResourceTypeConfigCalled bool
ValidateResourceTypeConfigTypeName string ValidateResourceTypeConfigTypeName string
@ -133,16 +133,16 @@ func (p *MockProvider) getSchema() providers.GetSchemaResponse {
return ret return ret
} }
func (p *MockProvider) ValidateProviderConfig(r providers.ValidateProviderConfigRequest) providers.ValidateProviderConfigResponse { func (p *MockProvider) PrepareProviderConfig(r providers.PrepareProviderConfigRequest) providers.PrepareProviderConfigResponse {
p.Lock() p.Lock()
defer p.Unlock() defer p.Unlock()
p.ValidateProviderConfigCalled = true p.PrepareProviderConfigCalled = true
p.ValidateProviderConfigRequest = r p.PrepareProviderConfigRequest = r
if p.ValidateProviderConfigFn != nil { if p.PrepareProviderConfigFn != nil {
return p.ValidateProviderConfigFn(r) return p.PrepareProviderConfigFn(r)
} }
return p.ValidateProviderConfigResponse return p.PrepareProviderConfigResponse
} }
func (p *MockProvider) ValidateResourceTypeConfig(r providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse { func (p *MockProvider) ValidateResourceTypeConfig(r providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse {