-
Notifications
You must be signed in to change notification settings - Fork 85
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
central environment variable store #75
Conversation
9f913a6
to
d43cedc
Compare
hey @lrlna - I'd love your perspective on this before I spend some more time on it. The remaining work is just to actually use this central environment variable store everywhere we use environment variables. Not sure if you had thoughts/have seen other patterns that may be better for our use case. |
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.
@EverlastingBugstopper I think to give you a better perspective, I'd like to get a few clarifications:
- Could you elaborate a little bit more on this point in the PR's description:
makes it a bit more difficult to use environment variables in libraries like houston (this is what im stuck on right now)
-
Is env var use solely for Rover's internals, or do we expect our users to be able to insert and get them? I think this makes a very large difference in thinking about this API.
-
Would we want to persist env vars or make sure they are started anew for every terminal session? I know lots of folks configure their terminals to specifically persist env vars, so that's something to consider when making a decision on this.
-
How do you distinguish between the
.config
dir introduced in this PR andenv
?
yeah! so before this PR, houston just directly called
all of these environment variables can and should be documented for external use
the changes here should be purely related to where in the code the environment variables values are retrieved and shouldn't actually change behavior. that being said, we do want to support this use case! folks should be able to set these environment variables and have them persist.
so the |
as discussed outside of this issue: I like having the To be able to also use it in As for |
it's all coming back to me now.. so the problem with the approach i have right now is that it requires you to create and persist an instance of the the problem with this is that we have to start passing the values around everywhere, so it's not as easy as The current design of Houston makes this quite difficult as the functions in the Perhaps there's another approach we can take here, or perhaps an easier way of getting the value of |
cdd6eca
to
380f4f3
Compare
This sentence got me thinking that perhaps we need to take step back. Could you walk me through what exactly your goal is with env vars? You previously mentioned that you wanted an easier testing scenario than you have now. Is there more? In the meantime, here is how my previous teams addressed the env var / any other setup scenarios in CLIs. I usually try to use this sort of design, as it's easily testable: The main entry point to the CLI handles all possible parsing and env var storage. Depending on the structure, and if statefullness is required, the main entry point will also initiate and keep track of state. This means that all env vars are initiated and written there as well. All "child" components, other initiated modules take either state, env vars, or configuration as parameters. Since the components/modules are independent of outside variables (forces? :D), it becomes a lot easier to test and to maintain. It's also a lot easier to spot regressions (at least in my experience). It does create an architecture that is reliant on a main entry point / "parent" module, but usually with CLI's I find that quite acceptable. (This would be easier to understand with a diagram perhaps, but I lost my apple pencil and a new one comes tomorrow. Lmk, and I can draw this up instead.) I do realise this probably requires a bit of an overhaul of how Rover does things now, but I want to put it out there as something we may wish to consider if we run into more issues with configuration / env vars. |
Yes - that makes a lot of sense. The parent - child relationship here is what I've started working on, I think it's just a matter of redesigning houston a bit to take those parameters. What you've described is pretty much the exact architecture I have here, I think it's just a matter of bending houston to match the new pattern. Should be ok with some heads down time. |
Cool, good to know.
Also: happy to pair on this if you like!
…On Thu, 10 Dec 2020, 18:52 Avery Harnish, ***@***.***> wrote:
Yes - that makes a lot of sense. The parent - child relationship here is
what I've started working on, I think it's just a matter of redesigning
houston a bit to take those parameters. What you've described is pretty
much the exact architecture I have here, I think it's just a matter of
bending houston to match the new pattern. Should be ok with some heads down
time.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#75 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB53OCE224KVKV4YE4LZC43SUEDGZANCNFSM4TQ7CZDA>
.
|
ac020f1
to
122dc13
Compare
122dc13
to
a584b26
Compare
This is ready for review now! |
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.
Really really nice!
a584b26
to
5b132c9
Compare
comments addressed! thanks for the thorough review @lrlna 🥇 |
5b132c9
to
104d258
Compare
This PR creates a centralized environment variable store that can be mocked in tests.
It defines an enum of all of the environment variables we use in rover in a single place, and also defines behavior for interacting with them.
benefits:
APOLLO_
prefixstd::env::var
callsserial_test
in most places where we had to add it because the system env var store would clobber the other testsAPOLLO_KEY
variable setdrawbacks:
Tests are passing and no are no longer affected by environment variables on any individual developer's machine. Any new tests should follow the patterns here when testing code that relies on environment variables.