1
0
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:
Luther Monson 2020-08-19 15:31:10 -07:00
parent 23d2341172
commit de19c42611
2 changed files with 20 additions and 1 deletions

View File

@ -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
}

View File

@ -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, "\\")
}