diff --git a/hcloud/helpers/labels.py b/hcloud/helpers/labels.py index eb7527dd..c9f45a97 100644 --- a/hcloud/helpers/labels.py +++ b/hcloud/helpers/labels.py @@ -4,10 +4,10 @@ class LabelValidator: KEY_REGEX = re.compile( - "^([a-z0-9A-Z]((?:[\-_.]|[a-z0-9A-Z]){0,253}[a-z0-9A-Z])?/)?[a-z0-9A-Z]((?:[\-_.]|[a-z0-9A-Z]|){0,62}[a-z0-9A-Z])?$" + "^([a-z0-9A-Z]((?:[\-_.]|[a-z0-9A-Z]){0,253}[a-z0-9A-Z])?/)?[a-z0-9A-Z]((?:[\-_.]|[a-z0-9A-Z]|){0,61}[a-z0-9A-Z])?$" ) VALUE_REGEX = re.compile( - "^(([a-z0-9A-Z](?:[\-_.]|[a-z0-9A-Z]){0,62})?[a-z0-9A-Z]$|$)" + "^(([a-z0-9A-Z](?:[\-_.]|[a-z0-9A-Z]){0,61})?[a-z0-9A-Z]$|$)" ) @staticmethod diff --git a/tests/unit/helpers/test_labels.py b/tests/unit/helpers/test_labels.py index 927564cf..013394c1 100644 --- a/tests/unit/helpers/test_labels.py +++ b/tests/unit/helpers/test_labels.py @@ -22,6 +22,12 @@ }, False, ), + ( + { + "valid_key": "63-characters-are-allowed-in-a-label__this-is-one-character-more", + }, + False, + ), # invalid keys ({"incorrect.de/": "correct.de"}, False), ({"incor rect.de/": "correct.de"}, False), @@ -75,6 +81,13 @@ def test_validate(labels, expected): False, "value", ), + ( + { + "valid_key": "63-characters-are-allowed-in-a-label__this-is-one-character-more", + }, + False, + "value", + ), # invalid keys ({"incorrect.de/": "correct.de"}, False, "key"), ({"incor rect.de/": "correct.de"}, False, "key"),