Skip to content

Commit f188a1f

Browse files
committed
chore(config): change config key pattern
1 parent 23e70e8 commit f188a1f

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

rootfs/api/serializers/__init__.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,10 @@
3939
"the route kind only supports: %s" % ROUTE_PROTOCOL_MATCH.pattern)
4040
PROCTYPE_MATCH = re.compile(PROCTYPE_REGEX)
4141
PROCTYPE_MISMATCH_MSG = "Process types can only supports: %s" % PROCTYPE_MATCH.pattern
42-
MEMLIMIT_MATCH = re.compile(r'^(?P<mem>([1-9][0-9]*[mgMG]))$', re.IGNORECASE)
43-
MEMLIMIT_MISMATCH_MSG = (
44-
"Memory limit format: <number><unit>, "
45-
"where unit = M or G"
46-
)
47-
CPUSHARE_MATCH = re.compile(r'^(?P<cpu>([-+]?[1-9][0-9]*[m]?))$')
48-
CPUSHARE_MISMATCH_MSG = "CPU limit format: <value>, where value must be a numeric"
42+
4943
TAGVAL_MATCH = re.compile(r'^(?:[a-zA-Z\d][-\.\w]{0,61})?[a-zA-Z\d]$')
50-
CONFIGKEY_MATCH = re.compile(r'^[a-z_]+[a-z0-9_]*$', re.IGNORECASE)
51-
CONFIGKEY_MISMATCH_MSG = (
52-
"Config keys must start with a letter or underscore and "
53-
"only contain [A-z0-9_]"
54-
)
44+
CONFIGKEY_MATCH = re.compile(r'^[A-z0-9_\-\.]+$', re.IGNORECASE)
45+
CONFIGKEY_MISMATCH_MSG = ("Config key can only supports: %s" % CONFIGKEY_MATCH.pattern)
5546
CONFIG_LIMITS_MISMATCH_MSG = "The limit plan {} does not exist"
5647

5748
TERMINATION_GRACE_PERIOD_MATCH = re.compile(r'^[0-9]*$')

rootfs/api/tests/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def test_config_deploy_failure(self, mock_requests):
317317
def test_invalid_config_keys(self, mock_requests):
318318
"""Test that invalid config keys are rejected.
319319
"""
320-
keys = ("123", "../../foo", "FOO/", "FOO-BAR")
320+
keys = ("$123", "../../foo", "FOO/", "*FOO-BAR")
321321
app_id = self.create_app()
322322
url = f'/v2/apps/{app_id}/config'
323323
for k in keys:

0 commit comments

Comments
 (0)