func applyVolumeThings[T corev1.VolumeMount | corev1.Volume]()

in internal/workload/podspec_updates.go [987:1008]


func applyVolumeThings[T corev1.VolumeMount | corev1.Volume](
	s *updateState,
	newVols []T,
	nameAccessor func(T) string,
	thingAccessor func(*managedVolume) T) []T {

	// add or replace items for all new volume mounts
	for i := 0; i < len(s.mods.VolumeMounts); i++ {
		var found bool
		newVol := thingAccessor(s.mods.VolumeMounts[i])
		for j := 0; j < len(newVols); j++ {
			if nameAccessor(newVol) == nameAccessor(newVols[j]) {
				found = true
				newVols[j] = newVol
			}
		}
		if !found {
			newVols = append(newVols, newVol)
		}
	}
	return newVols
}