From 7a5b9e2991569120463acbe627da451b58df8dae Mon Sep 17 00:00:00 2001
From: Hidde Beydals <hello@hidde.co>
Date: Thu, 10 Dec 2020 18:26:41 +0100
Subject: [PATCH] Use rel filepath in auto generated kustomization

This works around another bug on Windows platforms that would cause the
kustomize-controller to choke on the kustomization.yaml generated by the
bootstrap command due to the filepath being in a Windows format.

By using `filepath.Rel`, the output is _just_ the filename for files
relative to the bootstrap path, which is at the moment sufficient to
make it work.

Signed-off-by: Hidde Beydals <hello@hidde.co>
---
 internal/utils/utils.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/internal/utils/utils.go b/internal/utils/utils.go
index 094f88b4..eb372612 100644
--- a/internal/utils/utils.go
+++ b/internal/utils/utils.go
@@ -323,7 +323,11 @@ func GenerateKustomizationYaml(dirPath string) error {
 
 		var resources []string
 		for _, file := range files {
-			resources = append(resources, strings.Replace(file, abs, ".", 1))
+			relP, err := filepath.Rel(abs, file)
+			if err != nil {
+				return err
+			}
+			resources = append(resources, relP)
 		}
 
 		kus.Resources = resources
-- 
GitLab