mirror of
https://github.com/rancher/rke.git
synced 2025-09-01 06:56:29 +00:00
added windows path cleaner
This commit is contained in:
@@ -1118,7 +1118,7 @@ func (c *Cluster) GetHostInfoMap() map[string]types.Info {
|
|||||||
func (c *Cluster) getPrefixPath(os string) string {
|
func (c *Cluster) getPrefixPath(os string) string {
|
||||||
switch {
|
switch {
|
||||||
case os == "windows" && c.WindowsPrefixPath != "":
|
case os == "windows" && c.WindowsPrefixPath != "":
|
||||||
return c.WindowsPrefixPath
|
return util.CleanWindowsPath(c.WindowsPrefixPath)
|
||||||
default:
|
default:
|
||||||
return c.PrefixPath
|
return c.PrefixPath
|
||||||
}
|
}
|
||||||
|
19
util/util.go
19
util/util.go
@@ -161,3 +161,22 @@ func PrintProxyEnvVars() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CleanWindowsPath(s string) string {
|
||||||
|
// clean backslashes added from encoding
|
||||||
|
var new []string
|
||||||
|
|
||||||
|
// squash multi backslashes
|
||||||
|
sp := strings.Split(s, "\\")
|
||||||
|
for _, v := range sp {
|
||||||
|
if v != "" {
|
||||||
|
new = append(new, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// drive letter only, add a trailing slash
|
||||||
|
if len(new) == 1 {
|
||||||
|
new = append(new, "")
|
||||||
|
}
|
||||||
|
return strings.Join(new, "\\")
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user