dbt-platform-helper 13.0.1__py3-none-any.whl → 13.0.2__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 (26) hide show
  1. dbt_platform_helper/COMMANDS.md +2 -2
  2. dbt_platform_helper/commands/config.py +26 -33
  3. dbt_platform_helper/commands/generate.py +2 -2
  4. dbt_platform_helper/commands/version.py +30 -30
  5. dbt_platform_helper/domain/config_validator.py +10 -5
  6. dbt_platform_helper/domain/copilot_environment.py +10 -9
  7. dbt_platform_helper/domain/maintenance_page.py +32 -7
  8. dbt_platform_helper/domain/terraform_environment.py +17 -61
  9. dbt_platform_helper/providers/config.py +11 -1
  10. dbt_platform_helper/providers/files.py +13 -12
  11. dbt_platform_helper/providers/semantic_version.py +126 -0
  12. dbt_platform_helper/providers/terraform_manifest.py +117 -26
  13. dbt_platform_helper/providers/validation.py +0 -14
  14. dbt_platform_helper/providers/version.py +36 -0
  15. dbt_platform_helper/providers/yaml_file.py +5 -3
  16. dbt_platform_helper/utils/application.py +3 -2
  17. dbt_platform_helper/utils/versioning.py +152 -221
  18. {dbt_platform_helper-13.0.1.dist-info → dbt_platform_helper-13.0.2.dist-info}/METADATA +1 -1
  19. {dbt_platform_helper-13.0.1.dist-info → dbt_platform_helper-13.0.2.dist-info}/RECORD +23 -24
  20. platform_helper.py +2 -2
  21. dbt_platform_helper/domain/test_platform_terraform_manifest_generator.py +0 -100
  22. dbt_platform_helper/templates/environments/main.tf +0 -46
  23. dbt_platform_helper/utils/platform_config.py +0 -20
  24. {dbt_platform_helper-13.0.1.dist-info → dbt_platform_helper-13.0.2.dist-info}/LICENSE +0 -0
  25. {dbt_platform_helper-13.0.1.dist-info → dbt_platform_helper-13.0.2.dist-info}/WHEEL +0 -0
  26. {dbt_platform_helper-13.0.1.dist-info → dbt_platform_helper-13.0.2.dist-info}/entry_points.txt +0 -0
