forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: terraform.ResourceProvider.GetSchema method
In order to parse provider, resource and data source configuration from HCL2 config files, we need to know the relevant configuration schema. This new method allows Terraform Core to request these from a provider. This is a breaking change to this interface, so all of its implementers in this package are updated too. This includes concrete implementations of the new method in helper/schema that use the schema conversion code added in an earlier commit to produce a configschema.Block automatically. Plugins compiled against prior versions of helper/schema will not have support for this method, and so calls to them will fail. Callers of this new method will therefore need to sniff for support using the SchemaAvailable field added to both ResourceType and DataSource. This careful handling will need to persist until next time we increment the plugin protocol version, at which point we can make the breaking change of requiring this information to be available.
- Loading branch information
1 parent
ccb328c
commit 183833a
Showing
8 changed files
with
238 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package terraform | ||
|
||
import ( | ||
"github.com/hashicorp/terraform/config/configschema" | ||
) | ||
|
||
type Schemas struct { | ||
Providers ProviderSchemas | ||
} | ||
|
||
// ProviderSchemas is a map from provider names to provider schemas. | ||
// | ||
// The names in this map are the direct plugin name (e.g. "aws") rather than | ||
// any alias name (e.g. "aws.foo"), since. | ||
type ProviderSchemas map[string]*ProviderSchema | ||
|
||
// ProviderSchema represents the schema for a provider's own configuration | ||
// and the configuration for some or all of its resources and data sources. | ||
// | ||
// The completeness of this structure depends on how it was constructed. | ||
// When constructed for a configuration, it will generally include only | ||
// resource types and data sources used by that configuration. | ||
type ProviderSchema struct { | ||
Provider *configschema.Block | ||
ResourceTypes map[string]*configschema.Block | ||
DataSources map[string]*configschema.Block | ||
} | ||
|
||
// ProviderSchemaRequest is used to describe to a ResourceProvider which | ||
// aspects of schema are required, when calling the GetSchema method. | ||
type ProviderSchemaRequest struct { | ||
ResourceTypes []string | ||
DataSources []string | ||
} |