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

Inconsistent results with recursive descent with filter expression #49

Open
rspurgeon opened this issue Apr 21, 2023 · 0 comments
Open

Comments

@rspurgeon
Copy link
Contributor

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:

Screenshot 2023-04-21 at 9 52 28 AM

Screenshot 2023-04-21 at 9 52 37 AM

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

No branches or pull requests

1 participant