Skip to main content

Convenient configuration of containerized applications

Project description

container-app-conf https://badge.fury.io/py/container-app-conf Build Status

container-app-conf is a library to easily read application values from multiple places like a yaml file and environment variables while providing type validation.

The initial purpose of this library was to have an easy way to configure applications running inside some kind of container (Docker in this case) using environment variables while still provide the possibility to use a more simple form of configuration like a yaml file.

How to use

pip install container-app-conf

Extend Config base

from container_app_conf import Config
from container_app_conf.entry.string import StringConfigEntry

class AppConfig(Config):

    @property
    def config_file_names(self) -> [str]:
        return ["my_app_config_file_name"]

    MY_CONFIG = StringConfigEntry(
        yaml_path=[
            "my_app_config_file_name",
            "example"
        ],
        none_allowed=False)

Config Types

Name Description Type
BoolConfigEntry Parses bool, int (0 and 1) and str values (yes, no etc.) to a boolean value bool
IntConfigEntry Parses input to an integer int
FloatConfigEntry Parses input to a floating number float
StringConfigEntry Takes the raw string input str
ListConfigEntry Parses a comma separated string to a list of items specified in another ConfigEntry (in yaml it can also be specified as a yaml list) []

If none of the existing types suit your needs you can easily create your own by extending the ConfigEntry base class.

Default Values

A default value can be specified for every ConfigEntry by using the default constructor parameter.

Allow None

By default a None value is only allowed if the default value is None. This means it is not possible to set the MY_CONFIG entry in the example at the top to None even after initial parsing. Specifying an empty text in the yaml or corresponding environment variable will result in an exception. If you want to allow setting a None value you can use the none_allowed constructor parameter.

Contributing

GitHub is for social coding: if you want to write code, I encourage contributions through pull requests from forks of this repository. Create GitHub tickets for bugs and new features and comment on the ones that you are interested in.

License

container-app-conf
Copyright (c) 2019 Markus Ressel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

container_app_conf-1.0.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

container_app_conf-1.0.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file container_app_conf-1.0.1.tar.gz.

File metadata

  • Download URL: container_app_conf-1.0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

File hashes

Hashes for container_app_conf-1.0.1.tar.gz
Algorithm Hash digest
SHA256 98ec1a5d0ea9d366c269b3513b5bb0ea88124f8d26ec88fd421c4c5b8ab20edf
MD5 d549c8e4d6125b44b68327d8c4411c55
BLAKE2b-256 f27f9490a9e5fc1912fc5f305219e876647e7fac0044f0ff5b7e9d68eda0ed15

See more details on using hashes here.

Provenance

File details

Details for the file container_app_conf-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: container_app_conf-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

File hashes

Hashes for container_app_conf-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6126313dded536f83398de0401701c8b19abfa6af593358ad6559ad89a12f93e
MD5 e47052fb445e9087b06c8a84e9ce8f8f
BLAKE2b-256 88dfb9e98f3ce554d6fbe5f74d7346635c89cd308db647eca866f720a1a8397f

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page