-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
1 parent
da8c501
commit ad1e583
Showing
14 changed files
with
219 additions
and
25 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
DYNACONF_SERVER='prod_server_fromenv.com' | ||
DEV_SERVER='dev_server_fromenv.com' | ||
# switch namespaces or omit to default to DYNACONF | ||
NAMESPACE_FOR_DYNACONF=dev | ||
# NAMESPACE_FOR_DYNACONF=dev |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[dynaconf] | ||
[dev] | ||
password = 'My5up3r53c4et' |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[dynaconf] | ||
server = 'foo.com' | ||
username = 'prod user' | ||
password = false | ||
password = false # in prod this value must come from .secrets.toml or vault server | ||
STATIC_URL = '/changed/in/settings.toml/by/dynaconf/' | ||
[dev] | ||
username = 'dev user' |
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,141 @@ | ||
from dynaconf import settings | ||
|
||
|
||
print('# 1 all values in {} + {}: namespace of yaml file:'.format( | ||
settings.BASE_NAMESPACE_FOR_DYNACONF, | ||
settings.current_namespace)) | ||
assert settings.current_namespace == 'DEVELOPMENT' | ||
print('HOST::', settings.HOST) | ||
print('PORT:', settings.PORT) | ||
print('USERNAME:', settings.USERNAME) | ||
print('PASSWORD:', settings.PASSWORD) | ||
print('LEVELS:', settings.LEVELS) | ||
print('TEST_LOADERS:', settings.TEST_LOADERS) | ||
print('MONEY:', settings.MONEY) | ||
print('AGE:', settings.AGE) | ||
print('ENABLED:', settings.ENABLED) | ||
print('ENVIRONMENT:', settings.get('ENVIRONMENT')) | ||
print('WORKS:', settings.WORKS) | ||
|
||
with settings.using_namespace('TESTING'): | ||
print('# 2 using {}: namespace values for context:'.format( | ||
settings.current_namespace)) | ||
assert settings.current_namespace == 'TESTING' | ||
print('HOST::', settings.HOST) | ||
print('PORT:', settings.PORT) | ||
print('USERNAME:', settings.USERNAME) | ||
print('PASSWORD:', settings.PASSWORD) | ||
print('LEVELS:', settings.LEVELS) | ||
print('TEST_LOADERS:', settings.TEST_LOADERS) | ||
print('MONEY:', settings.MONEY) | ||
print('AGE:', settings.AGE) | ||
print('ENABLED:', settings.ENABLED) | ||
print('ENVIRONMENT:', settings.get('ENVIRONMENT')) | ||
print('WORKS:', settings.WORKS) | ||
|
||
print('# 3 back to default {}: namespace:'.format(settings.current_namespace)) | ||
assert settings.current_namespace == 'DEVELOPMENT' | ||
print('HOST::', settings.HOST) | ||
print('PORT:', settings.PORT) | ||
print('USERNAME:', settings.USERNAME) | ||
print('PASSWORD:', settings.PASSWORD) | ||
print('LEVELS:', settings.LEVELS) | ||
print('TEST_LOADERS:', settings.TEST_LOADERS) | ||
print('MONEY:', settings.MONEY) | ||
print('AGE:', settings.AGE) | ||
print('ENABLED:', settings.ENABLED) | ||
print('ENVIRONMENT:', settings.get('ENVIRONMENT')) | ||
print('WORKS:', settings.WORKS) | ||
|
||
settings.namespace('testing') | ||
print('# 4 Set to {}: namespace:'.format(settings.current_namespace)) | ||
assert settings.current_namespace == 'TESTING' | ||
print('HOST::', settings.HOST) | ||
print('PORT:', settings.PORT) | ||
print('USERNAME:', settings.USERNAME) | ||
print('PASSWORD:', settings.PASSWORD) | ||
print('LEVELS:', settings.LEVELS) | ||
print('TEST_LOADERS:', settings.TEST_LOADERS) | ||
print('MONEY:', settings.MONEY) | ||
print('AGE:', settings.AGE) | ||
print('ENABLED:', settings.ENABLED) | ||
print('ENVIRONMENT:', settings.get('ENVIRONMENT')) | ||
print('WORKS:', settings.WORKS) | ||
|
||
settings.namespace() | ||
print('# 5 back to default {}: namespace:'.format(settings.current_namespace)) | ||
assert settings.current_namespace == 'DEVELOPMENT' | ||
print('HOST::', settings.HOST) | ||
print('PORT:', settings.PORT) | ||
print('USERNAME:', settings.USERNAME) | ||
print('PASSWORD:', settings.PASSWORD) | ||
print('LEVELS:', settings.LEVELS) | ||
print('TEST_LOADERS:', settings.TEST_LOADERS) | ||
print('MONEY:', settings.MONEY) | ||
print('AGE:', settings.AGE) | ||
print('ENABLED:', settings.ENABLED) | ||
print('ENVIRONMENT:', settings.get('ENVIRONMENT')) | ||
print('WORKS:', settings.WORKS) | ||
|
||
|
||
with settings.using_namespace('staging'): | ||
print('# 6 using {}: namespace values for context:'.format( | ||
settings.current_namespace)) | ||
assert settings.current_namespace == 'STAGING' | ||
print('HOST::', settings.HOST) | ||
print('PORT:', settings.PORT) | ||
print('USERNAME:', settings.USERNAME) | ||
print('PASSWORD:', settings.PASSWORD) | ||
print('LEVELS:', settings.LEVELS) | ||
print('TEST_LOADERS:', settings.TEST_LOADERS) | ||
print('MONEY:', settings.MONEY) | ||
print('AGE:', settings.AGE) | ||
print('ENABLED:', settings.ENABLED) | ||
print('ENVIRONMENT:', settings.get('ENVIRONMENT')) | ||
print('WORKS:', settings.WORKS) | ||
|
||
print('# 7 back to default {}: namespace:'.format(settings.current_namespace)) | ||
assert settings.current_namespace == 'DEVELOPMENT' | ||
print('HOST::', settings.HOST) | ||
print('PORT:', settings.PORT) | ||
print('USERNAME:', settings.USERNAME) | ||
print('PASSWORD:', settings.PASSWORD) | ||
print('LEVELS:', settings.LEVELS) | ||
print('TEST_LOADERS:', settings.TEST_LOADERS) | ||
print('MONEY:', settings.MONEY) | ||
print('AGE:', settings.AGE) | ||
print('ENABLED:', settings.ENABLED) | ||
print('ENVIRONMENT:', settings.get('ENVIRONMENT')) | ||
print('WORKS:', settings.WORKS) | ||
|
||
settings.namespace('staging') | ||
assert settings.current_namespace == 'STAGING' | ||
print('# 8 Set to {}: namespace:'.format(settings.current_namespace)) | ||
print('HOST::', settings.HOST) | ||
print('PORT:', settings.PORT) | ||
print('USERNAME:', settings.USERNAME) | ||
print('PASSWORD:', settings.PASSWORD) | ||
print('LEVELS:', settings.LEVELS) | ||
print('TEST_LOADERS:', settings.TEST_LOADERS) | ||
print('MONEY:', settings.MONEY) | ||
print('AGE:', settings.AGE) | ||
print('ENABLED:', settings.ENABLED) | ||
print('ENVIRONMENT:', settings.get('ENVIRONMENT')) | ||
print('WORKS:', settings.WORKS) | ||
|
||
settings.namespace() | ||
print('# 9 back to default {}: namespace:'.format(settings.current_namespace)) | ||
print('HOST::', settings.HOST) | ||
print('PORT:', settings.PORT) | ||
print('USERNAME:', settings.USERNAME) | ||
print('PASSWORD:', settings.PASSWORD) | ||
print('LEVELS:', settings.LEVELS) | ||
print('TEST_LOADERS:', settings.TEST_LOADERS) | ||
print('MONEY:', settings.MONEY) | ||
print('AGE:', settings.AGE) | ||
print('ENABLED:', settings.ENABLED) | ||
print('ENVIRONMENT:', settings.get('ENVIRONMENT')) | ||
print('WORKS:', settings.WORKS) | ||
|
||
|
||
assert settings.current_namespace == 'DEVELOPMENT' |
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,44 @@ | ||
# This is the BASE namespace | ||
# the values from [prod] will be always loaded and used as default values | ||
# by default it was called [dynaconf] but in the .env file we changed the BASE_NAMESPACE_FOR_DYNACONF to PROD | ||
[prod] | ||
host = "server.com from TOML" | ||
port = 5000.0 | ||
username = "admin" | ||
PASSWORD = "Secret" | ||
levels = [ | ||
"debug", | ||
"info", | ||
"warning" | ||
] | ||
money = 500.5 | ||
age = 42.0 | ||
enabled = true | ||
works = "only_in_prod" | ||
|
||
[prod.test_loaders] | ||
dev = "test_dev" | ||
prod = "test_prod" | ||
|
||
|
||
# If other namespace is set by NAMESPACE_FOR_DYNACONF env var | ||
# or switch using settings.namespace or settings.using_namespace | ||
# then the [prod] values will be overwritten with: | ||
|
||
# When NAMESPACE_FOR_DYNACONF=TESTING | ||
[testing] | ||
environment = "this is testing from toml" | ||
host = "test_server.com from toml" | ||
works = 'only_in_test' | ||
|
||
# When NAMESPACE_FOR_DYNACONF=DEVELOPMENT | ||
[development] | ||
environment = "this is development from toml" | ||
host = "dev_server.com from toml" | ||
works = 'only_in_dev' | ||
|
||
# When NAMESPACE_FOR_DYNACONF=STAGING | ||
[staging] | ||
environment = "this is staging from toml" | ||
host = "staging_server.com from toml" | ||
works = 'only_in_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
File renamed without changes.
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