From 31ff9e57f69ffd6b06042d13848aeebea628c6b9 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Mon, 19 Sep 2022 17:56:31 +0530 Subject: [PATCH] Validation: Use validation path in case windows path in used Current validation fails in case of windows path `C:\` because url able to parse it and provide `C` as scheme which result to following error ``` $ .\crc.exe setup -b C:\Users\prkumar\Downloads\crc_hyperv_4.11.1_amd64.crcbundle invalid C:\Users\prkumar\Downloads\crc_hyperv_4.11.1_amd64.crcbundle format (only supported http, https or docker) ``` This patch is make an assumption that in case of uri.scheme is single letter than it might be windows path and run validation path of it. As per MS document driver name shouldn't be more than single letter. https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-setup-diskconfiguration-disk-modifypartitions-modifypartition-letter --- pkg/crc/validation/validation.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/crc/validation/validation.go b/pkg/crc/validation/validation.go index d354473b3f..b7581910a7 100644 --- a/pkg/crc/validation/validation.go +++ b/pkg/crc/validation/validation.go @@ -121,6 +121,11 @@ func ValidateURL(uri string) error { // Relative paths will cause `ParseRequestURI` to error out, and will be handled in `ValidateBundlePath` case !u.IsAbs(): return ValidatePath(uri) + // In case of windows where path started with C:\ the uri scheme would be `C` + // We are going to check if the uri scheme is a single letter and assume that it is windows drive path url + // and send it to ValidatePath + case len(u.Scheme) == 1: + return ValidatePath(uri) case u.Scheme == "http", u.Scheme == "https": return nil case u.Scheme == "docker":