-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add support for configuration file settings #1
Comments
flags-first package by Peter Bourgon supports all of these configuration file formats and command-line and environment variables. |
This GitHub issue shows how to use If we're willing to use a JSON-formatted configuration file, we could have the app save the current settings chosen on command-line out to a configuration file, either with an automatic choice for save/load location or something custom provided by the user (maybe an enhancement to the first draft). |
As noted on #2 (comment):
|
Aside from YAML, what other config file format easily support specifying multiple source paths to crawl/process? |
TOML seems like it would. This appears to be the most active TOML library for Go: https://github.com/pelletier/go-toml This project's README (https://github.com/naoina/toml) gives an example of breaking array values over multiple lines, which I think would be a good fit for specifying multiple paths for processing: # Line breaks are OK when inside arrays
hosts = [
"alpha",
"omega"
] Presumably the line break support is a part of the TOML spec and would be supported by most/all Go library implementations for TOML. |
Note to self: test both libraries: Hands-on experience with both should make it easier to decide. |
Takeaways thus far for TOML:
Attempting to use default values may be tricky since we're also supporting command-line flags and environment variables. |
YAML is also case-sensitive. |
Scratch notes:
|
Create base config object, then copy it for use as a template with a new config source? |
Note to self: Comparing against a Additionally, If the config file says to use |
Does go-arg have logic that prevents using the go-toml does not, so that might be irrelevant? |
At this point I've given up on trying to find a way to reliably keep the Thus if we try to use a layered configuration object approach with the In short, I think the |
Some other scratch notes from a brainstorming session (which probably didn't catch everything). As I write this I've found a few logic errors I still have to work out. Transcribing my existing notes anyway in case it helps me look at the problem from a different angle later.
Config layering order:
|
Still testing/working with my earlier approach. I'm starting to see some issues with the simple logic (e.g., copying slice values between structs), so I spent a short bit looking for community solutions to merging structs. Seems I'm far from the only one attempting to merge configuration settings across various structs, particularly from different configuration sources. This package is used by quite a number of larger projects, including Kubernetes and Docker: here are some (unsorted) examples of using it to merge different structs: |
I'm not sure yet if the "stars aligned" or if I'm just fooling myself, but the current state of the associated feature branch appears to be working. I need to do further testing to make sure that config settings are being overridden as intended to establish the proper precedence. |
- Add license info from go-toml project to NOTICE file - Update README with precedence details - Move `default` struct tag values back to constructor to improve compatibility between `pelletier/go-toml` and `alexflint/go-arg` packages - Add TOML config file support - Update doc comments - Move logging config method to config package, break bulk of the code into separate functions called from the logging package - Create `MergeConfig()` function to handle merging default, config file and command-line argument settings - needs work - good candidate for replacement by common struct merging package used by Docker, Kubernetes and others - BUGFIX for "keep X files" logic (indexing out of bounds errors) - BUGFIX: Fix logic problems with FileMatches slice indexing - Various linting fixes - TODO: Problems created while adjusting code or existing issues fixed? - Update .gitignore to ignore config.toml file in case user wishes to keep config file alongside of this code (for whatever reason) - Update .gitignore to remove files no longer present or used - BUGFIX for Config.String() method (field repeat?) - config.Validate() now responsible for enforcing 'required' settings in place of struct tags - Extend doc comments for FileMatches sort methods - Move FilesToPrune logic to FileMatches method in matches package - Use logging.LogBuffer to collect log messages for later replay once user-specified logging settings are in-place - Change log level for Windows syslog attempt refs #1
- Add license info from go-toml project to NOTICE file - Update README with precedence details - Move `default` struct tag values back to constructor to improve compatibility between `pelletier/go-toml` and `alexflint/go-arg` packages - Add TOML config file support - Update doc comments - Move logging config method to config package, break bulk of the code into separate functions called from the logging package - Create `MergeConfig()` function to handle merging default, config file and command-line argument settings - needs work - good candidate for replacement by common struct merging package used by Docker, Kubernetes and others - BUGFIX for "keep X files" logic (indexing out of bounds errors) - BUGFIX: Fix logic problems with FileMatches slice indexing - Various linting fixes - TODO: Problems created while adjusting code or existing issues fixed? - Update .gitignore to ignore config.toml file in case user wishes to keep config file alongside of this code (for whatever reason) - Update .gitignore to remove files no longer present or used - BUGFIX for Config.String() method (field repeat?) - config.Validate() now responsible for enforcing 'required' settings in place of struct tags - Extend doc comments for FileMatches sort methods - Move FilesToPrune logic to FileMatches method in matches package - Use logging.LogBuffer to collect log messages for later replay once user-specified logging settings are in-place - Change log level for Windows syslog attempt refs #1, #154
- Add TOML config file support - by way of `pelletier/go-toml` package - Add `config.example.toml` template/starter file - LICENCE - Add license info from go-toml project to NOTICE file - README - Update with precedence details - Update with new config file options table that maps those settings back to the equivalent command-line flags - Move `default` struct tag values back to constructor to improve compatibility between `pelletier/go-toml`, `alexflint/go-arg` (and potentially) other packages - Update many doc comments in an effort to expand coverage, improve clarity (lots more to do here) - Move logging config method to config package, break bulk of the code into separate functions within the logging package that are now orchestrated from the `Config.SetLoggerConfig()` method - Create `MergeConfig()` function to handle merging default, config file and command-line argument settings - favors incoming config object, provided the source field being examined does not contain a default value - needs work - good candidate for replacement by the `imdario/mergo` package used by Docker, Kubernetes, VMware and other big name projects - BUGFIX: Fix logic problems with FileMatches slice indexing - BUGFIX: Various linting fixes - Update .gitignore to ignore config.toml file in case user wishes to keep config file alongside this code (for whatever reason) - Update .gitignore to remove files no longer present or used - BUGFIX for `Config.String()` method (field repeat?) - Update `Config.Validate()` to assume full responsibility for enforcing 'required' settings in place of struct tags - Extend doc comments for FileMatches sort methods - Move FilesToPrune logic to FileMatches `FilesToPrune` method in matches package - Use logging.LogBuffer to collect log messages for later replay once user-specified logging settings are in-place - Change log level for Windows syslog attempt refs #1, #154
- Add TOML config file support - by way of `pelletier/go-toml` package - Add `config.example.toml` template/starter file - LICENCE - Add license info from go-toml project to NOTICE file - README - Update with precedence details - Update with new config file options table that maps those settings back to the equivalent command-line flags - Move `default` struct tag values back to constructor to improve compatibility between `pelletier/go-toml`, `alexflint/go-arg` (and potentially) other packages - Update many doc comments in an effort to expand coverage, improve clarity (lots more to do here) - Move logging config method to config package, break bulk of the code into separate functions within the logging package that are now orchestrated from the `Config.SetLoggerConfig()` method - Create `MergeConfig()` function to handle merging default, config file and command-line argument settings - favors incoming config object, provided the source field being examined does not contain a default value - needs work - good candidate for replacement by the `imdario/mergo` package used by Docker, Kubernetes, VMware and other big name projects - BUGFIX: Fix logic problems with FileMatches slice indexing - BUGFIX: Various linting fixes - Update .gitignore to ignore config.toml file in case user wishes to keep config file alongside this code (for whatever reason) - Update .gitignore to remove files no longer present or used - BUGFIX for `Config.String()` method (field repeat?) - Update `Config.Validate()` to assume full responsibility for enforcing 'required' settings in place of struct tags - Extend doc comments for FileMatches sort methods - Move FilesToPrune logic to FileMatches `FilesToPrune` method in matches package - Use logging.LogBuffer to collect log messages for later replay once user-specified logging settings are in-place - Change log level for Windows syslog attempt refs #1, #154
- Add TOML config file support - by way of `pelletier/go-toml` package - Add `config.example.toml` template/starter file - LICENCE - Add license info from go-toml project to NOTICE file - README - Update with precedence details - Update with new config file options table that maps those settings back to the equivalent command-line flags - Update log output examples to reflect no only config file command-line flags and related output, but also recent work to better summarize file size details (e.g., space reclaimed from pruning matching files) - Move `default` struct tag values back to constructor to improve compatibility between `pelletier/go-toml`, `alexflint/go-arg` (and potentially) other packages - Update many doc comments in an effort to expand coverage, improve clarity (lots more to do here) - Move logging config method to config package, break bulk of the code into separate functions within the logging package that are now orchestrated from the `Config.SetLoggerConfig()` method - Create `MergeConfig()` function to handle merging default, config file and command-line argument settings - favors incoming config object, provided the source field being examined does not contain a default value - needs work - good candidate for replacement by the `imdario/mergo` package used by Docker, Kubernetes, VMware and other big name projects - BUGFIX: Fix logic problems with FileMatches slice indexing - BUGFIX: Various linting fixes - Update .gitignore to ignore config.toml file in case user wishes to keep config file alongside this code (for whatever reason) - Update .gitignore to remove files no longer present or used - BUGFIX for `Config.String()` method (field repeat?) - Update `Config.Validate()` to assume full responsibility for enforcing 'required' settings in place of struct tags - Extend doc comments for FileMatches sort methods - Move FilesToPrune logic to FileMatches `FilesToPrune` method in matches package - Use logging.LogBuffer to collect log messages for later replay once user-specified logging settings are in-place - Change log level for Windows syslog attempt refs #1, #154 WIP: Merge me
- Add TOML config file support - by way of `pelletier/go-toml` package - Add `config.example.toml` template/starter file - LICENCE - Add license info from go-toml project to NOTICE file - README - Update with precedence details - Update with new config file options table that maps those settings back to the equivalent command-line flags - Update log output examples to reflect no only config file command-line flags and related output, but also recent work to better summarize file size details (e.g., space reclaimed from pruning matching files) - Move `default` struct tag values back to constructor to improve compatibility between `pelletier/go-toml`, `alexflint/go-arg` (and potentially) other packages - Update many doc comments in an effort to expand coverage, improve clarity (lots more to do here) - Move logging config method to config package, break bulk of the code into separate functions within the logging package that are now orchestrated from the `Config.SetLoggerConfig()` method - Create `MergeConfig()` function to handle merging default, config file and command-line argument settings - favors incoming config object, provided the source field being examined does not contain a default value - needs work - good candidate for replacement by the `imdario/mergo` package used by Docker, Kubernetes, VMware and other big name projects - BUGFIX: Fix logic problems with FileMatches slice indexing - BUGFIX: Various linting fixes - Update .gitignore to ignore config.toml file in case user wishes to keep config file alongside this code (for whatever reason) - Update .gitignore to remove files no longer present or used - BUGFIX for `Config.String()` method (field repeat?) - Update `Config.Validate()` to assume full responsibility for enforcing 'required' settings in place of struct tags - Extend doc comments for FileMatches sort methods - Move FilesToPrune logic to FileMatches `FilesToPrune` method in matches package - Use logging.LogBuffer to collect log messages for later replay once user-specified logging settings are in-place - Change log level for Windows syslog attempt refs #1, #154
- Add TOML config file support - by way of `pelletier/go-toml` package - Add `config.example.toml` template/starter file - LICENCE - Add license info from go-toml project to NOTICE file - README - Update with precedence details - Update with new config file options table that maps those settings back to the equivalent command-line flags - Update log output examples to reflect no only config file command-line flags and related output, but also recent work to better summarize file size details (e.g., space reclaimed from pruning matching files) - Move `default` struct tag values back to constructor to improve compatibility between `pelletier/go-toml`, `alexflint/go-arg` (and potentially) other packages - Update many doc comments in an effort to expand coverage, improve clarity (lots more to do here) - Move logging config method to config package, break bulk of the code into separate functions within the logging package that are now orchestrated from the `Config.SetLoggerConfig()` method - Create `MergeConfig()` function to handle merging default, config file and command-line argument settings - favors incoming config object, provided the source field being examined does not contain a default value - needs work - good candidate for replacement by the `imdario/mergo` package used by Docker, Kubernetes, VMware and other big name projects - BUGFIX: Fix logic problems with FileMatches slice indexing - BUGFIX: Various linting fixes - Update .gitignore to ignore config.toml file in case user wishes to keep config file alongside this code (for whatever reason) - Update .gitignore to remove files no longer present or used - BUGFIX for `Config.String()` method (field repeat?) - Update `Config.Validate()` to assume full responsibility for enforcing 'required' settings in place of struct tags - Extend doc comments for FileMatches sort methods - Move FilesToPrune logic to FileMatches `FilesToPrune` method in matches package - Use logging.LogBuffer to collect log messages for later replay once user-specified logging settings are in-place - Change log level for Windows syslog attempt refs #1, #154
- Add TOML config file support - by way of `pelletier/go-toml` package - Add `config.example.toml` template/starter file - LICENCE - Add license info from go-toml project to NOTICE file - README - Update with precedence details - Update with new config file options table that maps those settings back to the equivalent command-line flags - Update log output examples to reflect no only config file command-line flags and related output, but also recent work to better summarize file size details (e.g., space reclaimed from pruning matching files) - Move `default` struct tag values back to constructor to improve compatibility between `pelletier/go-toml`, `alexflint/go-arg` (and potentially) other packages - Update many doc comments in an effort to expand coverage, improve clarity (lots more to do here) - Move logging config method to config package, break bulk of the code into separate functions within the logging package that are now orchestrated from the `Config.SetLoggerConfig()` method - Create `MergeConfig()` function to handle merging default, config file and command-line argument settings - favors incoming config object, provided the source field being examined does not contain a default value - needs work - good candidate for replacement by the `imdario/mergo` package used by Docker, Kubernetes, VMware and other big name projects - BUGFIX: Fix logic problems with FileMatches slice indexing - BUGFIX: Various linting fixes - Update .gitignore to ignore config.toml file in case user wishes to keep config file alongside this code (for whatever reason) - Update .gitignore to remove files no longer present or used - BUGFIX for `Config.String()` method (field repeat?) - Update `Config.Validate()` to assume full responsibility for enforcing 'required' settings in place of struct tags - Extend doc comments for FileMatches sort methods - Move FilesToPrune logic to FileMatches `FilesToPrune` method in matches package - Use logging.LogBuffer to collect log messages for later replay once user-specified logging settings are in-place - Change log level for Windows syslog attempt refs #1, #154
- Add TOML config file support - by way of `pelletier/go-toml` package - Add `config.example.toml` template/starter file - LICENCE - Add license info from go-toml project to NOTICE file - README - Update with precedence details - Update with new config file options table that maps those settings back to the equivalent command-line flags - Update log output examples to reflect no only config file command-line flags and related output, but also recent work to better summarize file size details (e.g., space reclaimed from pruning matching files) - Move `default` struct tag values back to constructor to improve compatibility between `pelletier/go-toml`, `alexflint/go-arg` (and potentially) other packages - Update many doc comments in an effort to expand coverage, improve clarity (lots more to do here) - Move logging config method to config package, break bulk of the code into separate functions within the logging package that are now orchestrated from the `Config.SetLoggerConfig()` method - Create `MergeConfig()` function to handle merging default, config file and command-line argument settings - favors incoming config object, provided the source field being examined does not contain a default value - needs work - good candidate for replacement by the `imdario/mergo` package used by Docker, Kubernetes, VMware and other big name projects - BUGFIX: Fix logic problems with FileMatches slice indexing - BUGFIX: Various linting fixes - Update .gitignore to ignore config.toml file in case user wishes to keep config file alongside this code (for whatever reason) - Update .gitignore to remove files no longer present or used - BUGFIX for `Config.String()` method (field repeat?) - Update `Config.Validate()` to assume full responsibility for enforcing 'required' settings in place of struct tags - Extend doc comments for FileMatches sort methods - Move FilesToPrune logic to FileMatches `FilesToPrune` method in matches package - Use logging.LogBuffer to collect log messages for later replay once user-specified logging settings are in-place - Change log level for Windows syslog attempt refs #1, #154
- Add TOML config file support - by way of `pelletier/go-toml` package - Add `config.example.toml` template/starter file - LICENCE - Add license info from go-toml project to NOTICE file - README - Update with precedence details - Update with new config file options table that maps those settings back to the equivalent command-line flags - Update log output examples to reflect no only config file command-line flags and related output, but also recent work to better summarize file size details (e.g., space reclaimed from pruning matching files) - Move `default` struct tag values back to constructor to improve compatibility between `pelletier/go-toml`, `alexflint/go-arg` (and potentially) other packages - Update many doc comments in an effort to expand coverage, improve clarity (lots more to do here) - Move logging config method to config package, break bulk of the code into separate functions within the logging package that are now orchestrated from the `Config.SetLoggerConfig()` method - Create `MergeConfig()` function to handle merging default, config file and command-line argument settings - favors incoming config object, provided the source field being examined does not contain a default value - needs work - good candidate for replacement by the `imdario/mergo` package used by Docker, Kubernetes, VMware and other big name projects - BUGFIX: Fix logic problems with FileMatches slice indexing - BUGFIX: Various linting fixes - Update .gitignore to ignore config.toml file in case user wishes to keep config file alongside this code (for whatever reason) - Update .gitignore to remove files no longer present or used - BUGFIX for `Config.String()` method (field repeat?) - Update `Config.Validate()` to assume full responsibility for enforcing 'required' settings in place of struct tags - Extend doc comments for FileMatches sort methods - Move FilesToPrune logic to FileMatches `FilesToPrune` method in matches package - Use logging.LogBuffer to collect log messages for later replay once user-specified logging settings are in-place - Change log level for Windows syslog attempt refs #1, #154
While this tool will be heavily command-line driven, there are likely to be several good use cases for laying out all desired options via configuration file.
The specific format is yet to be determined.
Potential options:
The text was updated successfully, but these errors were encountered: