opentofu/configs
Martin Atkins fc0e28b2b4 configload: Don't download the same module source multiple times
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.
2018-10-16 18:50:29 -07:00
..
configload configload: Don't download the same module source multiple times 2018-10-16 18:50:29 -07:00
test-fixtures configs: parse the "providers" map for module calls 2018-10-16 18:44:26 -07:00
backend.go command: Various updates for the new backend package API 2018-10-16 18:44:26 -07:00
compat_shim.go configs: Handle object constructor keys when shimming traversals 2018-10-16 18:49:20 -07:00
config_build_test.go configs/configload: package for loading configurations 2018-02-15 15:56:38 -08:00
config_build.go configs: use addrs.Module for module path, rather than []string 2018-10-16 18:46:46 -07:00
config.go configs: NewEmptyConfig function 2018-10-16 18:44:26 -07:00
depends_on.go configs: quoted keywords/references are warnings, not errors 2018-02-15 15:56:39 -08:00
doc.go configs: Additional guidance in doc.go 2018-02-15 15:56:39 -08:00
module_call_test.go configs: parse the "providers" map for module calls 2018-10-16 18:44:26 -07:00
module_call.go configs: parse the "providers" map for module calls 2018-10-16 18:44:26 -07:00
module_merge_body.go configs: Export MergeBodies and new SynthBody function 2018-10-16 18:24:47 -07:00
module_merge_test.go configs: allow full type constraints for variables 2018-03-08 16:23:35 -08:00
module_merge.go configs: Re-unify the ManagedResource and DataResource types 2018-10-16 18:44:26 -07:00
module.go configs: Allow looking up resources by resource addresses. 2018-10-16 18:46:46 -07:00
named_values.go configs: Helper methods to integrate with "addrs" package 2018-10-16 18:44:26 -07:00
parser_config_dir_test.go configs: record the source directory for modules 2018-10-16 18:46:46 -07:00
parser_config_dir.go configload: Configuration snapshots 2018-10-16 18:50:29 -07:00
parser_config_test.go configs: allow full type constraints for variables 2018-03-08 16:23:35 -08:00
parser_config.go configs: allow full type constraints for variables 2018-03-08 16:23:35 -08:00
parser_test.go configs: Implementation of mergeBody 2018-02-15 15:56:38 -08:00
parser_values_test.go configs: update values file invalid syntax test for new HCL behavior 2018-03-08 11:17:39 -08:00
parser_values.go configs: Parser.LoadValuesFile 2018-02-15 15:56:37 -08:00
parser.go configs: Parser type 2018-02-15 15:56:36 -08:00
provider.go configs: Helper methods to integrate with "addrs" package 2018-10-16 18:44:26 -07:00
provisioner.go don't hanlde "type" when parsing connection blocks 2018-10-16 18:49:20 -07:00
provisioneronfailure_string.go configs: stub out main configuration structs 2018-02-15 15:56:37 -08:00
provisionerwhen_string.go configs: stub out main configuration structs 2018-02-15 15:56:37 -08:00
resource.go don't hanlde "type" when parsing connection blocks 2018-10-16 18:49:20 -07:00
synth_body_test.go configs: Export MergeBodies and new SynthBody function 2018-10-16 18:24:47 -07:00
synth_body.go configs: Export MergeBodies and new SynthBody function 2018-10-16 18:24:47 -07:00
util.go configs: allow overrides files to omit args that primary files can't 2018-02-15 15:56:38 -08:00
variable_type_hint.go configs: stub out main configuration structs 2018-02-15 15:56:37 -08:00
variabletypehint_string.go configs: stub out main configuration structs 2018-02-15 15:56:37 -08:00
version_constraint.go configs: Parser.LoadConfigFile 2018-02-15 15:56:37 -08:00