dbt-platform-helper 12.4.1__py3-none-any.whl → 12.5.1__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.
- dbt_platform_helper/COMMANDS.md +1 -6
- dbt_platform_helper/commands/config.py +2 -2
- dbt_platform_helper/commands/copilot.py +51 -30
- dbt_platform_helper/commands/environment.py +25 -185
- dbt_platform_helper/commands/pipeline.py +10 -173
- dbt_platform_helper/constants.py +10 -0
- dbt_platform_helper/domain/codebase.py +8 -4
- dbt_platform_helper/domain/config_validator.py +242 -0
- dbt_platform_helper/domain/copilot_environment.py +204 -0
- dbt_platform_helper/domain/database_copy.py +16 -12
- dbt_platform_helper/domain/maintenance_page.py +44 -20
- dbt_platform_helper/domain/pipelines.py +213 -0
- dbt_platform_helper/domain/terraform_environment.py +86 -0
- dbt_platform_helper/domain/test_platform_terraform_manifest_generator.py +100 -0
- dbt_platform_helper/jinja2_tags.py +1 -1
- dbt_platform_helper/providers/cache.py +14 -21
- dbt_platform_helper/providers/cloudformation.py +0 -1
- dbt_platform_helper/providers/config.py +100 -0
- dbt_platform_helper/providers/copilot.py +2 -0
- dbt_platform_helper/providers/files.py +26 -0
- dbt_platform_helper/providers/opensearch.py +36 -0
- dbt_platform_helper/providers/platform_config_schema.py +589 -527
- dbt_platform_helper/providers/redis.py +34 -0
- dbt_platform_helper/providers/vpc.py +57 -0
- dbt_platform_helper/providers/yaml_file.py +72 -0
- dbt_platform_helper/templates/addons/svc/s3-cross-account-policy.yml +67 -0
- dbt_platform_helper/utils/application.py +32 -34
- dbt_platform_helper/utils/aws.py +1 -107
- dbt_platform_helper/utils/files.py +8 -59
- dbt_platform_helper/utils/platform_config.py +0 -7
- dbt_platform_helper/utils/template.py +10 -0
- dbt_platform_helper/utils/validation.py +5 -327
- dbt_platform_helper/utils/versioning.py +12 -0
- {dbt_platform_helper-12.4.1.dist-info → dbt_platform_helper-12.5.1.dist-info}/METADATA +2 -2
- {dbt_platform_helper-12.4.1.dist-info → dbt_platform_helper-12.5.1.dist-info}/RECORD +38 -26
- {dbt_platform_helper-12.4.1.dist-info → dbt_platform_helper-12.5.1.dist-info}/WHEEL +1 -1
- {dbt_platform_helper-12.4.1.dist-info → dbt_platform_helper-12.5.1.dist-info}/LICENSE +0 -0
- {dbt_platform_helper-12.4.1.dist-info → dbt_platform_helper-12.5.1.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
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 FileNotFoundException
|
|
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: YamlFileProvider = 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
|
+
# TODO refactor so that apply_environment_defaults isn't set, discarded and set again
|
|
29
|
+
def get_enriched_config(self):
|
|
30
|
+
return self.apply_environment_defaults(self.load_and_validate_platform_config())
|
|
31
|
+
|
|
32
|
+
def validate_platform_config(self):
|
|
33
|
+
PlatformConfigSchema.schema().validate(self.config)
|
|
34
|
+
|
|
35
|
+
# TODO= logically this isn't validation but loading + parsing, to move.
|
|
36
|
+
# also, we apply defaults but discard that data. Should we just apply
|
|
37
|
+
# defaults to config returned by load_and_validate
|
|
38
|
+
enriched_config = ConfigProvider.apply_environment_defaults(self.config)
|
|
39
|
+
self.validator.run_validations(enriched_config)
|
|
40
|
+
|
|
41
|
+
def load_and_validate_platform_config(self, path=PLATFORM_CONFIG_FILE):
|
|
42
|
+
try:
|
|
43
|
+
self.config = self.file_provider.load(path)
|
|
44
|
+
except FileNotFoundException as e:
|
|
45
|
+
abort_with_error(
|
|
46
|
+
f"{e} Please check it exists and you are in the root directory of your deployment project."
|
|
47
|
+
)
|
|
48
|
+
except FileProviderException as e:
|
|
49
|
+
abort_with_error(f"Error loading configuration from {path}: {e}")
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
self.validate_platform_config()
|
|
53
|
+
except SchemaError as e:
|
|
54
|
+
abort_with_error(f"Schema error in {path}. {e}")
|
|
55
|
+
|
|
56
|
+
return self.config
|
|
57
|
+
|
|
58
|
+
@staticmethod
|
|
59
|
+
# TODO this general function should be moved out of ConfigProvider
|
|
60
|
+
def config_file_check(path=PLATFORM_CONFIG_FILE):
|
|
61
|
+
if not Path(path).exists():
|
|
62
|
+
abort_with_error(
|
|
63
|
+
f"`{path}` is missing. "
|
|
64
|
+
"Please check it exists and you are in the root directory of your deployment project."
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
@staticmethod
|
|
68
|
+
def apply_environment_defaults(config):
|
|
69
|
+
if "environments" not in config:
|
|
70
|
+
return config
|
|
71
|
+
|
|
72
|
+
enriched_config = deepcopy(config)
|
|
73
|
+
|
|
74
|
+
environments = enriched_config["environments"]
|
|
75
|
+
env_defaults = environments.get("*", {})
|
|
76
|
+
without_defaults_entry = {
|
|
77
|
+
name: data if data else {} for name, data in environments.items() if name != "*"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
default_versions = config.get("default_versions", {})
|
|
81
|
+
|
|
82
|
+
def combine_env_data(data):
|
|
83
|
+
return {
|
|
84
|
+
**env_defaults,
|
|
85
|
+
**data,
|
|
86
|
+
"versions": {
|
|
87
|
+
**default_versions,
|
|
88
|
+
**env_defaults.get("versions", {}),
|
|
89
|
+
**data.get("versions", {}),
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
defaulted_envs = {
|
|
94
|
+
env_name: combine_env_data(env_data)
|
|
95
|
+
for env_name, env_data in without_defaults_entry.items()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
enriched_config["environments"] = defaulted_envs
|
|
99
|
+
|
|
100
|
+
return enriched_config
|
|
@@ -64,6 +64,7 @@ def create_addon_client_task(
|
|
|
64
64
|
f"{execution_role}"
|
|
65
65
|
f"--image {CONDUIT_DOCKER_IMAGE_LOCATION}:{addon_type} "
|
|
66
66
|
f"--secrets CONNECTION_SECRET={_get_secrets_provider(application, env).get_connection_secret_arn(secret_name)} "
|
|
67
|
+
"--cpu 2048 --memory 4096 "
|
|
67
68
|
"--platform-os linux "
|
|
68
69
|
"--platform-arch arm64",
|
|
69
70
|
shell=True,
|
|
@@ -98,6 +99,7 @@ def create_postgres_admin_task(
|
|
|
98
99
|
f"--task-group-name {task_name} "
|
|
99
100
|
f"--image {CONDUIT_DOCKER_IMAGE_LOCATION}:{addon_type} "
|
|
100
101
|
f"--env-vars CONNECTION_SECRET='{connection_string}' "
|
|
102
|
+
"--cpu 2048 --memory 4096 "
|
|
101
103
|
"--platform-os linux "
|
|
102
104
|
"--platform-arch arm64",
|
|
103
105
|
shell=True,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from os import makedirs
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class FileProvider:
|
|
6
|
+
|
|
7
|
+
def load(path: str) -> str:
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
@staticmethod
|
|
11
|
+
def mkfile(base_path: str, file_path: str, contents, overwrite=False) -> str:
|
|
12
|
+
file_path = Path(file_path)
|
|
13
|
+
file = Path(base_path).joinpath(file_path)
|
|
14
|
+
file_exists = file.exists()
|
|
15
|
+
|
|
16
|
+
if not file_path.parent.exists():
|
|
17
|
+
makedirs(file_path.parent)
|
|
18
|
+
|
|
19
|
+
if file_exists and not overwrite:
|
|
20
|
+
return f"File {file_path} exists; doing nothing"
|
|
21
|
+
|
|
22
|
+
action = "overwritten" if file_exists and overwrite else "created"
|
|
23
|
+
|
|
24
|
+
file.write_text(contents)
|
|
25
|
+
|
|
26
|
+
return f"File {file_path} {action}"
|
|
@@ -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()
|