Feature/include config: Support including additional config files using new config file directive #623
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR add support in the configuration file for an "include" directive.
If line appears in the config file loaded by the daemon:
It will pause processing the config file and begin processing each config that matches the pattern/glob in turn before resuming processing of the original file.
The directive is recursive, but limited to a depth of 5 config files.
This process allows for a config folder, or including a "local" file to override package defaults
I have in my setup, used:
This capability is enabled using a new .h/.c file configlocations.
struct ConfigLocations
is a handle that provides a fgets like interface to read lines.The handle can be instructed to open a file, folder, or glob pattern.
calling the fgets method against the handle will return a line from the current file, automatically rolling forward to other files matched by folder or glob and rolling back to paused files.
The "include" directive is included in the config file reading loop. When an "include" directive is found, the parameter is passed into the open_glob method to load all config files that match the pattern.
This functionality is proving useful for me as I dynamically create the allow list based on other system information and I would prefer not to re-write the entire config file each time. I also like having the ability to override defaults in the package config independently