mirror of
https://github.com/rancher/rke.git
synced 2025-04-27 19:25:44 +00:00
added windows path cleaner
This commit is contained in:
parent
23d2341172
commit
de19c42611
@ -1118,7 +1118,7 @@ func (c *Cluster) GetHostInfoMap() map[string]types.Info {
|
||||
func (c *Cluster) getPrefixPath(os string) string {
|
||||
switch {
|
||||
case os == "windows" && c.WindowsPrefixPath != "":
|
||||
return c.WindowsPrefixPath
|
||||
return util.CleanWindowsPath(c.WindowsPrefixPath)
|
||||
default:
|
||||
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, "\\")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user