From f720a060ffa814b6ffbb5ead02f4a54499b7eb90 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Thu, 8 Feb 2024 13:10:41 +0100 Subject: [PATCH] use plugin cache for provider lock across for all platforms The cache architecture already supports multi-platform, the only downside is that this might grow the cache. This seems expected. --- internal/command/providers_lock.go | 4 ++-- internal/providercache/dir.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/command/providers_lock.go b/internal/command/providers_lock.go index cb6b26f266..d0b82abbe2 100644 --- a/internal/command/providers_lock.go +++ b/internal/command/providers_lock.go @@ -249,8 +249,8 @@ func (c *ProvidersLockCommand) Run(args []string) int { // 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) + if globalCacheDir != nil { + installer.SetGlobalCacheDir(globalCacheDir.WithPlatform(platform)) installer.SetGlobalCacheDirMayBreakDependencyLockFile(c.PluginCacheMayBreakDependencyLockFile) } diff --git a/internal/providercache/dir.go b/internal/providercache/dir.go index c11a14192e..eab987e453 100644 --- a/internal/providercache/dir.go +++ b/internal/providercache/dir.go @@ -75,6 +75,12 @@ func (d *Dir) BasePath() string { return filepath.Clean(d.baseDir) } +// WithPlatform creates a new dir with the provided platform based +// on this dir +func (d *Dir) WithPlatform(platform getproviders.Platform) *Dir { + return NewDirWithPlatform(d.baseDir, platform) +} + // AllAvailablePackages returns a description of all of the packages already // present in the directory. The cache entries are grouped by the provider // they relate to and then sorted by version precedence, with highest