I have been in DevOps related jobs for past 6 years dealing mainly with Kubernetes in AWS and on-premise as well. I spent quite a lot …
:date_long | 1 min ReadInput file to process with
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
.
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
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