turbonomic / orm

Operator Resource Mapping
Apache License 2.0
5 stars 13 forks source link

escape dot in jsonpath #40

Closed kuanf closed 1 year ago

kuanf commented 1 year ago

Use case 1 - labels:

metadata:
  labels:
    "ibm.com/type": "app"

Use case 2 - special field:

spec:
  components:
    ibm.com:
      websphere:
        resources:

In order to work with fields with dot in the key, we can't use jsonpath like .metadata.labels.ibm.com/type or .spec.ibm.com.websphere.resources

According to evaluator from https://jsonpath.com/

the right way is to use .metadata.labels.['ibm.com/type'] .spec.['ibm.com'].websphere.resources

we need to support that approach.

kuanf commented 1 year ago

the jsonpath package in client-go v0.26.1 used currently does not support [' and '] to quote string, created an issue there .

we may need to do an ugly implementation ourselves.

jsonpath patterns to support:

with filters

kuanf commented 1 year ago

It seems the community is not responding to this issue. We'll do a quick/ugly implementation to support keys in metadata.labels and metadata.annotations with dot(.). (e.g. .metadata.labels.['ibm.com']) But not other generic fields.

labels and annotations could be used to reference some keyword from owned resource. With this change more mappings could be folded by 1 pattern.