dbt-platform-helper 12.4.1__py3-none-any.whl → 12.5.0__py3-none-any.whl

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.

Potentially problematic release.


This version of dbt-platform-helper might be problematic. Click here for more details.

Files changed (28) hide show
  1. dbt_platform_helper/COMMANDS.md +0 -3
  2. dbt_platform_helper/commands/config.py +2 -2
  3. dbt_platform_helper/commands/copilot.py +47 -28
  4. dbt_platform_helper/commands/environment.py +16 -178
  5. dbt_platform_helper/commands/pipeline.py +4 -5
  6. dbt_platform_helper/constants.py +9 -0
  7. dbt_platform_helper/domain/config_validator.py +242 -0
  8. dbt_platform_helper/domain/copilot_environment.py +204 -0
  9. dbt_platform_helper/domain/database_copy.py +7 -5
  10. dbt_platform_helper/domain/terraform_environment.py +53 -0
  11. dbt_platform_helper/jinja2_tags.py +1 -1
  12. dbt_platform_helper/providers/cache.py +15 -21
  13. dbt_platform_helper/providers/cloudformation.py +0 -1
  14. dbt_platform_helper/providers/config.py +90 -0
  15. dbt_platform_helper/providers/opensearch.py +36 -0
  16. dbt_platform_helper/providers/platform_config_schema.py +589 -527
  17. dbt_platform_helper/providers/redis.py +34 -0
  18. dbt_platform_helper/providers/yaml_file.py +83 -0
  19. dbt_platform_helper/templates/addons/svc/s3-cross-account-policy.yml +67 -0
  20. dbt_platform_helper/utils/aws.py +1 -57
  21. dbt_platform_helper/utils/files.py +0 -36
  22. dbt_platform_helper/utils/template.py +10 -0
  23. dbt_platform_helper/utils/validation.py +5 -327
  24. {dbt_platform_helper-12.4.1.dist-info → dbt_platform_helper-12.5.0.dist-info}/METADATA +2 -2
  25. {dbt_platform_helper-12.4.1.dist-info → dbt_platform_helper-12.5.0.dist-info}/RECORD +28 -20
  26. {dbt_platform_helper-12.4.1.dist-info → dbt_platform_helper-12.5.0.dist-info}/WHEEL +1 -1
  27. {dbt_platform_helper-12.4.1.dist-info → dbt_platform_helper-12.5.0.dist-info}/LICENSE +0 -0
  28. {dbt_platform_helper-12.4.1.dist-info → dbt_platform_helper-12.5.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,90 @@
1
+ from copy import deepcopy
2
+ from pathlib import Path
3
+
4
+ import click
5
+ from schema import SchemaError
6
+
7
+ from dbt_platform_helper.constants import PLATFORM_CONFIG_FILE
8
+ from dbt_platform_helper.domain.config_validator import ConfigValidator
9
+ from dbt_platform_helper.providers.platform_config_schema import PlatformConfigSchema
10
+ from dbt_platform_helper.providers.yaml_file import FileProvider
11
+ from dbt_platform_helper.providers.yaml_file import FileProviderException
12
+ from dbt_platform_helper.providers.yaml_file import YamlFileProvider
13
+ from dbt_platform_helper.utils.messages import abort_with_error
14
+
15
+
16
+ class ConfigProvider:
17
+ def __init__(
18
+ self,
19
+ config_validator: ConfigValidator,
20
+ file_provider: FileProvider = None,
21
+ echo=click.secho,
22
+ ):
23
+ self.config = {}
24
+ self.validator = config_validator
25
+ self.echo = echo
26
+ self.file_provider = file_provider or YamlFileProvider
27
+
28
+ def validate_platform_config(self):
29
+ PlatformConfigSchema.schema().validate(self.config)
30
+
31
+ # TODO= logically this isn't validation but loading + parsing, to move.
32
+ enriched_config = ConfigProvider.apply_environment_defaults(self.config)
33
+ self.validator.run_validations(enriched_config)
34
+
35
+ def load_and_validate_platform_config(self, path=PLATFORM_CONFIG_FILE):
36
+ try:
37
+ self.config = self.file_provider.load(path)
38
+ except FileProviderException as e:
39
+ abort_with_error(f"Error loading configuration from {path}: {e}")
40
+
41
+ try:
42
+ self.validate_platform_config()
43
+ except SchemaError as e:
44
+ abort_with_error(f"Schema error in {path}. {e}")
45
+
46
+ return self.config
47
+
48
+ @staticmethod
49
+ # TODO this general function should be moved out of ConfigProvider
50
+ def config_file_check(path=PLATFORM_CONFIG_FILE):
51
+ if not Path(path).exists():
52
+ abort_with_error(
53
+ f"`{path}` is missing. "
54
+ "Please check it exists and you are in the root directory of your deployment project."
55
+ )
56
+
57
+ @staticmethod
58
+ def apply_environment_defaults(config):
59
+ if "environments" not in config:
60
+ return config
61
+
62
+ enriched_config = deepcopy(config)
63
+
64
+ environments = enriched_config["environments"]
65
+ env_defaults = environments.get("*", {})
66
+ without_defaults_entry = {
67
+ name: data if data else {} for name, data in environments.items() if name != "*"
68
+ }
69
+
70
+ default_versions = config.get("default_versions", {})
71
+
72
+ def combine_env_data(data):
73
+ return {
74
+ **env_defaults,
75
+ **data,
76
+ "versions": {
77
+ **default_versions,
78
+ **env_defaults.get("versions", {}),
79
+ **data.get("versions", {}),
80
+ },
81
+ }
82
+
83
+ defaulted_envs = {
84
+ env_name: combine_env_data(env_data)
85
+ for env_name, env_data in without_defaults_entry.items()
86
+ }
87
+
88
+ enriched_config["environments"] = defaulted_envs
89
+
90
+ return enriched_config
@@ -0,0 +1,36 @@
1
+ from dbt_platform_helper.providers.cache import CacheProvider
2
+
3
+
4
+ class OpensearchProvider:
5
+
6
+ def __init__(self, opensearch_client):
7
+ self.opensearch_client = opensearch_client
8
+
9
+ def get_supported_opensearch_versions(self) -> list[str]:
10
+
11
+ cache_provider = self.__get_cache_provider()
12
+
13
+ if cache_provider.cache_refresh_required("opensearch"):
14
+
15
+ response = self.opensearch_client.list_versions()
16
+ all_versions = response["Versions"]
17
+
18
+ opensearch_versions = [
19
+ version for version in all_versions if not version.startswith("Elasticsearch_")
20
+ ]
21
+ supported_versions = [
22
+ version.removeprefix("OpenSearch_") for version in opensearch_versions
23
+ ]
24
+
25
+ cache_provider.update_cache("opensearch", supported_versions)
26
+
27
+ return supported_versions
28
+
29
+ else:
30
+ return cache_provider.read_supported_versions_from_cache("opensearch")
31
+
32
+ # TODO - cache provider instantiated here rather than via dependancy injection since it will likely only be used in the get_supported_opensearch_versions method.
33
+ # If another method is added which needs a CacheProvider, it should be injected into the constructor instead.
34
+ @staticmethod
35
+ def __get_cache_provider():
36
+ return CacheProvider()