From 29f14a58fbfb27a6f61def05efa75240a052f87b Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Thu, 17 Sep 2020 03:01:34 +0000 Subject: [PATCH] Add 'content/posts/yaml-multiline.md' --- content/posts/yaml-multiline.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 content/posts/yaml-multiline.md diff --git a/content/posts/yaml-multiline.md b/content/posts/yaml-multiline.md new file mode 100644 index 0000000..9283c0f --- /dev/null +++ b/content/posts/yaml-multiline.md @@ -0,0 +1,27 @@ +--- +title: "YAML multiline values" +date: 2020-09-17 +draft: false +tags: + - yaml +images: +- /images/yaml-multiline.gif +--- + +After using YAML for a long time, for many, many Kubernetes manifest files, I have today learnt that it contains two multiline value types (called scalars): + +```yaml +scalarsExample: + literalScalar: | + Literal scalars use the pipe (`|`) to denote the start of the value with the scope indicated by indentation. + All content here is used literally, with newlines preserved. + <-- This is the start of the line, the spaces before this aren't included in the literal. + This should be used when storing things like file contents (e.g. in a ConfigMap) + foldedScalar: > + Folded scalars use the greater-than symbol (`>`) to denote the start of the value with the scope indicated by indentation. + Unlike literal scalars newlines aren't preserved and instead converted into spaces. + <-- This is the start of the line, the spaces before this aren't included in the value. + This should be used when you'd normally use a string but the contents are long and wrapping makes it easier to read. +``` + +> More info: https://yaml.org/spec/1.2/spec.html#id2760844 \ No newline at end of file