-
Notifications
You must be signed in to change notification settings - Fork 161
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
Modernize implementation #76
Comments
Hi @StarpTech, a few days before your proposals I came up with this #75 |
Hi! I'm currently working on this: #78 I've experimented a bit with tagged templates and I've arrived at the conclusion that the use of mustache comes in handy because it allows for a consistent and declarative code, and is also very readable, making the generation of documentation (through I've transformed pretty much everything into modern ES6 code with I'm gonna investigate r2 now and see why and how to implement it into the project. About splitting the project, I'm not sure that would serve any purpose really. The methods, as they are defined now, take little to no space in the project and the memory, and I don't see why a client would bother adding separate pieces of functionality at different times when you can just access to the whole HTTP API through About the documentation, I'm almost finished documentation the code for devs (using the docco setup already in place) and I plan on adding the I'm also thinking on adding some more intensive tests, like reading, writing, deleting secrets, creating users, policies, checking them, etc, some random features to cover a good amount of functionality. After this 'refactor' project is done, I will implement AIM and EC2-AIM auth (and maybe EC2 and lambda as well) auth as well as some helper interfaces. I'm thinking on exposing an automatically aws authenticated method, something like: const vault = require('node-vault').awsAuth()
vault.read(...)
vault.write(...) This way there's no hassle for developers (other than setting up the I would love to hear you thoughts! Cheers, |
PD1: the codecov stuff is failing in my PR, help! |
I've investigated |
Hi @DaniGuardiola great to see progress here.
I don't want to avoid the usage of mustache for template generating but for url building here that's a great use-case for template-literals.
In |
let uri =
I agree that we can probably substitute the |
That was quite confusing :D For which case do you need
|
I reviewed |
Ahh, that's great and even more lightweight than |
Ok I'll explain:
This is convenient for the reasons I wrote in this comment. |
Check the features.md file and you'll understand why using mustache is a really good idea, solving two problems in one:
|
I don't speak about documentation. I point into the code here: https://github.com/kr1sp1n/node-vault/blob/master/src/index.js#L67-L69 You will start the mustache procedure on each request for what? |
UPDATE: outdated list So, current progress is:
|
@StarpTech I explained how and why we are using And I explained some of the advantages of using it in this other comment Each request needs to create the path for the URI of the request by inserting the parameters. |
Sry I don't get it. You use template-literals to build your url and then replace variables with mustache? Why not: client.request = (options = {}) => {
const valid = tv4.validate(options, requestSchema);
if (!valid) return Promise.reject(tv4.error);
if (typeof client.token === 'string' && client.token.length) {
options.headers['X-Vault-Token'] = client.token;
}
const uri = `${client.endpoint}/${client.apiVersion}${options.path}`
debug(options.method, uri);
return rp({
uri,
headers: options.headers
}).then(handleVaultResponse);
}; |
Btw, you guys can help me with something, I need to finish adding documentation to If you can please do it and send a PR to my branch ( |
@StarpTech forming the url and inserting the parameters are two different things. The parameters are contained in the path. In the
Mustache will match any In your snippet you are not doing this substitution and, therefore, in my request example, you would be trying to send a request to |
Re-read my comment and notice that there are two steps: forming the URI and inserting the parameters in the path. For the first step a template string literal works just fine, and mustache takes care of the second step. |
Ok, I got it but it feels like overhead. I don't like the idea to use a template language for URI interpolation. It includes 630 lines of javascript to do such a simple thing. |
I mean we could create a basic Example path using inverted sections: |
I suppose what we need to implement are defaults to replace the inverted section usage. Then we can easily create a function with a similar interface to
And the defaults would need to be defined in |
@kr1sp1n I got a question, if there's a parameters defined in the path without a default ( |
For now this is the behavior I decided, not very happy with it but I think that is the current behavior with mustache anyway
|
Yay! :) Thanks @StarpTech for helping me with the idea. We can cross that off the list now, pending @kr1sp1n answer to my question. |
Current tasks:
|
Could you guys do some code review? |
So I found two problems with |
TL;DR:
So unless we can find a lib that supports both things, we should keep using |
https://www.npmjs.com/package/needle This could be an alternative, supports |
It is not a slim package though, it might not be worth it if it's bigger or similar to |
Due to these problems, I think the best decision is to leave I updated the checklist up there, now we only have tasks of documentation and testing left. We should also consider if we should add babel translation to add node 6+ (or even <6) support. What do you think about that? |
Vault fixed this issue! hashicorp/vault#3763 However, I still need to include the workaround to support versions prior to |
You can enforce ssl if you pass the correct options to simple-get. Look here:
or look in the node.js docs here https://nodejs.org/api/https.html#https_https_request_options_callback |
@StarpTech that's |
yes, I know you can also pass request options in |
@StarpTech ok, could you take care of that? You can pull my branch were I was last working on it. It is not a priority for me as I need to focus on other stuff for my company. The tests fail (you'll need to run |
@kr1sp1n could you accept the PR and publish a new major version? We can add the documentation and further tests and code improvements in minor versions. This is prio for my company :) |
@kr1sp1n actually wait because I need to finish the |
I will try to help you as soon I have some time but right now I'm very busy :/ |
@StarpTech don't worry, it can be done in the future. I think that we should release the current version as soon as I do some more tests and change the request stuff in a minor release when it's ready. Do you agree? :) |
Updated checklist (excluding minor details):
On hold:
|
@DaniGuardiola Where can the progress on "Provide better documentation" be found? |
@patrick-motard #78 which is a PR from the refactor branch in my fork: https://github.com/daniguardiola/node-vault/tree/refactor :) keep in mind that although the features are almost the same, some are new (very few) and cannot be found in the published version. |
@DaniGuardiola thank you for responding. And thank you for your work to improve the codebase. The documentation is so far my largest barrier of use. I'll take the time to look over the PR. |
@patrick-motard What specific docs are you looking for? Maybe we could help you immediately. |
I can get specific examples soon. Offhanded comment... I'm not able to get the example on the readme working:
Returns:
Seems identical to an issue reported by another user on stackoverflow 10 months ago. |
@patrick-motard are you running vault on that address? Can you use the REST API (or the CLI) pointing to that address without a problem? |
Wanted to check in and see if there's been any progress here. |
@DaniGuardiola I have not been working with this codebase since participating in this issue discussion over a year ago. I would like to think that I was smart enough to have first tested that CLI worked on the local dev version of vault I was running before I attempted to use this SDK, but I do think it's the right thing to test and confirm first in addressing this issue. I'm not in a position to test this any time soon personally, but it shouldn't be too difficult to do for whomever wants to pick this up and work on it. |
This initiative seems stale :) |
As titled. Any plans yet?
request
+request-native-promise
packageI will help you to reach the goals.
The text was updated successfully, but these errors were encountered: