kubernetes / client-go

Go client for Kubernetes.
Apache License 2.0
8.78k stars 2.9k forks source link

util/jsonpath in client-go support "['" "']" to escape dot(.) in the path when working with unstructured.Unstructured object #1281

Closed kuanf closed 11 months ago

kuanf commented 12 months ago

If an object contains dot (.) in the key, such as

metadata:
  labels:
    app.kubernetes.io/name: myapp

according to jsonpath.com the path to that label value is .metadata.labels.['app.kubernetes.io/name'].

Labels and Annotations are simplest and most frequent case to have dot(.) in the key. Developers can easily create CRD with map[string][string] or map[string]Object in their spec.

Please correct me if I'm wrong, it seems current util/jsonpath package does not support [' ']. In the cases above, the FindResults() in util/jsonpath won't be able to find the right result(s). :(

Will you consider that feature?

kuanf commented 11 months ago

found this duplicated to #1018