From ee1f70841c2979ee5fe080fbedfe7b8428f77bb6 Mon Sep 17 00:00:00 2001
From: Hidde Beydals <hello@hidde.co>
Date: Thu, 10 Dec 2020 16:24:50 +0100
Subject: [PATCH] Use path rel to working dir for kustomize build

Work around for a bug in kustomize causing it to not properly
handle absolute paths on Windows.

Signed-off-by: Hidde Beydals <hello@hidde.co>
---
 pkg/manifestgen/install/manifests.go | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/pkg/manifestgen/install/manifests.go b/pkg/manifestgen/install/manifests.go
index 5a0a556b..0052b377 100644
--- a/pkg/manifestgen/install/manifests.go
+++ b/pkg/manifestgen/install/manifests.go
@@ -105,6 +105,22 @@ func build(base, output string) error {
 		return fmt.Errorf("%s not found", kfile)
 	}
 
+	// 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
+	if filepath.IsAbs(base) {
+		wd, err := os.Getwd()
+		if err != nil {
+			return err
+		}
+		base, err = filepath.Rel(wd, base)
+		if err != nil {
+			return err
+		}
+	}
+
 	opt := krusty.MakeDefaultOptions()
 	k := krusty.MakeKustomizer(fs, opt)
 	m, err := k.Run(base)
-- 
GitLab