-
Notifications
You must be signed in to change notification settings - Fork 36
Migrate devfile specific vol code from odo to devfile/library #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,3 +419,46 @@ func getBuildConfigSpec(buildConfigSpecParams BuildConfigSpecParams) *buildv1.Bu | |
}, | ||
} | ||
} | ||
|
||
// GetVolumeMountPath gets the volume mount's path. | ||
func GetVolumeMountPath(volumeMount v1.VolumeMount) string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason we want to make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. odo is using it in some of their code, i will move it to generators.go |
||
// if there is no volume mount path, default to volume mount name as per devfile schema | ||
if volumeMount.Path == "" { | ||
volumeMount.Path = "/" + volumeMount.Name | ||
} | ||
|
||
return volumeMount.Path | ||
} | ||
|
||
// getPVC gets a pvc type volume with the given volume name and pvc name. | ||
func getPVC(volumeName, pvcName string) corev1.Volume { | ||
|
||
return corev1.Volume{ | ||
Name: volumeName, | ||
VolumeSource: corev1.VolumeSource{ | ||
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ | ||
ClaimName: pvcName, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
// addVolumeMountToContainers adds the Volume Mounts in containerNameToMountPaths to the containers for a given volumeName. | ||
// containerNameToMountPaths is a map of a container name to an array of its Mount Paths. | ||
func addVolumeMountToContainers(containers []corev1.Container, volumeName string, containerNameToMountPaths map[string][]string) { | ||
|
||
for containerName, mountPaths := range containerNameToMountPaths { | ||
for i := range containers { | ||
if containers[i].Name == containerName { | ||
for _, mountPath := range mountPaths { | ||
containers[i].VolumeMounts = append(containers[i].VolumeMounts, corev1.VolumeMount{ | ||
Name: volumeName, | ||
MountPath: mountPath, | ||
SubPath: "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we simplify these checks?