mirror of https://github.com/hashicorp/terraform
Loading schemas from some providers can be particularly expensive, since providers for large remote platforms tend to have very large schemas. Since provider schemas are needed for many operations in Terraform, callers sometimes end up loading schemas themselves anyway. Earlier work tried to mitigate this by introducing a global schema cache for all plugin-based providers, but that's problematic because it forces only a single implementation of each distinct provider source address across the entire lifetime of a process importing package providers. This does not remove that global cache yet, but does add a new capability that will hopefully eventually supplant it: callers of terraform.NewContext can provide a set of preloaded provider schemas which they must ensure would match what Terraform Core would find if it loaded the schemas from an instance of the same provider instantiated through the corresponding factory function given alongside. A caller that wishes to avoid the potential cost of multiple schema lookups can now therefore go look up the schemas itself before calling terraform.NewContext, and provide frozen schemas that we'll use instead of fetching from the associated plugins. As of this commit no callers are actually using this mechanism. The first caller will be the "stackeval" package, which already loads provider schemas in order to evaluate provider configuration blocks anyway and so should always be able to provide a full complement of preloaded schemas to avoid Terraform Core needing to do any further lookups itself.pull/34243/head
parent
42d40f73b6
commit
2cc94b4e89
Loading…
Reference in new issue