HELM YAML - 有时需要 spaces/tabs 但有时不需要的数组值?
HELM YAML - arrays values that sometimes requires spaces/tabs but sometimes not?
当涉及到数组和配置时,我很困惑何时使用空格,何时不使用空格。
我认为对于单值数组你需要使用空格:
即:
values:
- "hello"
- "bye"
- "yes"
然而这是错误的:
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata:
direction: in
当值是映射时,helm 解释器在我添加空格时抱怨:
error: error parsing deploy.yaml: error converting YAML to JSON: yaml: line 12: did not find expected '-' indicator
不当我不:
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata:
direction: in
我似乎找不到任何关于此的规则。
YAML 中的对象数组可以以空格开头,也可以不以空格开头。两者在 YAML 语法中均有效。
values:
- "hello"
- "bye"
- "yes"
values:
- "hello"
- "bye"
- "yes"
确保同一块的键必须在同一列。
样本:
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata: # "metadata" and "type" in the same column
direction: in
或
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata:
direction: in
当涉及到数组和配置时,我很困惑何时使用空格,何时不使用空格。
我认为对于单值数组你需要使用空格:
即:
values:
- "hello"
- "bye"
- "yes"
然而这是错误的:
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata:
direction: in
当值是映射时,helm 解释器在我添加空格时抱怨:
error: error parsing deploy.yaml: error converting YAML to JSON: yaml: line 12: did not find expected '-' indicator
不当我不:
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata:
direction: in
我似乎找不到任何关于此的规则。
YAML 中的对象数组可以以空格开头,也可以不以空格开头。两者在 YAML 语法中均有效。
values:
- "hello"
- "bye"
- "yes"
values:
- "hello"
- "bye"
- "yes"
确保同一块的键必须在同一列。
样本:
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata: # "metadata" and "type" in the same column
direction: in
或
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata:
direction: in