-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
168 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
changelog for configstore | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
|
||
v0.6 (unreleased) | ||
================= | ||
|
||
|
||
|
||
v0.5 | ||
==== | ||
|
||
Package library with flit. | ||
|
||
|
||
v0.4 | ||
==== | ||
|
||
New backend to get config from AWS SSM Parameter Store. | ||
|
||
|
||
v0.3 | ||
==== | ||
|
||
Added Store.add_backend method. | ||
|
||
|
||
v0.2 | ||
==== | ||
|
||
Introducing Store class with configurable backends instead of function. | ||
|
||
|
||
v0.1 | ||
==== | ||
|
||
First release! | ||
|
||
The get_config function finds values in environment variables | ||
or Docker secrets. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,14 @@ author-email = "[email protected]" | |
home-page = "https://github.com/caravancoop/configstore" | ||
description-file = "README.rst" | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"Development Status :: 4 - Beta", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
"Topic :: Software Development", | ||
"Topic :: System :: Installation/Setup", | ||
"Topic :: System :: Systems Administration", | ||
] | ||
requires = [ | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import pytest | ||
import configstore | ||
|
||
DOTENV_CONTENTS = u''' | ||
SECRET_KEY=1234dot | ||
ENVIRONMENT=PRODUCTION | ||
''' | ||
|
||
DOTENV_EMPTY = u''' | ||
''' | ||
|
||
|
||
def test_configstore_envvars_override_dotenv(monkeypatch, tmp_path): | ||
monkeypatch.setenv('ENVIRONMENT', 'STAGING') | ||
path = tmp_path / 'config.env' | ||
path.write_text(DOTENV_CONTENTS) | ||
|
||
store = configstore.Store([ | ||
configstore.EnvVarBackend(), | ||
configstore.DotenvBackend(str(path)), | ||
]) | ||
|
||
secret_key = store.get_setting('SECRET_KEY') | ||
environment = store.get_setting('ENVIRONMENT') | ||
|
||
assert secret_key == '1234dot' | ||
assert environment == 'STAGING' | ||
|
||
|
||
def test_configstore_dotenv_overrides_envvars(monkeypatch, tmp_path): | ||
monkeypatch.setenv('ENVIRONMENT', 'STAGING') | ||
path = tmp_path / 'config.env' | ||
path.write_text(DOTENV_CONTENTS) | ||
|
||
store = configstore.Store([ | ||
configstore.DotenvBackend(str(path)), | ||
configstore.EnvVarBackend(), | ||
]) | ||
|
||
secret_key = store.get_setting('SECRET_KEY') | ||
environment = store.get_setting('ENVIRONMENT') | ||
|
||
assert secret_key == '1234dot' | ||
assert environment == 'PRODUCTION' | ||
|
||
|
||
def test_dotenv_empty_file(monkeypatch, tmp_path): | ||
monkeypatch.setenv('ENVIRONMENT', 'STAGING') | ||
path = tmp_path / 'config.env' | ||
path.write_text(DOTENV_EMPTY) | ||
|
||
store = configstore.Store([ | ||
configstore.DotenvBackend(str(path)), | ||
configstore.EnvVarBackend(), | ||
]) | ||
|
||
with pytest.raises(Exception) as excinfo: | ||
store.get_setting('DEBUG') | ||
environment = store.get_setting('ENVIRONMENT') | ||
|
||
assert "Couldn't find setting" in str(excinfo.value) | ||
assert environment == 'STAGING' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters