Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5c7a1a2c
Commit
5c7a1a2c
authored
Dec 07, 2017
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable flexvolume on Windows
parent
f875ee59
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
2 deletions
+52
-2
volume_host.go
pkg/kubelet/volume_host.go
+6
-1
plugin.go
pkg/volume/flexvolume/plugin.go
+6
-1
util.go
pkg/volume/util.go
+9
-0
util_test.go
pkg/volume/util_test.go
+31
-0
No files found.
pkg/kubelet/volume_host.go
View file @
5c7a1a2c
...
...
@@ -19,6 +19,7 @@ package kubelet
import
(
"fmt"
"net"
"runtime"
"github.com/golang/glog"
...
...
@@ -91,7 +92,11 @@ func (kvh *kubeletVolumeHost) GetVolumeDevicePluginDir(pluginName string) string
}
func
(
kvh
*
kubeletVolumeHost
)
GetPodVolumeDir
(
podUID
types
.
UID
,
pluginName
string
,
volumeName
string
)
string
{
return
kvh
.
kubelet
.
getPodVolumeDir
(
podUID
,
pluginName
,
volumeName
)
dir
:=
kvh
.
kubelet
.
getPodVolumeDir
(
podUID
,
pluginName
,
volumeName
)
if
runtime
.
GOOS
==
"windows"
{
dir
=
volume
.
GetWindowsPath
(
dir
)
}
return
dir
}
func
(
kvh
*
kubeletVolumeHost
)
GetPodVolumeDeviceDir
(
podUID
types
.
UID
,
pluginName
string
)
string
{
...
...
pkg/volume/flexvolume/plugin.go
View file @
5c7a1a2c
...
...
@@ -19,6 +19,7 @@ package flexvolume
import
(
"fmt"
"path"
"runtime"
"strings"
"sync"
...
...
@@ -100,7 +101,11 @@ func (plugin *flexVolumePlugin) Init(host volume.VolumeHost) error {
func
(
plugin
*
flexVolumePlugin
)
getExecutable
()
string
{
parts
:=
strings
.
Split
(
plugin
.
driverName
,
"/"
)
execName
:=
parts
[
len
(
parts
)
-
1
]
return
path
.
Join
(
plugin
.
execPath
,
execName
)
execPath
:=
path
.
Join
(
plugin
.
execPath
,
execName
)
if
runtime
.
GOOS
==
"windows"
{
execPath
=
volume
.
GetWindowsPath
(
execPath
)
}
return
execPath
}
// Name is part of the volume.VolumePlugin interface.
...
...
pkg/volume/util.go
View file @
5c7a1a2c
...
...
@@ -495,3 +495,12 @@ func AccessModesContainedInAll(indexedModes []v1.PersistentVolumeAccessMode, req
}
return
true
}
// GetWindowsPath get a windows path
func
GetWindowsPath
(
path
string
)
string
{
windowsPath
:=
strings
.
Replace
(
path
,
"/"
,
"
\\
"
,
-
1
)
if
strings
.
HasPrefix
(
windowsPath
,
"
\\
"
)
{
windowsPath
=
"c:"
+
windowsPath
}
return
windowsPath
}
pkg/volume/util_test.go
View file @
5c7a1a2c
...
...
@@ -869,3 +869,34 @@ func TestValidateZone(t *testing.T) {
}
}
}
func
TestGetWindowsPath
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
path
string
expectedPath
string
}{
{
path
:
`/var/lib/kubelet/pods/146f8428-83e7-11e7-8dd4-000d3a31dac4/volumes/kubernetes.io~disk`
,
expectedPath
:
`c:\var\lib\kubelet\pods\146f8428-83e7-11e7-8dd4-000d3a31dac4\volumes\kubernetes.io~disk`
,
},
{
path
:
`\var/lib/kubelet/pods/146f8428-83e7-11e7-8dd4-000d3a31dac4\volumes\kubernetes.io~disk`
,
expectedPath
:
`c:\var\lib\kubelet\pods\146f8428-83e7-11e7-8dd4-000d3a31dac4\volumes\kubernetes.io~disk`
,
},
{
path
:
`/`
,
expectedPath
:
`c:\`
,
},
{
path
:
``
,
expectedPath
:
``
,
},
}
for
_
,
test
:=
range
tests
{
result
:=
GetWindowsPath
(
test
.
path
)
if
result
!=
test
.
expectedPath
{
t
.
Errorf
(
"GetWindowsPath(%v) returned (%v), want (%v)"
,
test
.
path
,
result
,
test
.
expectedPath
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment