terraform/internal/plugin
Martin Atkins 2cc94b4e89 core: terraform.Context with preloaded provider schemas
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.
2023-11-14 13:01:56 -08:00
..
convert Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
discovery Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
mock_proto Add GetMetadata RPC to provider protocol (#33739) 2023-08-24 14:35:42 -04:00
grpc_error.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
grpc_provider.go core: terraform.Context with preloaded provider schemas 2023-11-14 13:01:56 -08:00
grpc_provider_test.go add mock tests for GetProviderSchemaOptional 2023-09-05 18:05:32 -04:00
grpc_provisioner.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
grpc_provisioner_test.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
plugin.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
serve.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
ui_input.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
ui_input_test.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
ui_output.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
ui_output_test.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00