此上下文中不允许使用 YAML 映射值 [英] YAML mapping values are not allowed in this context
本文介绍了此上下文中不允许使用 YAML 映射值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试以这种格式配置 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
这个想法是我可以读取 job 元素中的内容,并有一系列可以解析的不同作业配置.
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.
然而,yamllint.com 告诉我这是非法的 YAML,因为 映射值不是在此上下文中允许在第 2 行
,其中 line 2
是 jobs:
行.
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.
我做错了什么?
推荐答案
这是有效的 YAML:
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.
这篇关于此上下文中不允许使用 YAML 映射值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文