Skip to content

[dmt] fix YAML document splitting for block scalars#362

Open
diyliv wants to merge 2 commits into
mainfrom
fix/yaml-block-scalar-doc-split
Open

[dmt] fix YAML document splitting for block scalars#362
diyliv wants to merge 2 commits into
mainfrom
fix/yaml-block-scalar-doc-split

Conversation

@diyliv
Copy link
Copy Markdown
Contributor

@diyliv diyliv commented May 17, 2026

Summary

  • handle YAML block scalar headers with indentation/chomping indicators when splitting rendered manifests
  • keep document separators inside ConfigMap string data intact
  • add regression tests for |2 block scalars with embedded ---

Example

A ConfigMap can contain another YAML stream as plain string data. Helm and Kubernetes accept this manifest: the |2 marker starts a YAML literal block scalar with an explicit indentation indicator, so the nested --- is just text inside data.apply-on-startup.yaml.

apiVersion: v1
kind: ConfigMap
metadata:
  name: xxx
data:
  apply-on-startup.yaml: |2
    kind: token
    version: v2
    metadata:
      name: teleport-proxy
    ---
    kind: token
    version: v2
    metadata:
      name: teleport-appservice

Before the fix, DMT only recognized |, |-, >, and >- as multiline scalar markers. It did not recognize |2, so the rendered manifest splitter treated the indented --- as a Kubernetes document separator.

As a result, DMT effectively tried to parse the second half as a standalone manifest:

kind: token
version: v2
metadata:
  name: teleport-appservice

That could fail during manifest unmarshalling with an error like:

manifest ("templates/config.yaml") unmarshal: error converting YAML to JSON: yaml: line 2: mapping values are not allowed in this context

After the fix, DMT recognizes block scalar values by prefix, so |2, |+, |-2, >2, and similar valid YAML forms enter multiline mode. The embedded --- stays inside the ConfigMap string value, and DMT parses the whole ConfigMap as one rendered Kubernetes manifest.

@diyliv diyliv changed the title Fix YAML document splitting for block scalars [dmt] fix YAML document splitting for block scalars May 17, 2026
@diyliv diyliv self-assigned this May 17, 2026
@diyliv diyliv added enhancement New feature or request go Pull requests that update go code labels May 17, 2026
@diyliv diyliv requested a review from ipaqsa May 17, 2026 17:26
@diyliv diyliv force-pushed the fix/yaml-block-scalar-doc-split branch from 2961334 to 887b0f3 Compare May 17, 2026 17:31
Signed-off-by: diyliv <onlogn081@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant