What is the canonical YAML naming style

Use the standard dictated by the surrounding software. For example, in my current project the YAML file contains default values for Python attributes. Since the names used in YAML appear in the associated Python API, it is clear that on this particular project, the YAML names should obey the Python lower_case_with_underscores naming convention per PEP-8. … Read more

Syntax for empty dictionary in YAML

Short answer: use {} There are two ways to denote mappings (dictionaries) in yaml; flow mappings and block mappings: block_mapping: name: foo id: bar flow_mapping: { name: foo, id: bar } empty_flow_mapping: {} The flow mapping style is thus suitable for representing empty mappings.

What is the use of the pipe symbol in YAML?

The pipe symbol at the end of a line in YAML signifies that any indented text that follows should be interpreted as a multi-line scalar value. See the YAML spec. Specifically, the pipe indicates that (except for the indentation) the scalar value should be interpreted literally in such a way that preserves newlines. Conversely, the … Read more

How to set multiple commands in one yaml file with Kubernetes?

command: [“/bin/sh”,”-c”] args: [“command one; command two && command three”] Explanation: The command [“/bin/sh”, “-c”] says “run a shell, and execute the following instructions”. The args are then passed as commands to the shell. In shell scripting a semicolon separates commands, and && conditionally runs the following command if the first succeed. In the above … Read more

YAML Multi-Line Arrays

A YAML sequence is an array. So this is the right way to express it: key: – string1 – string2 – string3 – string4 – string5 – string6 That’s identical in meaning to: key: [‘string1’, ‘string2’, ‘string3’, ‘string4’, ‘string5’, ‘string6′] It’s also legal to split a single-line array over several lines: key: [‘string1’, ‘string2’, ‘string3’, … Read more

why — (3 dashes/hyphen) in yaml file?

As you already found out, the three dashes — are used to signal the start of a document, i.e.: To signal the document start after directives, i.e., %YAML or %TAG lines according to the current spec. For example: %YAML 1.2 %TAG !foo! !foo-types/ — myKey: myValue To signal the document start when you have multiple … Read more

Is it .yaml or .yml?

The nature and even existence of file extensions is platform-dependent (some obscure platforms don’t even have them, remember) — in other systems they’re only conventional (UNIX and its ilk), while in still others they have definite semantics and in some cases specific limits on length or character content (Windows, etc.). Since the maintainers have asked … Read more