providers PrepareProviderConfig
Change ValidateProviderConfig to PrepareProviderConfig. Providers have a concept of "required fields with defaults" that that was handled previously by helper/schema doing input and validation. Because Input and Validation is mostly now handled by core, the provider had no way of setting default values for missing required attributes. To achieve the same behavior with new providers, there will be a PrepareProviderConfig, which allow for manual validation, as well as alteration of the config. The provider is free to set whatever attributes necessary to create a valid config and return it to the caller. If a new config is returned, it will be used instead of the original in the subsequent Configure call, however core may still add missing required values during an optional Input phase.
This commit is contained in:
parent
55c3f9b9c0
commit
c1303f8482
|
@ -14,9 +14,9 @@ type Interface interface {
|
|||
// GetSchema returns the complete schema for the provider.
|
||||
GetSchema() GetSchemaResponse
|
||||
|
||||
// ValidateProviderConfig allows the provider to validate the configuration
|
||||
// values.
|
||||
ValidateProviderConfig(ValidateProviderConfigRequest) ValidateProviderConfigResponse
|
||||
// PrepareProviderConfig allows the provider to validate the configuration
|
||||
// values, and set or override any values with defaults.
|
||||
PrepareProviderConfig(PrepareProviderConfigRequest) PrepareProviderConfigResponse
|
||||
|
||||
// ValidateResourceTypeConfig allows the provider to validate the resource
|
||||
// configuration values.
|
||||
|
@ -90,12 +90,14 @@ type Schema struct {
|
|||
Block *configschema.Block
|
||||
}
|
||||
|
||||
type ValidateProviderConfigRequest struct {
|
||||
// Config is the complete configuration value for the provider.
|
||||
type PrepareProviderConfigRequest struct {
|
||||
// Config is the raw configuration value for the provider.
|
||||
Config cty.Value
|
||||
}
|
||||
|
||||
type ValidateProviderConfigResponse struct {
|
||||
type PrepareProviderConfigResponse struct {
|
||||
// PreparedConfig is the configuration as prepared by the provider.
|
||||
PreparedConfig cty.Value
|
||||
// Diagnostics contains any warnings or errors from the method call.
|
||||
Diagnostics tfdiags.Diagnostics
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue