mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Suggested changes
This commit is contained in:
@@ -29,20 +29,21 @@ func DeriveSeqIndentStyle(originalYAML string) string {
|
||||
|
||||
numSpacesBeforeKeyElem := len(keyLine) - len(strings.TrimLeft(keyLine, " "))
|
||||
trimmedKeyLine := strings.Trim(keyLine, " ")
|
||||
if strings.HasSuffix(trimmedKeyLine, "|") || strings.HasSuffix(trimmedKeyLine, "|-") {
|
||||
if strings.Count(trimmedKeyLine, ":") != 1 || !strings.HasSuffix(trimmedKeyLine, ":") {
|
||||
// if the key line doesn't contain only one : that too at the end,
|
||||
// this is not a sequence node, it is a wrapped sequence node string
|
||||
// ignore it
|
||||
continue
|
||||
}
|
||||
|
||||
if numSpacesBeforeSeqElem == numSpacesBeforeKeyElem {
|
||||
return string(CompactSeqIndent)
|
||||
return string(CompactSequenceStyle)
|
||||
}
|
||||
|
||||
if numSpacesBeforeSeqElem-numSpacesBeforeKeyElem == 2 {
|
||||
return string(WideSeqIndent)
|
||||
return string(WideSequenceStyle)
|
||||
}
|
||||
}
|
||||
|
||||
return string(CompactSeqIndent)
|
||||
return string(CompactSequenceStyle)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user