-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix support for forward slashes in cd_files for Windows (#115)
Packer recommends that we use "/" as the path separator. There is a problem with using it on Windows because of the following behaviour: We might pass paths with forward slashes in `StepCreateCD` struct The string `rootFolder, err := tmp.Dir("packer_to_cdrom")` makes rootFolder use system-based slashes, which is "\" for Windows. This rootFolder is passed to `s.AddFile(rootFolder, toAdd)` And a mix of two slashes ruins our replace logic while going through the `visit` function. We end up having different slashes for `allDirs` and `discardPath` in `intermediaryDirs := strings.Replace(allDirs, discardPath, "", 1)` We change our replace login to don't depend on slashes. The tests we had didn't cover such cases as we passed all files with paths constructed with filepath.Join(dir, fname) which returns paths with "\\" on Windows. So we added a test case to specifically check forward slashes.
- Loading branch information
1 parent
2d9e9f3
commit f0d8f56
Showing
2 changed files
with
21 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters