Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YAML mapping values are not allowed in this context

Tags:

yaml

I am trying to configure a YAML file in this format:

jobs:  - name: A    - schedule: "0 0/5 * 1/1 * ? *"    - type: mongodb.cluster     - config:        - host: mongodb://localhost:27017/admin?replicaSet=rs        - minSecondaries: 2        - minOplogHours: 100        - maxSecondaryDelay: 120  - name: B    - schedule: "0 0/5 * 1/1 * ? *"    - type: mongodb.cluster     - config:        - host: mongodb://localhost:27017/admin?replicaSet=rs        - minSecondaries: 2        - minOplogHours: 100        - maxSecondaryDelay: 120 

The idea is that I can read the contents inside the job element, and have a series of different job configs which can be parsed.

however, yamllint.com tells me that this is illegal YAML due to mapping values are not allowed in this context at line 2 where line 2 is the jobs: line.

What am I doing wrong?

like image 535
Chris Edwards Avatar asked Jul 09 '15 09:07

Chris Edwards


People also ask

What is a mapping value in Yaml?

Flow mappings in YAML represent the unordered collection of key value pairs. They are also called as mapping node. Note that keys should be maintained unique. If there is a duplication of keys in flow mapping structure, it will generate an error.

What is Yaml syntax?

YAML syntaxYAML has features that come from Perl, C, XML, HTML, and other programming languages. YAML is also a superset of JSON, so JSON files are valid in YAML. YAML uses Python-style indentation to indicate nesting. Tab characters are not allowed, so whitespaces are used instead.


1 Answers

This is valid YAML:

jobs:  - name: A    schedule: "0 0/5 * 1/1 * ? *"    type: mongodb.cluster    config:      host: mongodb://localhost:27017/admin?replicaSet=rs      minSecondaries: 2      minOplogHours: 100      maxSecondaryDelay: 120  - name: B    schedule: "0 0/5 * 1/1 * ? *"    type: mongodb.cluster    config:      host: mongodb://localhost:27017/admin?replicaSet=rs      minSecondaries: 2      minOplogHours: 100      maxSecondaryDelay: 120 

Note, that every '-' starts new element in the sequence. Also, indentation of keys in the map should be exactly same.

like image 83
Tsyvarev Avatar answered Oct 02 '22 18:10

Tsyvarev