|
1 | 1 | import re |
2 | 2 | import sys |
3 | 3 | import textwrap |
4 | | -from collections import defaultdict |
5 | 4 | from dataclasses import dataclass, field |
6 | 5 | from functools import cache, cached_property |
7 | 6 | from pathlib import Path |
@@ -437,32 +436,26 @@ def validate_topic_name_compliance(self, value, schema): |
437 | 436 |
|
438 | 437 | def validate_max_local_topic_bytes_compliance(self, value, schema): |
439 | 438 |
|
440 | | - topics = value.get("managedResources", {}).get("mskTopics", {}) |
441 | | - topic_env = value.get("env") |
442 | | - |
443 | | - if not topics: |
| 439 | + topic_max_local_bytes = value.get("maxLocalTopicBytes") |
| 440 | + if topic_max_local_bytes is None: |
444 | 441 | return |
445 | 442 |
|
446 | | - for topic_config in topics.values(): |
447 | | - topic_name = topic_config.get("topicName") |
448 | | - topic_max_local_bytes = topic_config.get("maxLocalTopicBytes") |
449 | | - |
450 | | - if topic_max_local_bytes is None: |
451 | | - continue |
| 443 | + topic_name = value.get("topicName") |
| 444 | + topic_env = self.service_instance_config.env |
452 | 445 |
|
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 | | - ) |
| 446 | + max_allowed_values = ALLOWED_MAX_LOCAL_TOPIC_BYTES_BY_TOPIC_AND_ENV.get(topic_name, {}).get(topic_env, {}).get("max_limit") |
| 447 | + if not max_allowed_values: |
| 448 | + yield ValidationError( |
| 449 | + "maxLocalTopicBytes can only be used with allowed topics" |
| 450 | + f" and topic '{topic_name}' is not allowed for environment '{topic_env}'." |
| 451 | + " See https://kpler.atlassian.net/wiki/x/BgGKS for more information." |
| 452 | + ) |
| 453 | + elif topic_max_local_bytes > max_allowed_values: |
| 454 | + yield ValidationError( |
| 455 | + f"maxLocalTopicBytes exceeds the allowed maximum of {max_allowed_values} " |
| 456 | + f"for topic '{topic_name}' in environment '{topic_env}'.\n" |
| 457 | + " See https://kpler.atlassian.net/wiki/x/BgGKS for more information." |
| 458 | + ) |
466 | 459 |
|
467 | 460 |
|
468 | 461 | def validate_forbidden_environment_variables(self, value, schema): |
|
0 commit comments