-
Notifications
You must be signed in to change notification settings - Fork 161
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
Improvement: Moving secrets from USER_SETTINGS.cpp to platformio config #662
base: main
Are you sure you want to change the base?
Conversation
I'm in favour of this ! |
Nice improvement! Does it work good for Arduino IDE users also? |
I also like this approach. Testing .. |
A different approach would be required to support Arduino IDE users which would require a one time manual action which I avoided with Platformio. The best option I can see to support both Arduino IDE and Platformio is to create a USER_SECRETS_TEMPLATE.h file that users would need to copy to USER_SECRETS.h once manually. USER_SECRETS.h would be added to .gitignore to avoid accidental commits. |
Yeah well 99% of users are Arduino IDE users, so I guess we would need to cater to those 😅 |
f02bb31
to
3126607
Compare
I have updated the method to support both Arduino & VSCode users, it does require the manual step of copying the template file which I have added to the readme |
3126607
to
100ba0d
Compare
Doing this change will be a kind of "breaking" change that will require a new Youtube video to be put up. Otherwise my email will explode 😅 But I like the change! |
For such a small code change the impact is significant. If there are other settings to move now is the time to do it |
@No-Signal, you should be able to add and commit the file |
@lenvm my understanding is that once a file is being tracked in git adding it to .gitignore won't stop it tracking future changes |
@No-Signal, this can be solved. Please do the following on your branch:
|
@lenvm if I follow your steps then all subsequent changes to USER_SECRETS.h are tracked by git which is what I'm attempting to avoid with this PR |
Git shouldn’t be tracking those changes after the last commit, where you add it to Please ensure to run the following command.
This I did not include in the steps above, but seems necessary if you are the one that created the file that you want to commit, and later not track anymore. Try it out for yourself to confirm! |
@lenvm my understanding is that everyone that pulls the code would need to run the git rm command for this approach to work |
Let’s try it out and see! Even if that would be the case, it would be less intrusive than a breaking change for every user of the code, especially those that just download and compile and never plan to do any coding. |
I have pushed my test feature branch up so you can test https://github.com/No-Signal/Battery-Emulator/tree/feature/user_secrets2 This solution is certainly easier for people to get up and running and was the initial method I tried before testing platformio then the template approach The downside is it makes it much easier for people to accidentally commit secrets which is why most projects I have seen use a template file instead |
I have checked cloned your repository, and you are right. Conclusions:
|
Software/USER_SETTINGS.h
Outdated
@@ -92,7 +92,6 @@ | |||
|
|||
/* MQTT options */ | |||
// #define MQTT // Enable this line to enable MQTT | |||
#define MQTT_SERVER "192.168.xxx.yyy" | |||
#define MQTT_PORT 1883 |
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.
Perhaps also include MQTT_PORT
in USER_SECRETS.h
.
c5db54b
to
4f53a3b
Compare
af715bc
to
b4474e5
Compare
@dalathegreat, what do you say? Shall we merge this? The change is a real improvement, but does still impact your YouTube video :) |
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.
LGTM 👍 Let's merge this since we are indeed releasing a major update :)
What
This PR moves user secrets from USER_SETTINGS.cpp & USER_SETTINGS.h into a platformio config file USER_SECRETS.ini
Why
This change makes it less likely that secrets are accidentally exposed by users committing them and makes it easier to maintain these secrets during development
How