MCPcopy
hub / github.com/helmfile/helmfile / isSharedCachePath

Method isSharedCachePath

pkg/state/state.go:5362–5384  ·  view source on GitHub ↗

isSharedCachePath returns true if the chartPath is within the shared cache directory. Charts in the shared cache should not be deleted during refresh to prevent race conditions when multiple processes are using the same cached chart.

(chartPath string)

Source from the content-addressed store, hash-verified

5360// Charts in the shared cache should not be deleted during refresh to prevent race conditions
5361// when multiple processes are using the same cached chart.
5362func (st *HelmState) isSharedCachePath(chartPath string) bool {
5363 sharedCacheDir := remote.CacheDir()
5364 absChartPath, err := filepath.Abs(chartPath)
5365 if err != nil {
5366 st.logger.Debugf("failed to get absolute path for chartPath %q: %v", chartPath, err)
5367 return false
5368 }
5369 absSharedCache, err := filepath.Abs(sharedCacheDir)
5370 if err != nil {
5371 st.logger.Debugf("failed to get absolute path for shared cache dir %q: %v", sharedCacheDir, err)
5372 return false
5373 }
5374 resolvedChartPath, err := filepath.EvalSymlinks(absChartPath)
5375 if err != nil {
5376 resolvedChartPath = absChartPath
5377 }
5378 resolvedSharedCache, err := filepath.EvalSymlinks(absSharedCache)
5379 if err != nil {
5380 resolvedSharedCache = absSharedCache
5381 }
5382 return resolvedChartPath == resolvedSharedCache ||
5383 strings.HasPrefix(resolvedChartPath, resolvedSharedCache+string(filepath.Separator))
5384}
5385
5386// chartDownloadAction represents what action should be taken after acquiring locks
5387type chartDownloadAction int

Callers 2

acquireChartLockMethod · 0.95
TestIsSharedCachePathFunction · 0.95

Calls 2

CacheDirFunction · 0.92
AbsMethod · 0.80

Tested by 1

TestIsSharedCachePathFunction · 0.76