Giter Site home page Giter Site logo

config_resolver's People

Contributors

exhuma avatar pyup-bot avatar vinceatbluelabs avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

config_resolver's Issues

Config version support.

Add an optional constructor parameter "version". If specified the following rules will apply:

  • The version is expected to be in section config_resolver with the name config_version
  • The version will have the format "major.minor"
  • If the major version in the config file differs from the file passed in the constructor an exception is raised.
  • If the major version is the same, but the minor version is different, a warning is raised (using the warnings module).

DB Support

Add support to store config values in a database.

Unclear error message!

The warning message complaining about the minor version should contain the major number as well. Just for clarity. The message only appears if the test for the major number passed, so it's implicitly clear, but still confusing! Example message:

group=ept:app=ipbase:Mismatching minor version number. Expected 1, got 0 from filename '/etc/ept/ipbase/app.ini'

Unable to install config-resolver >=4.3.6, <5.0

The version.txt is missing in the MANIFEST.in and so the version file is not packaged. When trying to install this particular version I get the following error.

Collecting config-resolver<6.0
  Downloading config_resolver-4.3.6.tar.gz (10 kB)
    ERROR: Command errored out with exit status 1:
     command: /home/users/frank/workspace/platformer/env/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wha05sey/config-resolver/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wha05sey/config-resolver/
setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-wha05sey/config-resolver/pi
p-egg-info
         cwd: /tmp/pip-install-wha05sey/config-resolver/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-wha05sey/config-resolver/setup.py", line 10, in <module>
        VERSION = open("config_resolver/version.txt").read().strip()
    FileNotFoundError: [Errno 2] No such file or directory: 'config_resolver/version.txt'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Modular config parsing.

Currently, config_resolver's main job is find files, conditionally load them, and load them in a particular order (precedence).

To read the values, it uses SafeConfigParser from the stdlib. For some use-cases, simple .ini files are a bit limiting.

It should be possible to pass in a custom file-parser module, overriding SafeConfigParser. As long as that parser offers a way to read the values needed by config_resolver (currently only the config-file version) it should work.

Additionally, the returned config instance should be of the overridden type. This allows the user to provide a completely customized parser without losing that parser's advanced features.

This will also decouple the file look-up from the config handling.

Leave SafeConfigParser as default if no other parser is specified to keep backwards compatibility.

Optional exception if no config file was found.

It should be possible to request config files as "mandatory". If this flag is set, it should raise a "file not found" exception if no matching config file was found.

This should be optional, as some applications can very well survive with default settings.

WARNING level logging on every use

I'm looking to integrate config_resolver in https://github.com/bluelabsio/records-mover. This is exactly the library I was looking for to provide flexible configuration--thanks for writing it!!

In records-mover, I use Python standard logging. Unfortunately, it appears that every time I use get_config(), I get quite a bit of logging at a very high level (WARNING):

group=bluelabs:app=records_mover:Skipping unreadable file /etc/bluelabs/records_mover/app.ini (File not found)
group=bluelabs:app=records_mover:Skipping unreadable file /etc/xdg/bluelabs/records_mover/app.ini (File not found)
group=bluelabs:app=records_mover:Skipping unreadable file /Users/broz/.config/bluelabs/records_mover/app.ini (File not found)

This appears to be coming from here:

log.warning('Skipping unreadable file %s (%s)', filename,

Would you accept a PR to change this log level to DEBUG? It seems to me the idea of not having every potential config location full is not a concerning condition that should be warned about.

The workaround I have now is essentially to turn off logging altogether (logging.getLogger('config_resolver').setLevel(logging.ERROR)), but that would also suppress any potential concerning issues at WARNING or useful progress information at INFO being logged by config_resolver.

Ambiguous default filename.

By default, config_resolver looks for a file named app.ini. If multiple applications use config_resolver, this could lead to conflicts when looking of the current working directory. To avoid any conflict, searching the working directory should look into sub folders just like it does in the home folder. Example resolution order:

  • /etc/<group>/<app>/app.ini
  • ~/.<group>/<app>/app.ini
  • ./.<group>/<app>/app.ini

The "secure" flag breaks deployments in OpenShift

The "secure" flag to "get_config" enforces the permissions 0x600 for a config file. But in OpenShift the most secure a file can be is 0x640 because any mounted secrets will be owned by root:<app-user>.

This means that in its current state, config_resolver cannot be used for OpenShift apps.

A backwards compatible change would be to allow to pass in an octal value of the "expected" mode of a file, and use 0x600 if a user passes in True. This way each call could be adapted apropriately.

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.