You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an example file which is used for terraform.
`environmentName: sandbox
groups:
name: work/sbx1
variables:
name: foo
value: 123
type: int
name: bar
value: "hello"
type: string
name: foo
value: 456
type: int
name: work/sbx2
variables:
name: boo
value: 789
type: int
name: far
value: "hello"
type: string
name: boo
value: 789
type: int`
I'm using v4.45.1
I have tried various options which have thrown errors. yq eval '.groups[].variables |= uniqueBy(.value)' example_grp_prj_var.yaml Error: 1:30: invalid input text "By(.value)"
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have an example file which is used for terraform.
`environmentName: sandbox
groups:
variables:
value: 123
type: int
value: "hello"
type: string
value: 456
type: int
variables:
value: 789
type: int
value: "hello"
type: string
value: 789
type: int`
I'm using v4.45.1
I have tried various options which have thrown errors.
yq eval '.groups[].variables |= uniqueBy(.value)' example_grp_prj_var.yaml Error: 1:30: invalid input text "By(.value)"
yq eval '.groups[] |= (.variables |= uniqueBy(.value))' example_grp_prj_var.yaml Error: 1:35: invalid input text "By(.value))"
yq eval ".groups[] |= (.variables |= reduce .[] as \$item ({}; .[\$item.value] = \$item) | values)" example_grp_prj_var.yaml Error: 1:29: invalid input text "reduce .[] as $i..."
In the above example would like to see end result as:
`environmentName: sandbox
groups:
variables:
value: 123
type: int
value: "hello"
type: string
value: 456
type: int
variables:
value: 789
type: int
value: "hello"
type: string`
Your help would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions