Skip to content

Commit

Permalink
Add RO/RW options to extraMount
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Kim <oats87g@gmail.com>
  • Loading branch information
Oats87 committed Aug 3, 2021
1 parent ad5af17 commit 4be20c1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/staticpod/staticpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,21 @@ func addExtraMounts(p *v1.Pod, extraMounts []string) {

for i, rawMount := range extraMounts {
mount := strings.Split(rawMount, ":")
if len(mount) != 2 {
if len(mount) != 2 || len(mount) != 3 {
logrus.Errorf("mount for pod %s %s was not valid", p.Name, rawMount)
continue
}
var ro bool
if len(mount) == 3 {
switch strings.ToLower(mount[2]) {
case "ro":
ro = true
case "rw":
ro = false
default:
logrus.Errorf("unknown mount option: %s encountered in extra mount %s for pod %s", mount[2], rawMount, p.Name)
}
}
name := fmt.Sprintf("%s-%d", prefix, i)
p.Spec.Volumes = append(p.Spec.Volumes, v1.Volume{
Name: name,
Expand All @@ -293,7 +304,7 @@ func addExtraMounts(p *v1.Pod, extraMounts []string) {
})
p.Spec.Containers[0].VolumeMounts = append(p.Spec.Containers[0].VolumeMounts, v1.VolumeMount{
Name: name,
ReadOnly: false,
ReadOnly: ro,
MountPath: mount[1],
})
}
Expand Down

0 comments on commit 4be20c1

Please sign in to comment.