Skip to content

Commit

Permalink
fix: split yaml by matching (?m)^---\n regex
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoestrela committed Aug 12, 2024
1 parent a68bda3 commit 50a6f0b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/manifests/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"regexp"
"strings"

"github.com/ghodss/yaml"
Expand All @@ -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 {
Expand Down

0 comments on commit 50a6f0b

Please sign in to comment.