Skip to content
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

Proposal for allowing users to set their own env vars directly in the project. #130

Merged
merged 3 commits into from
Dec 15, 2016
Merged

Proposal for allowing users to set their own env vars directly in the project. #130

merged 3 commits into from
Dec 15, 2016

Conversation

Magellol
Copy link
Contributor

@Magellol Magellol commented Dec 14, 2016

Hi everyone.
I actually just installed Gladys today to play with it and realized I could not get it running without modifying config/connections.js directly because I could not provide the require env variables outside of the project scope. Which is not good because that file will get overridden on each updates.

Instead here's a proposal to set them up on a per-project scope. Means, everyone can create their own .env file at the root and set the env vars they need to work with their setup. Now, I realize it's kind of a breaking change because some people might have relied on the fact that we default to some values if the env vars are not there (we can bring that behaviour back if necessary) but I wanted to introduce some good practice first and get your opinions after since I'm not experienced with the project.

A .env file looks like:

MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=''
MYSQL_DATABASE=gladys

MYSQL_HOST_TEST=localhost
MYSQL_PORT_TEST=3306
MYSQL_USER_TEST=root
MYSQL_PASSWORD_TEST=''
MYSQL_DATABASE_TEST=gladystest

I can update the Readme file if we're going to agree on these changes. 👍

@Pierre-Gilles
Copy link
Contributor

First thanks for your proposal ! I'm 100% ok with the idea of finding another solution than actual way in Gladys.

Which is not good because that file will get overridden on each updates.

Yes of course modifying connection.js is really dirty :)

Your proposal seems great, the only problem I see is that it will breaks all current install if we remove the fallback as the current gladys raspbian image uses the fallback.. As you say for now we should keep the fallback.

But I agree on the changes, just put the fallback back and you can update the README ! 👍

Again, thanks for this PR !

@Magellol
Copy link
Contributor Author

Magellol commented Dec 15, 2016

Sweet! One thing I should have mentioned is I'm wrapping the dotenv call into a development NODE_ENV (see) check because they should only be required in development mode. Other env should set these env variables directly. Do you see any problem with it? My understanding is if we put the fallback back in, it's backward compatible as people not having a .env would still be able to run Gladys as they were.

Will go around these changes today 👍

EDIT: Changes are in. I took the chance to add a .env-sample file to list which variables are there to be customized.

…e; Updated the readme and did the actual fallback change.
@Pierre-Gilles
Copy link
Contributor

Pierre-Gilles commented Dec 15, 2016

Thanks for your revision ! Just one feedback, we should add the .env file to the .npmignore too :)

But that's just a detail, the rest is great !

@Magellol
Copy link
Contributor Author

Just added it in :)

@Pierre-Gilles Pierre-Gilles merged commit b639b47 into GladysAssistant:master Dec 15, 2016
@Pierre-Gilles
Copy link
Contributor

Thanks ! Merged :)

@Magellol Magellol deleted the enhancement/introduce-dotenv branch December 15, 2016 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants