Skip to content

Commit 324f8e8

Browse files
authored
Merge pull request #7375 from sbueringer/pr-clusterctl-overrides-folder-win
🐛 clusterctl: support Windows paths in overridesFolder
2 parents c9b4a0f + a92c0b0 commit 324f8e8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

cmd/clusterctl/client/repository/overrides.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ package repository
1818

1919
import (
2020
"fmt"
21+
"net/url"
2122
"os"
2223
"path/filepath"
24+
"runtime"
2325
"strings"
2426

2527
"github.com/drone/envsubst/v2"
@@ -79,6 +81,19 @@ func (o *overrides) Path() string {
7981
} else {
8082
basepath = evaluatedBasePath
8183
}
84+
85+
if runtime.GOOS == "windows" {
86+
parsedBasePath, err := url.Parse(basepath)
87+
if err != nil {
88+
logf.Log.Info(fmt.Sprintf("⚠️overridesFolder %q could not be parsed: %v", basepath, err))
89+
} else {
90+
// in case of windows, we should take care of removing the additional / which is required by the URI standard
91+
// for windows local paths. see https://blogs.msdn.microsoft.com/ie/2006/12/06/file-uris-in-windows/ for more details.
92+
// Encoded file paths are not required in Windows 10 versions <1803 and are unsupported in Windows 10 >=1803
93+
// https://support.microsoft.com/en-us/help/4467268/url-encoded-unc-paths-not-url-decoded-in-windows-10-version-1803-later
94+
basepath = filepath.FromSlash(strings.TrimPrefix(parsedBasePath.Path, "/"))
95+
}
96+
}
8297
}
8398

8499
return filepath.Join(

cmd/clusterctl/client/repository/repository_local.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ func newLocalRepository(providerConfig config.Provider, configVariablesClient co
148148
// for windows local paths. see https://blogs.msdn.microsoft.com/ie/2006/12/06/file-uris-in-windows/ for more details.
149149
// Encoded file paths are not required in Windows 10 versions <1803 and are unsupported in Windows 10 >=1803
150150
// https://support.microsoft.com/en-us/help/4467268/url-encoded-unc-paths-not-url-decoded-in-windows-10-version-1803-later
151-
path = strings.TrimPrefix(path, "/")
152-
path = filepath.FromSlash(path)
151+
path = filepath.FromSlash(strings.TrimPrefix(path, "/"))
153152
}
154153
if !filepath.IsAbs(path) {
155154
return nil, errors.Errorf("invalid path: path %q must be an absolute path", providerConfig.URL())

0 commit comments

Comments
 (0)