Skip to content

Commit

Permalink
Change function name to containsVolume
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <[email protected]>
  • Loading branch information
rubenvp8510 committed Jul 11, 2024
1 parent 33abac3 commit 827c8e5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/manifests/manifestutils/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func MountCAConfigMap(
ReadOnly: true,
})

volumeIndex, _ := findVolumeIndex(pod, caConfigMap)
if volumeIndex < 0 {
hasVolume := containsVolume(pod, caConfigMap)
if !hasVolume {
pod.Volumes = append(pod.Volumes, corev1.Volume{
Name: caConfigMap,
VolumeSource: corev1.VolumeSource{
Expand Down Expand Up @@ -63,8 +63,8 @@ func MountCertSecret(
ReadOnly: true,
})

volumeIndex, _ := findVolumeIndex(pod, certSecret)
if volumeIndex < 0 {
hasVolume := containsVolume(pod, certSecret)
if !hasVolume {
pod.Volumes = append(pod.Volumes, corev1.Volume{
Name: certSecret,
VolumeSource: corev1.VolumeSource{
Expand Down Expand Up @@ -126,12 +126,12 @@ func findContainerIndex(pod *corev1.PodSpec, containerName string) (int, error)
return -1, fmt.Errorf("cannot find container %s", containerName)
}

func findVolumeIndex(pod *corev1.PodSpec, volumeName string) (int, error) {
for i, volume := range pod.Volumes {
func containsVolume(pod *corev1.PodSpec, volumeName string) bool {
for _, volume := range pod.Volumes {
if volume.Name == volumeName {
return i, nil
return true
}
}

return -1, fmt.Errorf("cannot find volume %s", volumeName)
return false
}

0 comments on commit 827c8e5

Please sign in to comment.