1
0
mirror of synced 2026-02-25 09:46:55 +00:00

Fix bootstrap failure on Windows when working directory is on different drive than TEMP

When running flux bootstrap from a drive (e.g. D:\) different from
where %TEMP% lives (typically C:\), filepath.Rel fails because Go
can't compute relative paths across different drive letters.

The original code converted absolute paths to relative as a workaround
for a kustomize bug (kubernetes-sigs/kustomize#2789) that was caused
by go-getter. Since kustomize dropped go-getter in 2021, absolute
paths work fine now. Instead of hard-failing when filepath.Rel errors,
keep the absolute path as a fallback.

Signed-off-by: Varun Chawla <varun_6april@hotmail.com>
This commit is contained in:
Varun Chawla
2026-02-22 20:27:12 -08:00
parent 8362c88791
commit 5e5ee73046

View File

@@ -169,19 +169,19 @@ func BuildWithRoot(root, base string) ([]byte, error) {
return nil, fmt.Errorf("%s not found", konfig.DefaultKustomizationFileName())
}
// TODO(hidde): work around for a bug in kustomize causing it to
// not properly handle absolute paths on Windows.
// Convert the path to a relative path to the working directory
// as a temporary fix:
// https://github.com/kubernetes-sigs/kustomize/issues/2789
// Convert absolute paths to relative when possible, for kustomize
// compatibility. If filepath.Rel fails (e.g. paths on different
// Windows drives), keep the absolute path — kustomize handles
// absolute paths correctly since go-getter was removed.
// See: https://github.com/kubernetes-sigs/kustomize/issues/2789
// https://github.com/fluxcd/flux2/issues/1153
if filepath.IsAbs(base) {
wd, err := os.Getwd()
if err != nil {
return nil, err
}
base, err = filepath.Rel(wd, base)
if err != nil {
return nil, err
if relBase, err := filepath.Rel(wd, base); err == nil {
base = relBase
}
}