<p>I run <code>kubectl apply</code> for this file:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: test
  namespace: test
data:
  folded: &gt;-
    {
      &quot;field1&quot;: 1,
      &quot;test2&quot;: &quot;test&quot;
    }

  literal: |-
    {
      &quot;field1&quot;: 1,
      &quot;test2&quot;: &quot;test&quot;
    }
  
  single-quoted:
    '{
      &quot;field1&quot;: 1,
      &quot;test2&quot;: &quot;test&quot;
    }'
</code></pre>
<p>And I get this result after running <code>kubectl describe</code>:</p>
<pre><code>Data
====
folded:
----
{
  &quot;field1&quot;: 1,
  &quot;test2&quot;: &quot;test&quot;
}
literal:
----
{
  &quot;field1&quot;: 1,
  &quot;test2&quot;: &quot;test&quot;
}
single-quoted:
----
{ &quot;field1&quot;: 1, &quot;test2&quot;: &quot;test&quot; }
</code></pre>
<p>According to the documentation if I got things right I was expecting <code>folded</code> to be the same as <code>single-quoted</code>, i.e. in one line, but this does not happen. Am I doing something wrong?</p>

Ilya Chernomordik
<p>This is actually by design and due to extra spaces in json:</p>
<p>If you insert extra spaces at the start of not-the-first lines in Folded style, they will be kept, with a bonus newline. (This doesn't happen with flow styles.) <a href="https://yaml.org/spec/1.2.2/#65-line-folding" rel="nofollow noreferrer">Section 6.5 of the YAML 1.2.2 spec</a>:</p>
<blockquote>
<p>In addition, folding does not apply to line breaks surrounding text
lines that contain leading white space. Note that such a more-indented
line may consist only of such leading white space.</p>
</blockquote>
<p>This will work as I intended:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: test
  namespace: test
data:
  folded: &gt;-
    {
    &quot;field1&quot;: 1,
    &quot;test2&quot;: &quot;test&quot;
    }

</code></pre>
