yaml 中的“>-”和“|-”有什么区别?

Bgu*_*ess 5 yaml kubernetes

我想确切地知道 '>-' 和 '|-' 之间的区别,特别是在 kubernetes yaml 清单中

fly*_*lyx 17

折叠块标量 ( >) 中的换行符会进行行折叠,而文字块标量 ( |) 中的换行符则不会。

行折叠将非空行之间的单个换行符替换为空格,并且在空行的情况下,将周围非空行之间的换行符数量减少 1:

a: > # folds into "one two\nthree four\n\nfive\n"
  one
  two

  three
  four


  five
Run Code Online (Sandbox Code Playgroud)

当至少一行缩进较多时,即在开头包含不属于块的一般缩进的空白时,行之间不会发生行折叠:

a: > # folds into "one\n  two\nthree four\n\n five\n"
  one
    two
  three
  four

   five
Run Code Online (Sandbox Code Playgroud)

在or-之后添加将从最后一行中删除换行符:|>

a: >- # folded into "one two"
  one
  two
b: >- # folded into "one\ntwo"
  one

  two
Run Code Online (Sandbox Code Playgroud)

相反,|按原样发出每个换行符,唯一的例外是如果您使用 则最后一个换行符-