|
|
|
@ -26,6 +26,7 @@ import (
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"path"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"regexp"
|
|
|
|
"slices"
|
|
|
|
"slices"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
|
@ -62,6 +63,7 @@ import (
|
|
|
|
var Timestamper = time.Now
|
|
|
|
var Timestamper = time.Now
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
|
|
|
|
compactDocSeparatorPattern = regexp.MustCompile(`(?m)^---(?=\S)`)
|
|
|
|
// errMissingChart indicates that a chart was not provided.
|
|
|
|
// errMissingChart indicates that a chart was not provided.
|
|
|
|
errMissingChart = errors.New("no chart provided")
|
|
|
|
errMissingChart = errors.New("no chart provided")
|
|
|
|
// errMissingRelease indicates that a release (name) was not provided.
|
|
|
|
// errMissingRelease indicates that a release (name) was not provided.
|
|
|
|
@ -159,7 +161,9 @@ func annotateAndMerge(files map[string]string) (string, error) {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
manifests, err := kio.ParseAll(content)
|
|
|
|
// Go template whitespace trimming can produce lines like `---apiVersion: ...`.
|
|
|
|
|
|
|
|
// Normalize those into valid document separators before YAML parsing.
|
|
|
|
|
|
|
|
manifests, err := kio.ParseAll(normalizeDocSeparators(content))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return "", fmt.Errorf("parsing %s: %w", fname, err)
|
|
|
|
return "", fmt.Errorf("parsing %s: %w", fname, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -178,6 +182,10 @@ func annotateAndMerge(files map[string]string) (string, error) {
|
|
|
|
return merged, nil
|
|
|
|
return merged, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func normalizeDocSeparators(content string) string {
|
|
|
|
|
|
|
|
return compactDocSeparatorPattern.ReplaceAllString(content, "---\n")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// splitAndDeannotate reconstructs individual files from a merged YAML stream,
|
|
|
|
// splitAndDeannotate reconstructs individual files from a merged YAML stream,
|
|
|
|
// removing filename annotations and grouping documents by their original filenames.
|
|
|
|
// removing filename annotations and grouping documents by their original filenames.
|
|
|
|
func splitAndDeannotate(postrendered string) (map[string]string, error) {
|
|
|
|
func splitAndDeannotate(postrendered string) (map[string]string, error) {
|
|
|
|
|