MCPcopy
hub / github.com/argoproj/argo-workflows / FindOverlappingVolume

Function FindOverlappingVolume

workflow/common/util.go:26–38  ·  view source on GitHub ↗

FindOverlappingVolume looks an artifact path, checks if it overlaps with any user specified volumeMounts in the template, and returns the deepest volumeMount (if any). A return value of nil indicates the path is not under any volumeMount.

(tmpl *wfv1.Template, path string)

Source from the content-addressed store, hash-verified

24// user specified volumeMounts in the template, and returns the deepest volumeMount
25// (if any). A return value of nil indicates the path is not under any volumeMount.
26func FindOverlappingVolume(tmpl *wfv1.Template, path string) *apiv1.VolumeMount {
27 volumeMounts := tmpl.GetVolumeMounts()
28 sort.Slice(volumeMounts, func(i, j int) bool {
29 return len(volumeMounts[i].MountPath) > len(volumeMounts[j].MountPath)
30 })
31 for _, mnt := range volumeMounts {
32 normalizedMountPath := strings.TrimRight(mnt.MountPath, "/")
33 if path == normalizedMountPath || isSubPath(path, normalizedMountPath) {
34 return &mnt
35 }
36 }
37 return nil
38}
39
40func isSubPath(path string, normalizedMountPath string) bool {
41 return strings.HasPrefix(path, normalizedMountPath+"/")

Callers 6

saveArtifactFunction · 0.92
saveParameterFunction · 0.92
loadArtifactsMethod · 0.92
isBaseImagePathMethod · 0.92

Calls 2

isSubPathFunction · 0.85
GetVolumeMountsMethod · 0.80

Tested by 1