Yaml is a easily readable language for writing configuration files that store data used by different applications, like kubernetes and docker.
Yaml uses indentation to structure its data, it is also case-sensitive.
Yaml files can have the .yaml or .yml extension.
Yaml uses variables and objects. Objects serve as "containers" for the variables or other objects.
Data in YAML files:
Data in a Yaml file has the below format:
Access to the color variable could be done through: "automobile.color" for example.
If we have multiple automobiles, we can put them in a list:
The pink line that starts with a "#" is a comment, it is not taken into account by Yaml.
Sold variable is a boolean variable that could have the "true" or the "false" value.
We can also have a list including just the brands of the cars:
Another way to write the available_colors list is as below:
We could see above, two ways of defining lists members in the employee object.Nested objects:
"Owner" is a nested object inside the "automobile" object.
Accessing environmental variable:
We use the "$" sign to access environmental variables:
When we write a variable "paragraph" as a multi-line text (for visibility reason) and we want Yaml to interpret it as a line , we use the ">" sign:
If we want to preserve the formatting of our variable "paragraph" and keep it as we wrote , we use the "|" sign:
If we want Yaml to interpret a variable as a "float" or as a "string" we use the below:
Number is interpreted as a float 1.0
String is interpreted as a string "23"