Hi guys,
Yesterday I lost all my configuration bc my editor broke the file. Thats a pitty. It cost me a day to get it back working bc I use a lot of complicated modules e.g. like the openhab floorplan.
That got me thinking.
Config.js is typically not committed to git because of all the secret stuff like apiKeys for google, darksky, your lat/lon of your house which you might not want to share via github.
How you guys are doing this? Having version control, but not publicly visible. Ok, I could pay github, or have a own server set up for my privat git. But sharing back with the community your own enhancements of the core system gets difficult.
I thought about a simpler solution.
What about splitting the configuration into two files:
config.js
var config = {
...
{ ...
// instead of
apiKey1 = „my secret key“,
// we do
apiKey = this.secrets.apiKey1,
}
And we sum up all the secrets like lat/lon/apikeys in a dedicated file
secrets.js
var secrets = {
apiKey1 = „MySuperSecretApiKey1“,
Latitude = YouMustNotKnowWhereILive,
...
}
The secrets.js file must be read somehow by the core system and the this.secrets must be populated.
And it would be downward compatible. If you dont have a secrets.js you are good to go as well.
config.js could go in a public version control system and only secrets.js would stay in .gitignore.
Is there an easy way to do this on my own? Some sorr of an „include secrets.js“ statement in javascript. Kind of bash like „source anotherBashScript“. I am new to JavaScript. Sorry if this is a silly question.
Looking forward to your feedback.
Regards
Ralf