-
Notifications
You must be signed in to change notification settings - Fork 140
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
Issue234 Import all keys from specific path #238
Conversation
Temp action to allow manual build
Am I supposed to close this pull request? |
This would be really useful. |
This is exactly what we need for our project. We current have to create our own action to do this, Any change this would be merge soon? |
Good work here. This appears to be very similar to #247. Is there anything different here from that PR (other than a slightly different approach?). If not I think it would be best to close this PR and continue the conversation there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @slemme1! Thanks for taking a jab at this. The change looks good overall, my comment are mostly around styling and some leftovers changes from development we might not want to bring back into main.
I tested the modifications locally and the feature & tests (thanks for taking the time to add acceptance tests btw) work like a charm (with the small fix proposed of awaiting the response from selectData).
I know there are other PRs opened to address this wildcard support request such as #247 & #398. I'm inclined to accept yours over the others. It is more complete, uses a simpler approach, has more test coverage and I like the option you added of regrouping all the keys under a shared prefix if desired.
Let me know if you need anything from us to get this updated and ready to ship!
} | ||
return outputKey; | ||
} | ||
module.exports.normalizeOutputKey = normalizeOutputKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it causes circular dependency problems, it'd be better to move the normalizeOutputKey
method into it's own normalization.js or utils.js file so it can be imported and used by both secrets.js & actions.js.
It's usually better to rethink how a project is compartmentalised rather than hack the exports.
}; | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go ahead and move the normalization method in its own file well be able to keep this unique export block which I think is more "standard" than exporting methods one at a time throughout the file.
if (!selector.match(/.*[\.].*/)) { | ||
selector = '"' + selector + '"' | ||
|
||
if (selector == wildcard) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe strict equality with === should be used unless there is a specific reason not to.
//console.log("After", newRequest, value); | ||
|
||
// used cachedResponse for first entry in wildcard list and set to true for the rest | ||
cachedResponse = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think setting this to true does anything here? It gets reset to false at the beginning of every loops before we check for a cache hit.
}); | ||
|
||
//DEBUG | ||
//console.log("After", newRequest, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try not to leave leftover debug code or console.logs even if commented out.
|
||
selector = key; | ||
|
||
//This code (with exception of parsing body again and using newRequest instead of secretRequest) should match the else code for a single key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to isolate the shared code in a method instead of hoping maintainers see this comment and think to copy-paste changes between the wildcard and single-key paths?
selector = '"' + selector + '"' | ||
} | ||
selector = "data." + selector | ||
//body = JSON.parse(body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover comment, should it be deleted or it's important?
if (body.data["data"] != undefined) { | ||
selector = "data." + selector | ||
} | ||
const value = selectData(body, selector); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectData was changed to be async due to the recent bump to Jsonata 2.x, you'll need to await the response otherwise the code does not work and tries to manipulate a promise.
const value = await selectData(body, selector);
} | ||
return results; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extra empty line can be removed?
After reviewing both PRs I'm of the opinion that we should aim to ship this one and close #247. The approach here is simpler & cleaner plus it adds the option of specifying a prefix shared by all secrets form the same path which I think is useful. |
Why hasn't this PR been resolved for so long? Is there any other solution? |
I found out that |
Hi @maxcoulombe I see this PR no longer seems active and so I have implemented all of your requested changes in #488 Please let me know if you have any other changes you would like to see. Very keen to get this into the repo as we are currently using this functionality in production. |
* Initial check-in of wildcard to get all secrets in path (Issue#234) * Fix wildcard for K/V v2 and Cubbyhole. Add more tests * Refactored out selectAndAppendResults * Use selectAndAppendResults for wildcard * Use normalizeOutputKey in action.js * Refactored wildcard --------- Co-authored-by: Scott Lemme <[email protected]> Co-authored-by: Lemme <[email protected]>
Awesome thank you so much for picking this up. Thanks also to @slemme1 for the initial implementation. #488 got merged a couple of minutes ago, I'll follow-up with the team to include this new feature in a v2.8.0 release! |
I am a first time contributor. Any constructive feedback is appreciated.