-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Framework: Cascading Configs #876
Conversation
configPaths = [ | ||
'__base.json', | ||
opts.env + '.json', | ||
opts.env + '.local.json' |
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.
*.local.json
seems to be a nice addition 👍
I really like this PR! Thanks for taking care of it :) I have one more comment. At the moment we reference Also please note that we duplicated 3 functions in config files on client and server:
Of course this is a scope for another PR, but I couldn't resist to add it here :) |
Mo, I really really like this idea and I was arguing for this exact approach and remember @rralian and @gwwar were against it. I like what you did though, but maybe we need a bit more discussion? |
And by discussion I mean: waiting a bit until people wake up from food coma / long weekend :) |
I don't think this is an issue, because |
I see it and as I said - I like it, this is awesome! |
Yep, I resisted that in this PR but was thinking of tackling it if/after this ships :) |
If we decide that the cascading configs is a no-go, I'll just extract the |
@artpi I don't remember such a discussion (if you can find it that would be helpful). I think we probably just misunderstood each other one way or another. I don't have any concerns jumping out at me about this. I agree that it would be nice to move It looks like there are other items we could move into |
Yeah, I moved |
Any progress on this one? Our config file are getting out sync very quickly. See this: https://github.com/Automattic/wp-calypso/pull/2782/files. Those PR would mitigate most of the issues. |
Got sidetracked by other stuff but going to pick this up again today. |
86d7782
to
f948137
Compare
Okay, took a another shot at this:
I have not moved any other config values either. I think that should be left for other PRs. Plus, the readme files need an update. |
@mjangda I'm sorry this has languished for so long. I just walked through everything and I think this is really great. Tests all look good and the logic makes sense. I agree that we'll want some additional documentation to explain the additional features and how to use them. But I wouldn't hold up this PR for the documentation. One thing though, I think that feature flags should still be set specifically for each environment. I realize your PR would leave this convention in place, but it should probably be called out in the documentation that we would not want "features" to live in the Looks like the PR needs a rebase. If that's clean and good I'd give this a 👍. If the rebase is more involved, let me know and I can give this another look when you're done. |
BTW, one of the reasons I'm eager for this PR is so I can enable the React visualizer for performance tuning via: ENABLE_FEATURES=render-visualizer make run |
And allow for cascading config files. This allows us to start with a base file shared across all environments, an environment-specific config file, and then local overrides.
The discover_blog_id is now defined in out base file instead of each individual config.
shared is a clearer name. We also retain the `_` to sort this file at the top of most editors / file browsers.
And pass in a config path instead of traversing
Let's keep everything related to reading/parsing/building config in one place so it's easier to maintain. This way, the client config folder can just be purely generated.
Previously, we were defining the config functions in both the module and the regenerate file. We can just reuse the definition from the module.
Since it's necessary for the parser.
Rather than accessing env vars directly in the module. Makes the module testable and less-env specific.
f948137
to
8c0fb1c
Compare
Thanks @rralian! The rebase was pretty clean (just small config updates) so going to merge and will look into docs shortly. |
Problem
We have a config file for each environment we support; that's seven different files as of now. More could be added in the future. However, because each config file lives on its own, it means that we need to duplicate entries across each of the files even though in many cases, the values are exactly the same, regardless of the environment.
(Suggested) Solution
We can start with a base config file that will contain all our shared config values. We can then merge in environment-specific config values via
${env}.json
files. As an added bonus, we can allow local-only overrides via${env}.local.json
(gitignore
d) in case developers want to change things locally without touching the main configs.The PR extracts the config reading bits into a new module to reduce the duplicated bits between the server config and the client config generator.
We use something like this for Mesh and it works really well.
Looking for feedback on this before I expand it any further (tests, etc.).