Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/oc/cli/set/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"path"
"path/filepath"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -667,7 +667,7 @@ func (o *VolumeOptions) setVolumeMount(spec *kapi.PodSpec, info *resource.Info)

for _, c := range containers {
for _, m := range c.VolumeMounts {
if path.Clean(m.MountPath) == path.Clean(opts.MountPath) && m.Name != o.Name {
if filepath.Clean(m.MountPath) == filepath.Clean(opts.MountPath) && m.Name != o.Name {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.... that's not quite correct, b/c in containers we always want to use forward slashes, that's why path was being used here. Have you got a chance to verify this on a windows machine?

Copy link
Contributor Author

@sallyom sallyom Aug 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, i see. I'll set up a development Win machine, I started doing that but then this looked straight forward - i was wrong on that, though, I'll set it up and will report back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soltysh I was able to test this in Windows :) while the path->path/filepath change results in no undesired prefix, it does end up with backwards rather than forward slash in the mountPath. See here: https://bugzilla.redhat.com/show_bug.cgi?id=1807714#c10

return fmt.Errorf("volume mount '%s' already exists for container '%s'", opts.MountPath, c.Name)
}
}
Expand All @@ -679,11 +679,11 @@ func (o *VolumeOptions) setVolumeMount(spec *kapi.PodSpec, info *resource.Info)
}
volumeMount := &kapi.VolumeMount{
Name: o.Name,
MountPath: path.Clean(opts.MountPath),
MountPath: filepath.Clean(opts.MountPath),
ReadOnly: opts.ReadOnly,
}
if len(opts.SubPath) > 0 {
volumeMount.SubPath = path.Clean(opts.SubPath)
volumeMount.SubPath = filepath.Clean(opts.SubPath)
}
c.VolumeMounts = append(c.VolumeMounts, *volumeMount)
}
Expand All @@ -704,7 +704,7 @@ func (o *VolumeOptions) getVolumeName(spec *kapi.PodSpec, singleResource bool) (
matchCount := 0
for _, c := range containers {
for _, m := range c.VolumeMounts {
if path.Clean(m.MountPath) == path.Clean(opts.MountPath) {
if filepath.Clean(m.MountPath) == filepath.Clean(opts.MountPath) {
name = m.Name
matchCount++
break
Expand Down