Skip to content

Commit

Permalink
improve provider lock speed by using cache
Browse files Browse the repository at this point in the history
this is only possible for the architecture of the system since the cache is only for one architecture.

Closes #33837
  • Loading branch information
DanielMSchmidt committed Feb 7, 2024
1 parent 5b29b92 commit ae8941d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/command/providers_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ae8941d

Please sign in to comment.