@@ -1,100 +0,0 @@
1
- from unittest.mock import Mock
2
-
3
- from dbt_platform_helper.constants import DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION
4
- from dbt_platform_helper.domain.terraform_environment import (
5
- PlatformTerraformManifestGenerator,
6
- )
7
- from dbt_platform_helper.providers.files import FileProvider
8
-
9
-
10
- class TestPlatformTerraformManifestGenerator:
11
-
12
- def test_generator_generates_expected_manifest_content_with_version_override(self):
13
- test_environment_config = {
14
- "vpc": "vpc3",
15
- "accounts": {
16
- "deploy": {"name": "non-prod-acc", "id": "1122334455"},
17
- "dns": {"name": "non-prod-dns-acc", "id": "6677889900"},
18
- },
19
- "versions": {"terraform-platform-modules": 3},
20
- }
21
- expected_header = "# WARNING: This is an autogenerated file, not for manual editing."
22
- expected_modules = "git::https://github.com/uktrade/terraform-platform-modules.git//extensions?depth=1&ref=123456"
23
- expected_moved_block = (
24
- "moved {\n from = module.extensions-tf\n to = module.extensions\n}\n"
25
- )
26
-
27
- result = PlatformTerraformManifestGenerator(Mock()).generate_manifest(
28
- "test", "test-app", test_environment_config, 123456
29
- )
30
-
31
- assert expected_header in result
32
- assert expected_modules in result
33
- assert expected_moved_block in result
34
- assert 'environment = "test"' in result
35
- assert 'application = "test-app"' in result
36
- assert 'vpc_name = "vpc3"'
37
-
38
- def test_generator_generates_expected_manifest_content_with_tpm_version_set_in_config(self):
39
- test_environment_config = {
40
- "vpc": "vpc3",
41
- "accounts": {
42
- "deploy": {"name": "non-prod-acc", "id": "1122334455"},
43
- "dns": {"name": "non-prod-dns-acc", "id": "6677889900"},
44
- },
45
- "versions": {"terraform-platform-modules": 3},
46
- }
47
- expected_header = "# WARNING: This is an autogenerated file, not for manual editing."
48
- expected_modules = "git::https://github.com/uktrade/terraform-platform-modules.git//extensions?depth=1&ref=3"
49
- expected_moved_block = (
50
- "moved {\n from = module.extensions-tf\n to = module.extensions\n}\n"
51
- )
52
-
53
- result = PlatformTerraformManifestGenerator(Mock()).generate_manifest(
54
- "test", "test-app", test_environment_config
55
- )
56
-
57
- assert expected_header in result
58
- assert expected_modules in result
59
- assert expected_moved_block in result
60
- assert 'environment = "test"' in result
61
- assert 'application = "test-app"' in result
62
- assert 'vpc_name = "vpc3"'
63
-
64
- def test_generator_generates_expected_manifest_content_with_default_version(self):
65
- test_environment_config = {
66
- "vpc": "vpc3",
67
- "accounts": {
68
- "deploy": {"name": "non-prod-acc", "id": "1122334455"},
69
- "dns": {"name": "non-prod-dns-acc", "id": "6677889900"},
70
- },
71
- }
72
- expected_header = "# WARNING: This is an autogenerated file, not for manual editing."
73
- expected_modules = f"git::https://github.com/uktrade/terraform-platform-modules.git//extensions?depth=1&ref={DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION}"
74
- expected_moved_block = (
75
- "moved {\n from = module.extensions-tf\n to = module.extensions\n}\n"
76
- )
77
-
78
- result = PlatformTerraformManifestGenerator(Mock()).generate_manifest(
79
- "test", "test-app", test_environment_config
80
- )
81
-
82
- assert expected_header in result
83
- assert expected_modules in result
84
- assert expected_moved_block in result
85
- assert 'environment = "test"' in result
86
- assert 'application = "test-app"' in result
87
- assert 'vpc_name = "vpc3"'
88
-
89
- def test_generator_write_manifest_makes_the_expected_manifest_file(self):
90
- mock_file_provider = Mock(spec=FileProvider)
91
- PlatformTerraformManifestGenerator(mock_file_provider).write_manifest(
92
- "test-environment", "test-manifest-content"
93
- )
94
-
95
- mock_file_provider.mkfile.assert_called_once_with(
96
- ".",
97
- f"terraform/environments/test-environment/main.tf",
98
- "test-manifest-content",
99
- overwrite=True,
100
- )
@@ -1,46 +0,0 @@
1
- # {% extra_header %}
2
- # {% version_info %}
3
- locals {
4
- config = yamldecode(file("../../../platform-config.yml"))
5
- environments = local.config["environments"]
6
- env_config = { for name, config in local.environments : name => merge(lookup(local.environments, "*", {}), config) }
7
- args = {
8
- application = "{{ application }}"
9
- services = local.config["extensions"]
10
- env_config = local.env_config
11
- }
12
- }
13
-
14
- terraform {
15
- required_version = "{{ terraform_version }}"
16
- backend "s3" {
17
- bucket = "terraform-platform-state-{{ config.accounts.deploy.name }}"
18
- key = "tfstate/application/{{ application }}-{{ environment }}.tfstate"
19
- region = "eu-west-2"
20
- encrypt = true
21
- kms_key_id = "alias/terraform-platform-state-s3-key-{{ config.accounts.deploy.name }}"
22
- dynamodb_table = "terraform-platform-lockdb-{{ config.accounts.deploy.name }}"
23
- }
24
- required_providers {
25
- aws = {
26
- source = "hashicorp/aws"
27
- version = "{{ aws_provider_version }}"
28
- }
29
- }
30
- }
31
-
32
- module "extensions" {
33
- source = "git::https://github.com/uktrade/terraform-platform-modules.git//extensions?depth=1&ref={{terraform_platform_modules_version}}"
34
-
35
- args = local.args
36
- environment = "{{ environment }}"
37
- }
38
-
39
- /*
40
- Clean up because terraform modules were initially deployed with a -tf suffix. This block moves those modules to naming without a suffix.
41
- Can be removed once all services have moved to the new naming.
42
- */
43
- moved {
44
- from = module.extensions-tf
45
- to = module.extensions
46
- }
@@ -1,20 +0,0 @@
1
- from pathlib import Path
2
-
3
- import yaml
4
-
5
- from dbt_platform_helper.constants import PLATFORM_CONFIG_FILE
6
-
7
-
8
- def _read_config_file_contents():
9
- if Path(PLATFORM_CONFIG_FILE).exists():
10
- return Path(PLATFORM_CONFIG_FILE).read_text()
11
-
12
-
13
- def load_unvalidated_config_file():
14
- file_contents = _read_config_file_contents()
15
- if not file_contents:
16
- return {}
17
- try:
18
- return yaml.safe_load(file_contents)
19
- except yaml.parser.ParserError:
20
- return {}