[manifests] hoist the regex out of SplitManifests

pull/4358/head
Mike Lundy 7 years ago
parent 0a9c16f42b
commit 15ef839ff4

@ -23,14 +23,17 @@ import (
"k8s.io/helm/pkg/releaseutil"
)
var (
kindRegex = regexp.MustCompile("kind:(.*)\n")
)
// SplitManifests takes a map of rendered templates and splits them into the
// detected manifests.
func SplitManifests(templates map[string]string) []Manifest {
var listManifests []Manifest
// extract kind and name
re := regexp.MustCompile("kind:(.*)\n")
for k, v := range templates {
match := re.FindStringSubmatch(v)
match := kindRegex.FindStringSubmatch(v)
h := "Unknown"
if len(match) == 2 {
h = strings.TrimSpace(match[1])

Loading…
Cancel
Save