mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
fc0e28b2b4
It is common for the same module source package to be referenced multiple times in the same configuration, either because there are literally multiple instances of the same module source or because a single package (or repository) contains multiple modules in sub-directories and many of them are referenced. To optimize this, here we introduce a simple caching behavior where the module installer will detect if it's asked to install multiple times from the same source and produce the second and subsequent directories by copying the first, rather than by downloading again over the network. This optimization is applied once all of the go-getter detection has completed and sub-directory portions have been trimmed, so it is also able to normalize differently-specified source addresses that all ultimately detect to the same resolved address. When installing, we always extract the entire specified package (or repository) and then reference the specified sub-directory, so we can safely re-use existing directories when the base package is the same, even if the sub-directory is different. However, as a result we do not yet address the fact that the same package will be stored multiple times _on disk_, which may still be problematic when referencing large repositories multiple times in disk-storage-constrained environments. We could address this in a subsequent change by investigating the use of symlinks where possible. Since the Registry installer is implemented just as an extra resolution step in front of go-getter, this optimization applies to registry modules too. This does not apply to local relative references, which will continue to just resolve into the already-prepared directory of their parent module. The cache of previously installed paths lives only for the duration of one call to InstallModules, so we will never re-use directories that were created by previous runs of "terraform init" and there is no risk that older versions will pollute the cache when attempting an upgrade from a source address that doesn't explicitly specify a version. No additional tests are added here because the existing module installer tests (when TF_ACC=1) already cover the case of installing multiple modules from the same source. |
||
---|---|---|
.. | ||
configload | ||
test-fixtures | ||
backend.go | ||
compat_shim.go | ||
config_build_test.go | ||
config_build.go | ||
config.go | ||
depends_on.go | ||
doc.go | ||
module_call_test.go | ||
module_call.go | ||
module_merge_body.go | ||
module_merge_test.go | ||
module_merge.go | ||
module.go | ||
named_values.go | ||
parser_config_dir_test.go | ||
parser_config_dir.go | ||
parser_config_test.go | ||
parser_config.go | ||
parser_test.go | ||
parser_values_test.go | ||
parser_values.go | ||
parser.go | ||
provider.go | ||
provisioner.go | ||
provisioneronfailure_string.go | ||
provisionerwhen_string.go | ||
resource.go | ||
synth_body_test.go | ||
synth_body.go | ||
util.go | ||
variable_type_hint.go | ||
variabletypehint_string.go | ||
version_constraint.go |