From ae8941d4507a269281b05074727202993728f547 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 this is only possible for the architecture of the system since the cache is only for one architecture. 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 fa0235735da7..cb6b26f2666d 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(