feat: annotation to disable list conversion

This commit is contained in:
isarns
2024-08-11 17:44:44 +03:00
parent cc9dd34216
commit a1fd6efe5d
3 changed files with 138 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import (
"encoding/json"
"fmt"
"log"
"strconv"
"strings"
"sigs.k8s.io/kustomize/api/ifc"
@@ -189,6 +190,16 @@ func (rf *Factory) inlineAnyEmbeddedLists(
var n0 *yaml.RNode
for len(nodes) > 0 {
n0, nodes = nodes[0], nodes[1:]
annotations := n0.GetAnnotations()
convertToInlineList, err := strconv.ParseBool(annotations["kustomize.config.k8s.io/convertToInlineList"])
if err != nil {
convertToInlineList = true
}
if !convertToInlineList {
// if the annotation is set to true, then we should not convert the list to inline
result = append(result, n0)
continue
}
kind := n0.GetKind()
if !strings.HasSuffix(kind, "List") {
result = append(result, n0)