From 3552bf8f05fd7cc17759248218be9210d310419c Mon Sep 17 00:00:00 2001 From: David Zager Date: Tue, 6 Aug 2024 13:46:58 -0400 Subject: [PATCH] :bug: handle volume creation on windows (#307) Signed-off-by: David Zager --- cmd/analyze.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/analyze.go b/cmd/analyze.go index 9f90bf8..ac18728 100644 --- a/cmd/analyze.go +++ b/cmd/analyze.go @@ -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",