Questions tagged [yq]
yq is the name of two tools for interpreting and processing YAML (one Python based and one Go/CLI based).
394
questions
0
votes
0
answers
33
views
yq returning item is referenced but not assigned in nix script
I'm trying to merge 2 yaml files with a similar key in both files.
I've tried a variety of yq commands and have ultimately managed to get the following command to work locally.
yq eval-all '. as $item ...
0
votes
1
answer
39
views
Adding items with default values to empty array with yq (go)
ok I've been in contact with chatgpt and gemmini on this and they are really out to lunch a lot of the time.
I am using https://github.com/mikefarah/yq
I am reading from xml and need to ensure single ...
0
votes
1
answer
37
views
YQ - how to filter an array by field value if matching at least one element in a list
Specifically (https://github.com/mikefarah/yq) 4.35+
I have a comma-separated string of terms and I want to filter down a list if a field value is one of those terms.
Ex) Given the following input:
- ...
0
votes
1
answer
57
views
Add item to list in yq if it doesn't already exist
Using mikefarah's yq v4 I want to conditionally add an IP address to a list within a yml file if it does not exist in the list already.
Given a file like:
servers:
web:
- 1.1.1.1
jobs:
- 2....
1
vote
1
answer
34
views
Simple yq (go) to join key values and output to markdown
I am trying to use the go version of yq to produce markdown from a json array.
Given the following json array:
[
{ "en": "cat", "fr": "chat" },
{ "...
0
votes
1
answer
49
views
Adding values to YAML file
`
I want to append an entry in namespaceAdmin,namespaceDebugger in the below yaml file using yq. Basically it has got multiple patches and I want to make changes in some of the helmrelease patches. Is ...
0
votes
0
answers
110
views
How do I use `yq` to count the number of yaml documents present in multidocument yaml file that uses the `---` separator?
Given yaml file:
---
one: hey
---
two: you
---
How do I use yq to count the number of distinct yaml documents in the file?
yq ea '. as $item ireduce (0; . + 1)'
yields
3
3
3
and
yq e '. as $item ...
-2
votes
1
answer
83
views
how to use yq with ansible to generate quotes around inserted items?
I am trying to add some items in an YAML file, calling yq (v4.43.1) from ansible (core 2.16.5).
It inserts the values correctly, but without the quotes that would make it a valid yaml file.
Now I am ...
1
vote
1
answer
53
views
going back to 1 document after `.[]` in yq
Case 1
With input
- groupx:
- groupy:
The yq expression length evals to 2
Case 2
With input
groupx:
groupy:
The yq expression length also evals to 2
Case 3 - using splat (.[]) to transform case1 to ...
0
votes
1
answer
61
views
Conditional statement in yq parser for updating script
I m trying to replace a string value in a yaml file and I m not able to get the if working.
YAML file
apiVersion: kots.io/v1beta1
kind: Config
metadata:
name: enterprise
spec:
groups:
- name: ...
1
vote
1
answer
301
views
how to read a yaml file in bash shell and iterate through a list inside
I have this yaml file
I have a yaml file as below:
repos:
- REPO_NAME: A
INGRESS_SUBDOMAIN: B
DOCKER_IMAGE_PATH: C
IMAGE_NAME: D
MAJOR_VERSION: E
MINOR_VERSION: F
the name of the file is f....
0
votes
1
answer
129
views
yq deal with list items that can be values or objects
I'm trying to do some pipeline work that injects certain values in a yaml document (an mkdocs config) if they are not currently present. But the problem is that the current values can be either items ...
0
votes
1
answer
175
views
Delete an entry with the key matching regex using yq
I have a json like this:
{
"sha256key": [
"438143050f234146300c44ed7e22be698e1e3c8c6bbc89b5c7e6276e8250a3a7"
],
"validkey": [
"...
1
vote
1
answer
73
views
yq traverse complex values and convert to json file
I have a complex yaml and want to extract information from it using bash script.
The yaml is like:
content:
images:
sha256:4c8b96d4fffdfae29258d94a22ae4ad1fe36139d47288b8960d9958d1e63a9d0:
...
0
votes
1
answer
54
views
Inverse operation for a yaml merge such as yq multiply?
Many application read several input files and merge them logically such that inputs with higher priority override previously read fields.
For yaml files, we can achieve this logic using a merge ...