From 2c98e6a3472cfb836c5ef68c3d3f6ee6ddcd1d44 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Wed, 7 Feb 2024 18:54:34 +0100 Subject: [PATCH] improve provider lock speed by using cache Closes #33837 --- internal/command/providers_lock.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/command/providers_lock.go b/internal/command/providers_lock.go index fa0235735d..cb6b26f266 100644 --- a/internal/command/providers_lock.go +++ b/internal/command/providers_lock.go @@ -243,9 +243,17 @@ func (c *ProvidersLockCommand) Run(args []string) int { } ctx := evts.OnContext(ctx) + // We can not use c.providerGlobalCacheDir() as we install the provider into a temp dir dir := providercache.NewDirWithPlatform(tempDir, platform) installer := providercache.NewInstaller(dir, source) + // Use global plugin cache for extra speed if this architecture matches the systems (and therefore the caches) one + globalCacheDir := c.providerGlobalCacheDir() + if globalCacheDir != nil && platform == getproviders.CurrentPlatform { + installer.SetGlobalCacheDir(globalCacheDir) + installer.SetGlobalCacheDirMayBreakDependencyLockFile(c.PluginCacheMayBreakDependencyLockFile) + } + newLocks, err := installer.EnsureProviderVersions(ctx, oldLocks, reqs, providercache.InstallNewProvidersForce) if err != nil { diags = diags.Append(tfdiags.Sourceless(