feat: Add CDA Environment Manager - #209
Conversation
|
@msweier just a note. the pull request names should be feat, fix or feat!. not PATCH, MINOR, MAJOR. |
krowvin
left a comment
There was a problem hiding this comment.
First round of comments, just visual inspection. Going to take another pass on it if I can pull it down and run it myself.
|
Followup comments
We may turn this into a Credentials Manager conversation and not just an env conversation. If we can figure out the way we want to properly store credentials we can use that for both env api keys and for the tokens returned by keycloak. I suggest we look into keyring it's cross platform and it will make it trivial to store credentials. may want to just go ahead and ship this with the regular deps and not as a per method credential (i.e. only needed if you do cwms-cli login/env?) We will want to consider what this means for headless apps too where the secrets are expected to already be in an env and NEVER user defined. Would need to decide if we are trying to connect anything else to these env files. We could go to using the credentials manger lib for sensitive things like token and API key but use the host env for regular data. We talked about how to edit the environment for Solaris, I think we could append an environment file to the users |
|
I implemented most of the changes and it is a much better UX, but I didn't touch the token management. Also to be able to use a loaded env with VSCode is pretty difficult because it can't inherit the properties from the spawned terminal. But it does make the cli commands easier if you need to do something. If we upgraded the load commands to take My main question is this still a useful feature if you still need an env file use with VSCode and debugging? Maybe one of you know a better way to integrate it. |
|
Spoke with @msweier We agreed we can come back to
For now we can store the API key and ROOT in the Windows environment. We are doing this now even if that is plaintext. It is per user environment and requires the enduser to put the key it.
I think so, because it gives you the ability to activate without having to know any of the critical URLs but you can also opt into those. It has been a pain point of setting up the envs on windows for endusers and this allows you to do it all without leaving the terminal. Tag i'm itSpoke with Mitch about me taking over and trying to figure out how best to store and talk with the windows registry/env to store these env values. Take out the additional terminal spawing if possible to avoid terminal nesting. Will need to refreshenv Mitch has a branch that refreshes, can go to him if I can't figure it out |
|
Not to be a downer, but what's the point of this? I'm not opposed to simplifying processes where it makes sense, but this doesn't make sense to me. Instead of taking something targeted to a 12th grader and making it understandable by a 5th grader, you're taking something targeted to a 5th grader and making it for a 4th grader. EDIT: |
That's a fair point and something I was wondering myself. Here's a few reasons why I think it may be useful:
|
What happens if there's an OS update and python breaks, and cwms-cli no longer works? It's happened enough on my system I've had to change how I operate. Someone who doesn't do this regularly will really be in a bad position. Though I guess it may not matter, since what would they be doing if cwms-cli broke anyway?
I'll admit that's handy, though see below.
Honestly, I don't work with .env files at all. At least willingly. Too risky for accidental credential leakage. I'm not sure why they became so popular. Actual environment variables can't be committed to github. So I'll set multiple, like CDA_ROOT_DEV, CDA_ROOT_TEST, etc., then just reference them in the command-line of the process. They have their own security issues of course, but different. |
Yeah the intent is to help with using python/cwms-cli. It's opt in, and it just swaps out the |
|
Refactored to ditch keyring. Now stores envs as json alongside token store location. Updated
|
Merge remote-tracking branch 'origin/main' into feature/env-man
This cross-platform feature would add a CDA environment manager to cwms-cli that would:
CDA_API_ROOTandCDA_API_KEY)cwms-env cwbi-dev).--source-envand--target-envarguments for commands likecwms-cli loadSee https://github.com/HydrologicEngineeringCenter/cwms-cli/blob/feature/env-man/docs/ENV_MANAGER.md