yq select

1 개요[ | ]

yq select

2 값 매칭[ | ]

2.1 와일드카드[ | ]

root@wsl:~# cat sample.yml
- cat
- goat
- dog
root@wsl:~# yq '.[] | select(. == "*at")' sample.yml
cat
goat

2.2 정규표현식[ | ]

root@wsl:~# cat sample.yml
- this_0
- not_this
- nor_0_this
- thisTo_4
root@wsl:~# yq '.[] | select(test("[a-zA-Z]+_[0-9]$"))' sample.yml
this_0
thisTo_4

3 키 매칭[ | ]

root@wsl:~# cat sample.yml
name: bob
legs: 2
game: poker
root@wsl:~# yq 'with_entries(select(.key | test("ame$")))' sample.yml
name: bob
game: poker

4 기타[ | ]

root@wsl:~# curl -s https://raw.githubusercontent.com/kubernetes/ingress-nginx/helm-chart-4.4.2/deploy/static/provider/baremetal/deploy.yaml | yq 'select(.kind == "IngressClass")'
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  labels:
    app.kubernetes.io/component: controller
    app.kubernetes.io/instance: ingress-nginx
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
    app.kubernetes.io/version: 1.5.1
  name: nginx
spec:
  controller: k8s.io/ingress-nginx

5 같이 보기[ | ]

6 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}