Skip to content

Commit

Permalink
🐛 handle volume creation on windows (#307) (#310)
Browse files Browse the repository at this point in the history
Signed-off-by: David Zager <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
Co-authored-by: David Zager <[email protected]>
  • Loading branch information
konveyor-ci-bot[bot] and djzager authored Aug 6, 2024
1 parent 4f0692e commit 4230b9c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,21 @@ func (a *analyzeCommand) createContainerVolume() (string, error) {
if a.isFileInput {
input = filepath.Dir(input)
}
if runtime.GOOS == "windows" {
// TODO(djzager): Thank ChatGPT
// Extract the volume name (e.g., "C:")
// Remove the volume name from the path to get the remaining part
// Convert backslashes to forward slashes
// Remove the colon from the volume name and convert to lowercase
volumeName := filepath.VolumeName(input)
remainingPath := input[len(volumeName):]
remainingPath = filepath.ToSlash(remainingPath)
driveLetter := strings.ToLower(strings.TrimSuffix(volumeName, ":"))

// Construct the Linux-style path
input = fmt.Sprintf("/mnt/%s%s", driveLetter, remainingPath)
}

args := []string{
"volume",
"create",
Expand Down

0 comments on commit 4230b9c

Please sign in to comment.