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

[FEAT] Please document that selector are using JSONata #153

Closed
mook-as opened this issue Nov 16, 2020 · 11 comments
Closed

[FEAT] Please document that selector are using JSONata #153

mook-as opened this issue Nov 16, 2020 · 11 comments
Labels
enhancement New feature or request waiting-for-response Indicates a maintainer asked a question that must be answered by contributors before proceeding

Comments

@mook-as
Copy link

mook-as commented Nov 16, 2020

Is your feature request related to a problem? Please describe.
I'm using a kv2 store, with a key that had a dash: foo-bar.
This produced errors that we difficult to resolve: Unable to retrieve result for data.data.foo-bar. No match data was found. Double check your Key or Selector.

Upon reading the source code, I found references to JSONata; reading their docs, I found that I could escape things with backquotes, and this resolved the issue.

Describe the solution you'd like
Please add in the relevant section in the README that the selector syntax is using JSONata.

Describe alternatives you've considered
I guess ripping the library out and doing something home-grown is fine too? But that seems like a lot of work, and the actual problem is just documenting it (which would have to be done either way).

Additional context

uses: hashicorp/vault-action@v2.0.1
@mook-as mook-as added the enhancement New feature or request label Nov 16, 2020
@doowb
Copy link

doowb commented Apr 21, 2021

In case this is helpful to anyone else that needs to retrieve the entire JSON object from the secret, you can use $.$ as the selector:

secrets: secret/path/to/my-secret $.$ | MY_SECRET;

Just using $ or * might have worked with jsonata, but the selector is quoted here when it doesn't contain a .. It would be nice to be able to just do . or * to get the entire object, but I think that would be a separate feature request and I'm not sure where it would fit.

@anthonydahanne
Copy link

@doowb thanks so much for sharing $.$ - I could not find another way to grab the entire JSON under data.data !!!

@dcmoore-gd
Copy link

Same thank you @doowb!

@RichiCoder1
Copy link
Contributor

This has bit enough people that I'll see if I can document this as well as add an easier wildcard shortcut.

@dcmoore-gd
Copy link

Wonderful, thank you @RichiCoder1!

@benkeil
Copy link

benkeil commented Jul 29, 2022

after one year, any progress here? how could such a basic feature not be included from the first day?

@atomlab
Copy link

atomlab commented Oct 25, 2022

any updates?

@maxcoulombe
Copy link
Contributor

maxcoulombe commented Mar 2, 2023

Hi, I was going to look at this issue but could no reproduce the problem with a quick test. Can anybody confirm if I am doing something wrong or perhaps the issue has been fixed since this was opened?

Create a Vault KV secret with dashes:

curl -X POST -H "X-Vault-Token: $VAULT_TOKEN" -d "{"data": {"secret-with-dashes": "my-secret"}}" $VAULT_ADDR/v1/secret/data/test-with-dash

Read the secret with dashes in a vault-action:

jobs:
  build:
    name: local-test
    runs-on: ubuntu-latest
    steps:
      - name: Import Secrets
        id: import-secrets
        uses: hashicorp/vault-action@v2.5.0
        with:
          url: ${{ secrets.VAULT_ADDR }}
          method: token
          token: ${{ secrets.VAULT_TOKEN }}
          secrets: |
            secret/data/secret-with-dashes my-secret | DASH;

Vault version:
Vault v1.12.3

@maxcoulombe maxcoulombe added the waiting-for-response Indicates a maintainer asked a question that must be answered by contributors before proceeding label Mar 2, 2023
@fairclothjm
Copy link
Contributor

Hello! Is there any recent update on this issue? Are you still experiencing this issue?

@mook-as
Copy link
Author

mook-as commented May 5, 2023

I'm afraid I've stopped using vault-action some time in the last 2½ years; I see though that jsonata is still in use and the documentation is still rather light (but I can't confirm if it works now).

@maxcoulombe
Copy link
Contributor

I added a small precision to the doc to indicate the selectors use JSONata so it's more obvious if any characters need to be escaped.

The issue discussed here with dashes couldn't be reproduced and we have an acceptance test in place to catch any regression. With these measures in place I think it's safe to close this issue.

Thanks for bringing this up and if anyone is able to reproduce the original issue please let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request waiting-for-response Indicates a maintainer asked a question that must be answered by contributors before proceeding
Projects
None yet
Development

No branches or pull requests

9 participants