|
1 | 1 | import re |
2 | 2 | import sys |
3 | 3 | import textwrap |
| 4 | +from collections import defaultdict |
4 | 5 | from dataclasses import dataclass, field |
5 | 6 | from functools import cache, cached_property |
6 | 7 | from pathlib import Path |
|
49 | 50 | } |
50 | 51 |
|
51 | 52 | # Topics with special max local bytes limits |
52 | | -WHITELISTED_TOPICS_FOR_MAX_LOCAL_TOPIC_BYTES_BY_TOPIC_AND_ENV = { |
| 53 | +ALLOWED_MAX_LOCAL_TOPIC_BYTES_BY_TOPIC_AND_ENV = { |
53 | 54 | "ais-listener.nmea": { |
54 | 55 | "prod": { |
55 | 56 | "max_limit": 5_368_709_120, # 5GB |
@@ -449,21 +450,20 @@ def validate_max_local_topic_bytes_compliance(self, value, schema): |
449 | 450 | if topic_max_local_bytes is None: |
450 | 451 | continue |
451 | 452 |
|
452 | | - if topic_name in WHITELISTED_TOPICS_FOR_MAX_LOCAL_TOPIC_BYTES_BY_TOPIC_AND_ENV: |
453 | | - if topic_env in WHITELISTED_TOPICS_FOR_MAX_LOCAL_TOPIC_BYTES_BY_TOPIC_AND_ENV[topic_name]: |
454 | | - if topic_max_local_bytes > WHITELISTED_TOPICS_FOR_MAX_LOCAL_TOPIC_BYTES_BY_TOPIC_AND_ENV[topic_name][topic_env]["max_limit"]: |
455 | | - yield ValidationError( |
456 | | - f"maxLocalTopicBytes exceeds the allowed maximum of {WHITELISTED_TOPICS_FOR_MAX_LOCAL_TOPIC_BYTES_BY_TOPIC_AND_ENV[topic_name][topic_env]['max_limit']} " |
457 | | - f"for topic '{topic_name}' in environment '{topic_env}'.\n" |
458 | | - " See https://kpler.atlassian.net/wiki/x/BgGKS for more information." |
459 | | - ) |
460 | | - continue |
461 | | - |
462 | | - yield ValidationError( |
463 | | - "maxLocalTopicBytes can only be used with allowed topics" |
464 | | - f" and topic '{topic_name}' is not allowed in environment '{topic_env}'." |
465 | | - " See https://kpler.atlassian.net/wiki/x/BgGKS for more information." |
466 | | - ) |
| 453 | + max_allowed_values = ALLOWED_MAX_LOCAL_TOPIC_BYTES_BY_TOPIC_AND_ENV.get(topic_name, {}).get(topic_env, {}).get("max_limit") |
| 454 | + if not max_allowed_values: |
| 455 | + yield ValidationError( |
| 456 | + "maxLocalTopicBytes can only be used with allowed topics" |
| 457 | + f" and topic '{topic_name}' is not allowed in environment '{topic_env}'." |
| 458 | + " See https://kpler.atlassian.net/wiki/x/BgGKS for more information." |
| 459 | + ) |
| 460 | + elif topic_max_local_bytes > max_allowed_values: |
| 461 | + yield ValidationError( |
| 462 | + f"maxLocalTopicBytes exceeds the allowed maximum of {max_allowed_values} " |
| 463 | + f"for topic '{topic_name}' in environment '{topic_env}'.\n" |
| 464 | + " See https://kpler.atlassian.net/wiki/x/BgGKS for more information." |
| 465 | + ) |
| 466 | + |
467 | 467 |
|
468 | 468 | def validate_forbidden_environment_variables(self, value, schema): |
469 | 469 | if not isinstance(value, dict): |
|
0 commit comments