From 50a6f0ba2bb04846600bf3d0f5c2ff422a3c94da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Estrela?= Date: Mon, 12 Aug 2024 21:36:05 +0100 Subject: [PATCH] fix: split yaml by matching (?m)^---\n regex --- internal/manifests/manifests.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/manifests/manifests.go b/internal/manifests/manifests.go index d6dbb15..db0841a 100644 --- a/internal/manifests/manifests.go +++ b/internal/manifests/manifests.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "regexp" "strings" "github.com/ghodss/yaml" @@ -27,9 +28,11 @@ func CombineYAML(manifests [][]byte) []byte { } func SplitYAML(manifest []byte) (map[string][]byte, error) { - manifests := bytes.Split(manifest, []byte("---\n")) + separator := regexp.MustCompile(`(?m)^---\n`) + manifests := separator.Split(string(manifest), -1) manifestsByResourceTypeAndName := map[string][]byte{} - for _, manifest = range manifests { + for _, manifestStr := range manifests { + manifest := []byte(manifestStr) resource := struct { Kind string `json:"kind"` Metadata struct {