found a config validation bug where packer crashes instead of throwing a validation error if a windows-style path is provided to a provisioner on linux

This commit is contained in:
Megan Marsh 2018-06-22 13:49:39 -07:00
parent a861946f08
commit 4a7953f93a
1 changed files with 9 additions and 2 deletions

View File

@ -215,6 +215,13 @@ func ConvertToLinuxPath(winAbsPath string) (string, error) {
// get absolute path of script, and morph it into the bash path // get absolute path of script, and morph it into the bash path
winAbsPath = strings.Replace(winAbsPath, "\\", "/", -1) winAbsPath = strings.Replace(winAbsPath, "\\", "/", -1)
splitPath := strings.SplitN(winAbsPath, ":/", 2) splitPath := strings.SplitN(winAbsPath, ":/", 2)
winBashPath := fmt.Sprintf("/mnt/%s/%s", strings.ToLower(splitPath[0]), splitPath[1]) if len(splitPath) == 2 {
return winBashPath, nil winBashPath := fmt.Sprintf("/mnt/%s/%s", strings.ToLower(splitPath[0]), splitPath[1])
return winBashPath, nil
} else {
err := fmt.Errorf("There was an error splitting your absolute path; expected "+
"to find a drive following the format ':/' but did not: absolute "+
"path: %s", winAbsPath)
return "", err
}
} }