Inconsistent results with recursive descent with filter expression
rspurgeon opened this issue · 0 comments
rspurgeon commented
In the repo we have a sample deck file: docs/summertime-kong.yml
that has one service and one route and the route is defined under the service.
Applying a patch with a selector that uses recursive descent and a filter expression results in (I believe) inconsistent results:
The first example's selector is explicit in the path to the routes:
> kced patch -s docs/summertime-kong.yml --selector '$.services[*].routes[?(@.name=="summer-time_get")]' --value 'field:"foo"'
_format_version: "3.0"
services:
- host: mockbin.org
id: b1525aee-d304-11ed-afa1-0242ac120002
name: summer-time
path: /requests
plugins: []
port: 443
protocol: https
routes:
- field: foo
id: b7d87736-d304-11ed-afa1-0242ac120002
methods:
- GET
name: summer-time_get
paths:
- ~/summer-time$
plugins: []
regex_priority: 200
strip_path: false
tags: []
In the second example we use recursive descent which should result in the same behavior, but do not get the expected results:
❯ kced patch -s docs/summertime-kong.yml --selector '$..routes[?(@.name=="summer-time_get")]' --value 'field:"foo"'
_format_version: "3.0"
services:
- host: mockbin.org
id: b1525aee-d304-11ed-afa1-0242ac120002
name: summer-time
path: /requests
plugins: []
port: 443
protocol: https
routes:
- id: b7d87736-d304-11ed-afa1-0242ac120002
methods:
- GET
name: summer-time_get
paths:
- ~/summer-time$
plugins: []
regex_priority: 200
strip_path: false
tags: []
Using https://jsonpath.com/ to validate, I see the following: