'how to solve Parsing expression Lexer error yq
I am using yq
for YAML processor. I got this error:
Error: Parsing expression: Lexer error: could not match text starting at 1:8 failing at 1:10. unmatched text: "to"
Following is the code:
function query() {
cat "$SOURCE" | yq eval "$@" -
}
function get_env_for_url() {
local URL="$1"
local ENV_URL=$(query ".env | to_entries | .[] | select( .value.url == \"$URL\") | .key")
echo $ENV_URL
}
sample YAML file:
env:
app:
url: abc.com
dev:
url: dev.com
data:
url: data.com
How to solve Parsing expression: Lexer error?
Solution 1:[1]
you must quote your values that contains dots
env:
app:
url: "abc.com"
dev:
url: "dev.com"
data:
url: "data.com"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Adán Escobar |