How to select entries with sso_team_id using jq
How to select entries with sso_team_id using jq
How to select entries with sso_team_id using jq
Goal
How to choose only records that have sso_team_id key defined?
Input file to process with jq and yq.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
identities:
team1:
oidc: oidc
type: external
metadata:
version: 1
description: cloud team
policies:
- aaa-admin
sso_team_id: VLT-TEAM_1
team2:
oidc: oidc
type: external
metadata:
version: 1
description: cloud team
policies:
- aaa-admin
team3:
oidc: oidc
type: external
metadata:
version: 1
description: cloud team
policies:
- aaa-admin
sso_team_id: VLT-TEAM_3
Processing
1
2
3
4
5
6
yq -o=json eval /tmp/aaa.yaml | jq '.identities | [keys[] as $k | {($k): .[$k].sso_team_id}] | add | with_entries(select(.value |.!=null))'
{
"team1": "VLT-TEAM_1",
"team3": "VLT-TEAM_3"
}
Links:
202406051206
This post is licensed under CC BY 4.0 by the author.
