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

Split .config.json into separate files #2704

Merged
merged 4 commits into from Sep 25, 2020
Merged

Split .config.json into separate files #2704

merged 4 commits into from Sep 25, 2020

Conversation

knolleary
Copy link
Member

@knolleary knolleary commented Sep 23, 2020

  • New feature (non-breaking change which adds functionality)

Proposed changes

The runtime settings are currently stored in ~/.node-red/.config.json. This contains:

  • the list of nodes discovered by the runtime
  • user settings (eg editor settings such as 'show grid' etc)
  • project settings (active project, list of available projects etc)
  • other things - notable _credentialSecret.

Putting all of these things in one place is not ideal - a consequence of the Storage API only having a simple read/write API for the whole settings object.

This PR changes the default LocalFileSystem storage plugin to split the settings into 4 files:

  • .config.nodes.json - the node registry
  • .config.users.json - user specific settings (eg editor settings)
  • .config.projects.json - project settings, including the active project
  • .config.runtime.json - everything else - most notable _credentialSecret

This reduces the blast radius if any one of the files is lost for some reason.

It also means:

  • a user can be more selective over what they backup. For example, they can backup the users file to save their editor settings, without also pulling in the _credentialSecret from the runtime file.
  • when updating a setting, only the relevant file needs to be updated - we don't have to rewrite the whole file every time.

With this change, we will leave the existing .config.json in place. The logic is:

  • if .config.json exists and .config.nodes.json does not exist
    • migrate .config.json to the four new files
  • if .config.json and .config.nodes.json both exist
    • check modification time of both files
    • if .config.json is newer, migrate it to the four new files
    • if .config.nodes.json is newer, don't do any migration - use the four new files that already exist

We will leave the old .config.json in place because it eases the path if a user chooses to downgrade to pre 1.2 - they won't be left with no projects/_credentialSecret etc in place. This is more likely during the initial beta period of 1.2. We will begin to remove the old .config.json file in 1.3 or 2.0.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 76.887% when pulling 96d81ef on split-config into 81dc3de on dev.

@knolleary knolleary merged commit 085ff84 into dev Sep 25, 2020
@knolleary knolleary deleted the split-config branch September 25, 2020 14:56
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.

None yet

2 participants