Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use filters outside of arrays #48

Closed
ahuffman opened this issue May 28, 2021 · 0 comments · Fixed by #49
Closed

Cannot use filters outside of arrays #48

ahuffman opened this issue May 28, 2021 · 0 comments · Fixed by #49

Comments

@ahuffman
Copy link

As a user, I would like to be able to use JSONPath filters to recursively search for a particular value on yaml nodes that are not only limited to arrays/sequence nodes.

An example of this would be when a user would like to look up all instances of a value in a kubernetes manifest, so that all instances of that value can be replaced.

Consider the following query and Kubernetes manifest:
$..[?(@ == "dns-udp")]

---
apiVersion: v1
kind: Service
metadata:
  name: bind-udp
  namespace: tanzu-dns
  labels:
    app.kubernetes.io/name: external-dns
  annotations:
    # NOTE: this only works on 1.19.1+vmware.1+, but not prior
    ## This annotation will be ignored on other cloud providers
    service.beta.kubernetes.io/aws-load-balancer-type: nlb
spec:
  selector:
    app.kubernetes.io/name: external-dns
  type: LoadBalancer
  ports:
    - name: dns-udp
      port: 53
      protocol: UDP
      targetPort: dns-udp
status: {}

I would like the yamlNodes returned which should contain the values:

[
  "dns-udp",
  "dns-udp"
]
JefeDavis pushed a commit to JefeDavis/yaml-jsonpath that referenced this issue May 28, 2021
filter expressions can now be used on all nodes not just arrays

Closes vmware-labs#48

Signed-off-by: Jeff Davis <jeffda@vmware.com>
JefeDavis added a commit that referenced this issue May 28, 2021
filter expressions can now be used on all nodes not just arrays

Closes #48

Signed-off-by: Jeff Davis <jeffda@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant