dsw-config 4.8.2__tar.gz → 4.9.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dsw_config-4.8.2 → dsw_config-4.9.1}/PKG-INFO +1 -1
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw/config/build_info.py +4 -4
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw/config/keys.py +11 -80
- dsw_config-4.9.1/dsw/config/model.py +92 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw/config/parser.py +6 -18
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw_config.egg-info/PKG-INFO +1 -1
- {dsw_config-4.8.2 → dsw_config-4.9.1}/pyproject.toml +1 -1
- dsw_config-4.8.2/dsw/config/model.py +0 -166
- {dsw_config-4.8.2 → dsw_config-4.9.1}/LICENSE +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/README.md +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw/config/__init__.py +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw/config/logging.py +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw/config/sentry.py +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw_config.egg-info/SOURCES.txt +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw_config.egg-info/dependency_links.txt +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw_config.egg-info/not-zip-safe +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw_config.egg-info/requires.txt +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/dsw_config.egg-info/top_level.txt +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/setup.cfg +0 -0
- {dsw_config-4.8.2 → dsw_config-4.9.1}/setup.py +0 -0
|
@@ -9,9 +9,9 @@ BuildInfo = namedtuple(
|
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
BUILD_INFO = BuildInfo(
|
|
12
|
-
version='v4.
|
|
13
|
-
built_at='2024-08-09 12:
|
|
14
|
-
sha='
|
|
12
|
+
version='v4.9.1~7683c81',
|
|
13
|
+
built_at='2024-08-09 12:59:13Z',
|
|
14
|
+
sha='7683c812aa2f5a13563b62ef30e7041049eab35d',
|
|
15
15
|
branch='HEAD',
|
|
16
|
-
tag='v4.
|
|
16
|
+
tag='v4.9.1',
|
|
17
17
|
)
|
|
@@ -232,99 +232,30 @@ class _S3Keys(ConfigKeysContainer):
|
|
|
232
232
|
)
|
|
233
233
|
|
|
234
234
|
|
|
235
|
-
class
|
|
236
|
-
|
|
237
|
-
yaml_path=['
|
|
238
|
-
var_names=['
|
|
239
|
-
default=True,
|
|
240
|
-
cast=cast_bool,
|
|
241
|
-
)
|
|
242
|
-
name = ConfigKey(
|
|
243
|
-
yaml_path=['mail', 'name'],
|
|
244
|
-
var_names=['MAIL_NAME'],
|
|
245
|
-
default='',
|
|
246
|
-
cast=cast_str,
|
|
247
|
-
)
|
|
248
|
-
email = ConfigKey(
|
|
249
|
-
yaml_path=['mail', 'email'],
|
|
250
|
-
var_names=['MAIL_EMAIL'],
|
|
251
|
-
default='',
|
|
252
|
-
cast=cast_str,
|
|
253
|
-
)
|
|
254
|
-
host = ConfigKey(
|
|
255
|
-
yaml_path=['mail', 'host'],
|
|
256
|
-
var_names=['MAIL_HOST'],
|
|
257
|
-
default='',
|
|
258
|
-
cast=cast_str,
|
|
259
|
-
)
|
|
260
|
-
port = ConfigKey(
|
|
261
|
-
yaml_path=['mail', 'port'],
|
|
262
|
-
var_names=['MAIL_PORT'],
|
|
263
|
-
cast=cast_str,
|
|
264
|
-
)
|
|
265
|
-
ssl = ConfigKey(
|
|
266
|
-
yaml_path=['mail', 'ssl'],
|
|
267
|
-
var_names=[],
|
|
268
|
-
cast=cast_optional_str,
|
|
269
|
-
)
|
|
270
|
-
security = ConfigKey(
|
|
271
|
-
yaml_path=['mail', 'security'],
|
|
272
|
-
var_names=['MAIL_SECURITY'],
|
|
235
|
+
class _AWSKeys(ConfigKeysContainer):
|
|
236
|
+
access_key_id = ConfigKey(
|
|
237
|
+
yaml_path=['aws', 'awsAccessKeyId'],
|
|
238
|
+
var_names=['AWS_AWS_ACCESS_KEY_ID'],
|
|
273
239
|
cast=cast_optional_str,
|
|
274
240
|
)
|
|
275
|
-
|
|
276
|
-
yaml_path=['
|
|
277
|
-
var_names=[],
|
|
278
|
-
cast=cast_optional_bool,
|
|
279
|
-
)
|
|
280
|
-
username = ConfigKey(
|
|
281
|
-
yaml_path=['mail', 'username'],
|
|
282
|
-
var_names=['MAIL_USERNAME'],
|
|
241
|
+
secret_access_key = ConfigKey(
|
|
242
|
+
yaml_path=['aws', 'awsSecretAccessKey'],
|
|
243
|
+
var_names=['AWS_AWS_SECRET_ACCESS_KEY'],
|
|
283
244
|
cast=cast_optional_str,
|
|
284
245
|
)
|
|
285
|
-
|
|
286
|
-
yaml_path=['
|
|
287
|
-
var_names=['
|
|
288
|
-
cast=cast_optional_str,
|
|
289
|
-
)
|
|
290
|
-
rate_limit_window = ConfigKey(
|
|
291
|
-
yaml_path=['mail', 'rateLimit', 'window'],
|
|
292
|
-
var_names=['MAIL_RATE_LIMIT_WINDOW'],
|
|
293
|
-
default=0,
|
|
294
|
-
cast=cast_int,
|
|
295
|
-
)
|
|
296
|
-
rate_limit_count = ConfigKey(
|
|
297
|
-
yaml_path=['mail', 'rateLimit', 'count'],
|
|
298
|
-
var_names=['MAIL_RATE_LIMIT_COUNT'],
|
|
299
|
-
default=0,
|
|
300
|
-
cast=cast_int,
|
|
301
|
-
)
|
|
302
|
-
timeout = ConfigKey(
|
|
303
|
-
yaml_path=['mail', 'timeout'],
|
|
304
|
-
var_names=['MAIL_TIMEOUT'],
|
|
305
|
-
default=10,
|
|
306
|
-
cast=cast_int,
|
|
307
|
-
)
|
|
308
|
-
dkim_selector = ConfigKey(
|
|
309
|
-
yaml_path=['mail', 'dkim', 'selector'],
|
|
310
|
-
var_names=['MAIL_DKIM_SELECTOR'],
|
|
311
|
-
default=None,
|
|
312
|
-
cast=cast_optional_str,
|
|
313
|
-
)
|
|
314
|
-
dkim_privkey_file = ConfigKey(
|
|
315
|
-
yaml_path=['mail', 'dkim', 'privkey_file'],
|
|
316
|
-
var_names=['MAIL_DKIM_PRIVKEY_FILE'],
|
|
317
|
-
default=None,
|
|
246
|
+
region = ConfigKey(
|
|
247
|
+
yaml_path=['aws', 'awsRegion'],
|
|
248
|
+
var_names=['AWS_AWS_REGION'],
|
|
318
249
|
cast=cast_optional_str,
|
|
319
250
|
)
|
|
320
251
|
|
|
321
252
|
|
|
322
253
|
class ConfigKeys(ConfigKeysContainer):
|
|
254
|
+
aws = _AWSKeys
|
|
323
255
|
cloud = _CloudKeys
|
|
324
256
|
database = _DatabaseKeys
|
|
325
257
|
general = _GeneralKeys
|
|
326
258
|
logging = _LoggingKeys
|
|
327
|
-
mail = _MailKeys
|
|
328
259
|
s3 = _S3Keys
|
|
329
260
|
sentry = _SentryKeys
|
|
330
261
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from .logging import prepare_logging, LOG_FILTER
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _config_to_string(config: object):
|
|
7
|
+
lines = [f'{type(config).__name__}']
|
|
8
|
+
fields = (f for f in config.__dict__.keys() if not f.startswith('_'))
|
|
9
|
+
for field in fields:
|
|
10
|
+
v = str(getattr(config, field))
|
|
11
|
+
t = type(getattr(config, field)).__name__
|
|
12
|
+
lines.append(f'- {field} = {v} [{t}]')
|
|
13
|
+
return '\n'.join(lines)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ConfigModel:
|
|
17
|
+
|
|
18
|
+
def __str__(self):
|
|
19
|
+
return _config_to_string(self)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class GeneralConfig(ConfigModel):
|
|
23
|
+
|
|
24
|
+
def __init__(self, environment: str, client_url: str, secret: str):
|
|
25
|
+
self.environment = environment
|
|
26
|
+
self.client_url = client_url
|
|
27
|
+
self.secret = secret
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class SentryConfig(ConfigModel):
|
|
31
|
+
|
|
32
|
+
def __init__(self, enabled: bool, workers_dsn: Optional[str],
|
|
33
|
+
traces_sample_rate: Optional[float], max_breadcrumbs: Optional[int]):
|
|
34
|
+
self.enabled = enabled
|
|
35
|
+
self.workers_dsn = workers_dsn
|
|
36
|
+
self.traces_sample_rate = traces_sample_rate
|
|
37
|
+
self.max_breadcrumbs = max_breadcrumbs
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class DatabaseConfig(ConfigModel):
|
|
41
|
+
|
|
42
|
+
def __init__(self, connection_string: str, connection_timeout: int, queue_timout: int):
|
|
43
|
+
self.connection_string = connection_string
|
|
44
|
+
self.connection_timeout = connection_timeout
|
|
45
|
+
self.queue_timout = queue_timout
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class S3Config(ConfigModel):
|
|
49
|
+
|
|
50
|
+
def __init__(self, url: str, username: str, password: str,
|
|
51
|
+
bucket: str, region: str):
|
|
52
|
+
self.url = url
|
|
53
|
+
self.username = username
|
|
54
|
+
self.password = password
|
|
55
|
+
self.bucket = bucket
|
|
56
|
+
self.region = region
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class LoggingConfig(ConfigModel):
|
|
60
|
+
|
|
61
|
+
def __init__(self, level: str, global_level: str, message_format: str,
|
|
62
|
+
dict_config: Optional[dict] = None):
|
|
63
|
+
self.level = level
|
|
64
|
+
self.global_level = global_level
|
|
65
|
+
self.message_format = message_format
|
|
66
|
+
self.dict_config = dict_config
|
|
67
|
+
|
|
68
|
+
def apply(self):
|
|
69
|
+
prepare_logging(self)
|
|
70
|
+
|
|
71
|
+
@staticmethod
|
|
72
|
+
def set_logging_extra(key: str, value: str):
|
|
73
|
+
LOG_FILTER.set_extra(key, value)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class AWSConfig(ConfigModel):
|
|
77
|
+
|
|
78
|
+
def __init__(self, access_key_id: Optional[str], secret_access_key: Optional[str],
|
|
79
|
+
region: Optional[str]):
|
|
80
|
+
self.access_key_id = access_key_id
|
|
81
|
+
self.secret_access_key = secret_access_key
|
|
82
|
+
self.region = region
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def has_credentials(self) -> bool:
|
|
86
|
+
return self.access_key_id is not None and self.secret_access_key is not None
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class CloudConfig(ConfigModel):
|
|
90
|
+
|
|
91
|
+
def __init__(self, multi_tenant: bool):
|
|
92
|
+
self.multi_tenant = multi_tenant
|
|
@@ -5,7 +5,7 @@ from typing import List, Any, IO
|
|
|
5
5
|
|
|
6
6
|
from .keys import ConfigKey, ConfigKeys
|
|
7
7
|
from .model import GeneralConfig, SentryConfig, S3Config, \
|
|
8
|
-
DatabaseConfig, LoggingConfig, CloudConfig,
|
|
8
|
+
DatabaseConfig, LoggingConfig, CloudConfig, AWSConfig
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class MissingConfigurationError(Exception):
|
|
@@ -129,21 +129,9 @@ class DSWConfigParser:
|
|
|
129
129
|
)
|
|
130
130
|
|
|
131
131
|
@property
|
|
132
|
-
def
|
|
133
|
-
return
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
host=self.get(self.keys.mail.host),
|
|
138
|
-
ssl=self.get(self.keys.mail.ssl),
|
|
139
|
-
port=self.get(self.keys.mail.port),
|
|
140
|
-
security=self.get(self.keys.mail.security),
|
|
141
|
-
auth_enabled=self.get(self.keys.mail.auth_enabled),
|
|
142
|
-
username=self.get(self.keys.mail.username),
|
|
143
|
-
password=self.get(self.keys.mail.password),
|
|
144
|
-
rate_limit_window=int(self.get(self.keys.mail.rate_limit_window)),
|
|
145
|
-
rate_limit_count=int(self.get(self.keys.mail.rate_limit_count)),
|
|
146
|
-
timeout=int(self.get(self.keys.mail.timeout)),
|
|
147
|
-
dkim_selector=self.get(self.keys.mail.dkim_selector),
|
|
148
|
-
dkim_privkey_file=self.get(self.keys.mail.dkim_privkey_file),
|
|
132
|
+
def aws(self) -> AWSConfig:
|
|
133
|
+
return AWSConfig(
|
|
134
|
+
access_key_id=self.get(self.keys.aws.access_key_id),
|
|
135
|
+
secret_access_key=self.get(self.keys.aws.secret_access_key),
|
|
136
|
+
region=self.get(self.keys.aws.region),
|
|
149
137
|
)
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import pathlib
|
|
2
|
-
from typing import Optional
|
|
3
|
-
|
|
4
|
-
from .logging import prepare_logging, LOG_FILTER
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def _config_to_string(config: object):
|
|
8
|
-
lines = [f'{type(config).__name__}']
|
|
9
|
-
fields = (f for f in config.__dict__.keys() if not f.startswith('_'))
|
|
10
|
-
for field in fields:
|
|
11
|
-
v = str(getattr(config, field))
|
|
12
|
-
t = type(getattr(config, field)).__name__
|
|
13
|
-
lines.append(f'- {field} = {v} [{t}]')
|
|
14
|
-
return '\n'.join(lines)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class ConfigModel:
|
|
18
|
-
|
|
19
|
-
def __str__(self):
|
|
20
|
-
return _config_to_string(self)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class GeneralConfig(ConfigModel):
|
|
24
|
-
|
|
25
|
-
def __init__(self, environment: str, client_url: str, secret: str):
|
|
26
|
-
self.environment = environment
|
|
27
|
-
self.client_url = client_url
|
|
28
|
-
self.secret = secret
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class SentryConfig(ConfigModel):
|
|
32
|
-
|
|
33
|
-
def __init__(self, enabled: bool, workers_dsn: Optional[str],
|
|
34
|
-
traces_sample_rate: Optional[float], max_breadcrumbs: Optional[int]):
|
|
35
|
-
self.enabled = enabled
|
|
36
|
-
self.workers_dsn = workers_dsn
|
|
37
|
-
self.traces_sample_rate = traces_sample_rate
|
|
38
|
-
self.max_breadcrumbs = max_breadcrumbs
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
class DatabaseConfig(ConfigModel):
|
|
42
|
-
|
|
43
|
-
def __init__(self, connection_string: str, connection_timeout: int, queue_timout: int):
|
|
44
|
-
self.connection_string = connection_string
|
|
45
|
-
self.connection_timeout = connection_timeout
|
|
46
|
-
self.queue_timout = queue_timout
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
class S3Config(ConfigModel):
|
|
50
|
-
|
|
51
|
-
def __init__(self, url: str, username: str, password: str,
|
|
52
|
-
bucket: str, region: str):
|
|
53
|
-
self.url = url
|
|
54
|
-
self.username = username
|
|
55
|
-
self.password = password
|
|
56
|
-
self.bucket = bucket
|
|
57
|
-
self.region = region
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
class LoggingConfig(ConfigModel):
|
|
61
|
-
|
|
62
|
-
def __init__(self, level: str, global_level: str, message_format: str,
|
|
63
|
-
dict_config: Optional[dict] = None):
|
|
64
|
-
self.level = level
|
|
65
|
-
self.global_level = global_level
|
|
66
|
-
self.message_format = message_format
|
|
67
|
-
self.dict_config = dict_config
|
|
68
|
-
|
|
69
|
-
def apply(self):
|
|
70
|
-
prepare_logging(self)
|
|
71
|
-
|
|
72
|
-
@staticmethod
|
|
73
|
-
def set_logging_extra(key: str, value: str):
|
|
74
|
-
LOG_FILTER.set_extra(key, value)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
class CloudConfig(ConfigModel):
|
|
78
|
-
|
|
79
|
-
def __init__(self, multi_tenant: bool):
|
|
80
|
-
self.multi_tenant = multi_tenant
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
class MailConfig(ConfigModel):
|
|
84
|
-
|
|
85
|
-
def __init__(self, enabled: bool, ssl: Optional[bool], name: str, email: str,
|
|
86
|
-
host: str, port: Optional[int], security: Optional[str],
|
|
87
|
-
auth_enabled: Optional[bool], username: Optional[str],
|
|
88
|
-
password: Optional[str], rate_limit_window: int,
|
|
89
|
-
rate_limit_count: int, timeout: int,
|
|
90
|
-
dkim_selector: Optional[str] = None,
|
|
91
|
-
dkim_privkey_file: Optional[str] = None):
|
|
92
|
-
self.enabled = enabled
|
|
93
|
-
self.name = name
|
|
94
|
-
self.email = email
|
|
95
|
-
self.host = host
|
|
96
|
-
self.security = 'plain'
|
|
97
|
-
if security is not None:
|
|
98
|
-
self.security = security.lower()
|
|
99
|
-
elif ssl is not None:
|
|
100
|
-
self.security = 'ssl' if ssl else 'plain'
|
|
101
|
-
self.port = port or self._default_port()
|
|
102
|
-
self.auth = auth_enabled
|
|
103
|
-
if self.auth is None:
|
|
104
|
-
self.auth = username is not None and password is not None
|
|
105
|
-
self.username = username
|
|
106
|
-
self.password = password
|
|
107
|
-
self.rate_limit_window = rate_limit_window
|
|
108
|
-
self.rate_limit_count = rate_limit_count
|
|
109
|
-
self.timeout = timeout
|
|
110
|
-
self.dkim_selector = dkim_selector
|
|
111
|
-
self.dkim_privkey_file = dkim_privkey_file
|
|
112
|
-
self.dkim_privkey = b''
|
|
113
|
-
|
|
114
|
-
def load_dkim_privkey(self):
|
|
115
|
-
if self.dkim_privkey_file is not None:
|
|
116
|
-
self.dkim_privkey = pathlib.Path(self.dkim_privkey_file).read_bytes()
|
|
117
|
-
self.dkim_privkey = self.dkim_privkey.replace(b'\r\n', b'\n')
|
|
118
|
-
|
|
119
|
-
@property
|
|
120
|
-
def use_dkim(self):
|
|
121
|
-
return self.dkim_selector is not None and len(self.dkim_privkey) > 0
|
|
122
|
-
|
|
123
|
-
@property
|
|
124
|
-
def login_user(self) -> str:
|
|
125
|
-
return self.username or ''
|
|
126
|
-
|
|
127
|
-
@property
|
|
128
|
-
def login_password(self) -> str:
|
|
129
|
-
return self.password or ''
|
|
130
|
-
|
|
131
|
-
@property
|
|
132
|
-
def is_plain(self):
|
|
133
|
-
return self.security == 'plain'
|
|
134
|
-
|
|
135
|
-
@property
|
|
136
|
-
def is_ssl(self):
|
|
137
|
-
return self.security == 'ssl'
|
|
138
|
-
|
|
139
|
-
@property
|
|
140
|
-
def is_tls(self):
|
|
141
|
-
return self.security == 'starttls' or self.security == 'tls'
|
|
142
|
-
|
|
143
|
-
def _default_port(self) -> int:
|
|
144
|
-
if self.is_plain:
|
|
145
|
-
return 25
|
|
146
|
-
if self.is_ssl:
|
|
147
|
-
return 465
|
|
148
|
-
return 587
|
|
149
|
-
|
|
150
|
-
def has_credentials(self) -> bool:
|
|
151
|
-
return self.username is not None and self.password is not None
|
|
152
|
-
|
|
153
|
-
def __str__(self):
|
|
154
|
-
return f'MailConfig\n' \
|
|
155
|
-
f'- enabled = {self.enabled}\n' \
|
|
156
|
-
f'- name = {self.name}\n' \
|
|
157
|
-
f'- email = {self.email}\n' \
|
|
158
|
-
f'- host = {self.host}\n' \
|
|
159
|
-
f'- port = {self.port}\n' \
|
|
160
|
-
f'- security = {self.security}\n' \
|
|
161
|
-
f'- auth = {self.auth}\n' \
|
|
162
|
-
f'- rate_limit_window = {self.rate_limit_window}\n' \
|
|
163
|
-
f'- rate_limit_count = {self.rate_limit_count}\n' \
|
|
164
|
-
f'- timeout = {self.timeout}\n' \
|
|
165
|
-
f'- dkim_selector = {self.dkim_selector}\n' \
|
|
166
|
-
f'- dkim_privkey_file = {self.dkim_privkey_file}\n'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|