I will explain the basic of YAML. What there are ? How to use it with some usefull edge case I used.
YAML mean YAML lskjfslkdjflk, if you are a devops you need to know yaml. It’s frequenly used in IaC, CICD, Kubernetes and docker compose.
first I will define all the element:
string need ” if you use special character. Also for speciale caratere use html site and unicode site.
Folding Strings
Strings can also be written in blocks and be interpreted without the new line characters using the fold operator (greater than). message: > even though it looks like this is a multiline message, it is actually not The above YAML snippet is interpreted as in the output below. message: “even though it looks like this is a multiline message,it is actually not” Block strings
Strings can be interpreted as blocks using the block (pipe) character. message: | this is a real multiline message This is interpreted with the new lines (\n) as below. message: this is a real multiline message Chomp characters
Multiline strings may end with whitespaces. Preserve chomp(+) and strip chomp operators can be used either to preserve or strip the whitespaces. They can be used with block and pipe characters.
Preserving new line character message: >+ This block line Will be interpreted as a single line with a newline character at the end The above snippet is interpreted as below in JSON { “message”: “This block line Will be interpreted as a single line with a newline character at the end\n” } Stripping new line character message: >- This block line Will be interpreted as a single line without the newline character at the end The above snippet is interpreted as below in JSON. { “message”: “This block line Will be interpreted as a single line without the newline character at the end” }
Schema ?
how are literal treded ? as int string ? well it depend for the parser for your endpoint (api) it have a schema. But you can force the type
---
theatre: !!str ugc
open: !!bool true
movies:
- !!str deadpool
- !!str the batman
prices:
- child: !!int 3
- adulte: !!int 9
- studant: !!int 7
- andicape: !!int 6
to avoid cp and mv a lot of refereche you can link alias. you can even overrides some var
service1:
config: &service_config
env: prod
retries: 3
version: 4.8
service2:
config:
<<: *service_config
version: 5
service3:
config:
<<: *service_config
version: 4.2