What does this error mean? Is it due to indentation? Is there any way to auto align yaml files
I tried fixing it by aligning etc but it didn't work and my jenkins build is failing.
- name: SPLUNK_LOG_TOKEN
valueFrom:
secretKeyRef:
name: splunk-secret
key: splunk.token
- name: SPLUNK_LOG_URL //error in this line
valueFrom:
configMapKeyRef:
name: splunk-config
key: splunk.url
The following is invalid YAML (in both items):
- name: SPLUNK_LOG_TOKEN
valueFrom:
This is because valueFrom is more indented than name. Thus YAML thinks that valueFrom is a continuation of the scalar SPLUNK_LOG_TOKEN. However, a : follows which ends an implicit mapping key. And implicit mapping keys are forbidden in a multi-line scalar context, hence the error.
Is there any way to auto align yaml files
Indentation in YAML is part of the semantic (like in Python). You are basically asking whether you can guess the intended semantic for badly indented files. While this is theoretically not impossible (I mean, you could train a neural network on YAML syntax questions on StackOverflow; I have seen this particular problem countless times), I don't think a readily usable solution exists.
The probable solution for your problem is
- name: SPLUNK_LOG_TOKEN
valueFrom:
however, I can't be 100% sure; perhaps you rather want to do something like
- name:
id: SPLUNK_LOG_TOKEN
valueFrom:
if valueFrom should be a child of name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With