dbt-platform-helper 15.9.0__py3-none-any.whl → 15.10.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.

@@ -22,6 +22,8 @@
22
22
  - [platform-helper environment generate](#platform-helper-environment-generate)
23
23
  - [platform-helper environment generate-terraform](#platform-helper-environment-generate-terraform)
24
24
  - [platform-helper generate](#platform-helper-generate)
25
+ - [platform-helper internal](#platform-helper-internal)
26
+ - [platform-helper internal migrate-service-manifests](#platform-helper-internal-migrate-service-manifests)
25
27
  - [platform-helper pipeline](#platform-helper-pipeline)
26
28
  - [platform-helper pipeline generate](#platform-helper-pipeline-generate)
27
29
  - [platform-helper secrets](#platform-helper-secrets)
@@ -65,6 +67,7 @@ platform-helper <command> [--version]
65
67
  - [`database` ↪](#platform-helper-database)
66
68
  - [`environment` ↪](#platform-helper-environment)
67
69
  - [`generate` ↪](#platform-helper-generate)
70
+ - [`internal` ↪](#platform-helper-internal)
68
71
  - [`notify` ↪](#platform-helper-notify)
69
72
  - [`pipeline` ↪](#platform-helper-pipeline)
70
73
  - [`secrets` ↪](#platform-helper-secrets)
@@ -539,6 +542,44 @@ platform-helper generate
539
542
 
540
543
  ## Options
541
544
 
545
+ - `--help <boolean>` _Defaults to False._
546
+ - Show this message and exit.
547
+
548
+ # platform-helper internal
549
+
550
+ [↩ Parent](#platform-helper)
551
+
552
+ Internal commands for use within pipelines or by Platform Team.
553
+
554
+ ## Usage
555
+
556
+ ```
557
+ platform-helper internal migrate-service-manifests
558
+ ```
559
+
560
+ ## Options
561
+
562
+ - `--help <boolean>` _Defaults to False._
563
+ - Show this message and exit.
564
+
565
+ ## Commands
566
+
567
+ - [`migrate-service-manifests` ↪](#platform-helper-internal-migrate-service-manifests)
568
+
569
+ # platform-helper internal migrate-service-manifests
570
+
571
+ [↩ Parent](#platform-helper-internal)
572
+
573
+ Migrate copilot manifests to service manifests.
574
+
575
+ ## Usage
576
+
577
+ ```
578
+ platform-helper internal migrate-service-manifests
579
+ ```
580
+
581
+ ## Options
582
+
542
583
  - `--help <boolean>` _Defaults to False._
543
584
  - Show this message and exit.
544
585
 
@@ -0,0 +1,23 @@
1
+ import click
2
+
3
+ from dbt_platform_helper.domain.service import ServiceManager
4
+ from dbt_platform_helper.platform_exception import PlatformException
5
+ from dbt_platform_helper.providers.io import ClickIOProvider
6
+ from dbt_platform_helper.utils.click import ClickDocOptGroup
7
+
8
+
9
+ @click.group(cls=ClickDocOptGroup)
10
+ def internal():
11
+ """Internal commands for use within pipelines or by Platform Team."""
12
+
13
+
14
+ @internal.command()
15
+ def migrate_service_manifests():
16
+ """Migrate copilot manifests to service manifests."""
17
+ click_io = ClickIOProvider()
18
+
19
+ try:
20
+ service_manager = ServiceManager()
21
+ service_manager.migrate_copilot_manifests()
22
+ except PlatformException as error:
23
+ click_io.abort_with_error(str(error))
@@ -1,8 +1,12 @@
1
+ import os
2
+ from collections import OrderedDict
3
+ from copy import deepcopy
1
4
  from datetime import datetime
2
5
  from importlib.metadata import version
3
6
  from pathlib import Path
4
7
 
5
8
  from dbt_platform_helper.constants import IMAGE_TAG_ENV_VAR
9
+ from dbt_platform_helper.constants import PLATFORM_HELPER_PACKAGE_NAME
6
10
  from dbt_platform_helper.constants import PLATFORM_HELPER_VERSION_OVERRIDE_KEY
7
11
  from dbt_platform_helper.constants import SERVICE_CONFIG_FILE
8
12
  from dbt_platform_helper.constants import SERVICE_DIRECTORY
@@ -21,15 +25,18 @@ from dbt_platform_helper.providers.config_validator import ConfigValidator
21
25
  from dbt_platform_helper.providers.environment_variable import (
22
26
  EnvironmentVariableProvider,
23
27
  )
28
+ from dbt_platform_helper.providers.files import FileProvider
24
29
  from dbt_platform_helper.providers.io import ClickIOProvider
25
30
  from dbt_platform_helper.providers.terraform_manifest import TerraformManifestProvider
31
+ from dbt_platform_helper.providers.version import InstalledVersionProvider
26
32
  from dbt_platform_helper.providers.yaml_file import YamlFileProvider
27
33
  from dbt_platform_helper.utils.application import load_application
28
34
  from dbt_platform_helper.utils.deep_merge import deep_merge
29
35
 
30
- # TODO add schema version too service config
36
+ SERVICE_TYPES = ["Load Balanced Web Service", "Backend Service"]
31
37
 
32
38
 
39
+ # TODO add schema version to service config
33
40
  class ServiceManager:
34
41
  def __init__(
35
42
  self,
@@ -41,6 +48,7 @@ class ServiceManager:
41
48
  manifest_provider: TerraformManifestProvider = None,
42
49
  platform_helper_version_override: str = None,
43
50
  load_application=load_application,
51
+ installed_version_provider: InstalledVersionProvider = InstalledVersionProvider(),
44
52
  ):
45
53
 
46
54
  self.file_provider = file_provider
@@ -56,6 +64,7 @@ class ServiceManager:
56
64
  or self.environment_variable_provider.get(PLATFORM_HELPER_VERSION_OVERRIDE_KEY)
57
65
  )
58
66
  self.load_application = load_application
67
+ self.installed_version_provider = installed_version_provider
59
68
 
60
69
  def generate(self, environments: list[str], services: list[str], image_tag_flag: str = None):
61
70
 
@@ -151,3 +160,54 @@ class ServiceManager:
151
160
  config,
152
161
  module_source_override,
153
162
  )
163
+
164
+ def migrate_copilot_manifests(self) -> None:
165
+ service_directory = Path("services/")
166
+ service_directory.mkdir(parents=True, exist_ok=True)
167
+
168
+ for dirname, _, filenames in os.walk("copilot"):
169
+ if "manifest.yml" in filenames and "environments" not in dirname:
170
+ copilot_manifest = self.file_provider.load(f"{dirname}/manifest.yml")
171
+ service_manifest = OrderedDict(deepcopy(copilot_manifest))
172
+
173
+ if service_manifest["type"] not in SERVICE_TYPES:
174
+ continue
175
+
176
+ if "environments" in service_manifest:
177
+ for env in service_manifest["environments"]:
178
+ env_config = service_manifest["environments"][env]
179
+ if "http" in env_config:
180
+ if "alb" in env_config["http"]:
181
+ del env_config["http"]["alb"]
182
+
183
+ service_manifest = self.file_provider.find_and_replace(
184
+ service_manifest,
185
+ "${COPILOT_APPLICATION_NAME}",
186
+ "${PLATFORM_APPLICATION_NAME}",
187
+ )
188
+
189
+ service_manifest = self.file_provider.find_and_replace(
190
+ service_manifest,
191
+ "${COPILOT_ENVIRONMENT_NAME}",
192
+ "${PLATFORM_ENVIRONMENT_NAME}",
193
+ )
194
+
195
+ service_manifest = self.file_provider.remove_empty_keys(service_manifest)
196
+
197
+ service_path = service_directory / service_manifest["name"]
198
+
199
+ self.io.info(
200
+ FileProvider.mkfile(
201
+ service_path,
202
+ "service-config.yml",
203
+ "",
204
+ overwrite=True,
205
+ )
206
+ )
207
+
208
+ current_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
209
+ message = f"# Generated by platform-helper {self.installed_version_provider.get_semantic_version(PLATFORM_HELPER_PACKAGE_NAME)} / {current_date}.\n\n"
210
+
211
+ self.file_provider.write(
212
+ f"{service_path}/service-config.yml", dict(service_manifest), message
213
+ )
@@ -114,7 +114,6 @@ class PlatformConfigSchema:
114
114
  Optional("default_waf"): str,
115
115
  Optional("domain_prefix"): str,
116
116
  Optional("enable_logging"): bool,
117
- Optional("env_root"): str,
118
117
  Optional("forwarded_values_forward"): str,
119
118
  Optional("forwarded_values_headers"): [str],
120
119
  Optional("forwarded_values_query_string"): bool,
@@ -293,6 +292,7 @@ class PlatformConfigSchema:
293
292
  @staticmethod
294
293
  def __postgres_schema() -> dict:
295
294
  _valid_postgres_plans = Or(*plan_manager.get_plan_names("postgres"))
295
+ _valid_postgres_version = Or(int, float)
296
296
 
297
297
  # TODO: DBTP-1943: Move to Postgres provider?
298
298
  _valid_postgres_storage_types = Or("gp2", "gp3", "io1", "io2")
@@ -305,11 +305,13 @@ class PlatformConfigSchema:
305
305
 
306
306
  return {
307
307
  "type": "postgres",
308
- "version": (Or(int, float)),
308
+ Optional("version"): _valid_postgres_version,
309
309
  Optional("deletion_policy"): PlatformConfigSchema.__valid_postgres_deletion_policy(),
310
310
  Optional("environments"): {
311
311
  PlatformConfigSchema.__valid_environment_name(): {
312
+ Optional("apply_immediately"): bool,
312
313
  Optional("plan"): _valid_postgres_plans,
314
+ Optional("version"): (Or(int, float)),
313
315
  Optional("volume_size"): PlatformConfigSchema.is_integer_between(20, 10000),
314
316
  Optional("iops"): PlatformConfigSchema.is_integer_between(1000, 9950),
315
317
  Optional("snapshot_id"): str,
@@ -1,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: dbt-platform-helper
3
- Version: 15.9.0
3
+ Version: 15.10.0
4
4
  Summary: Set of tools to help transfer applications/services from GOV.UK PaaS to DBT PaaS augmenting AWS Copilot.
5
5
  License: MIT
6
+ License-File: LICENSE
6
7
  Author: Department for Business and Trade Platform Team
7
8
  Author-email: sre-team@digital.trade.gov.uk
8
9
  Requires-Python: >3.9.1,<4.0
@@ -12,12 +13,13 @@ Classifier: Programming Language :: Python :: 3.10
12
13
  Classifier: Programming Language :: Python :: 3.11
13
14
  Classifier: Programming Language :: Python :: 3.12
14
15
  Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
15
17
  Requires-Dist: Jinja2 (==3.1.6)
16
18
  Requires-Dist: boto3 (>=1.35.2,<2.0.0)
17
19
  Requires-Dist: botocore (>=1.34.85,<2.0.0)
18
20
  Requires-Dist: cfn-flip (>=1.3.0,<2.0.0)
19
21
  Requires-Dist: click (>=8.1.3,<9.0.0)
20
- Requires-Dist: jinja2-simple-tags (>=0.5.0,<0.6.0)
22
+ Requires-Dist: jinja2-simple-tags (>=0.5,<0.7)
21
23
  Requires-Dist: prettytable (>=3.9.0,<4.0.0)
22
24
  Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0)
23
25
  Requires-Dist: pydantic (>=2.11.7,<3.0.0)
@@ -1,4 +1,4 @@
1
- dbt_platform_helper/COMMANDS.md,sha256=eR_fK_iMO59_PjGWZIv3MDD61zG5Hlp9hbHeoXaHwyY,25096
1
+ dbt_platform_helper/COMMANDS.md,sha256=LPF1aREzwiYsoCnWRyglezdvRfJfMy3M7IIzOkO9trI,26014
2
2
  dbt_platform_helper/README.md,sha256=B0qN2_u_ASqqgkGDWY2iwNGZt_9tUgMb9XqtaTuzYjw,1530
3
3
  dbt_platform_helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  dbt_platform_helper/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -10,6 +10,7 @@ dbt_platform_helper/commands/copilot.py,sha256=L9UUuqD62q0aFrTTEUla3A1WJBz-vFBfV
10
10
  dbt_platform_helper/commands/database.py,sha256=2RJZEzaSqcNtDG1M2mZw-nB6agAd3GNAJsg2pjFF7vc,4407
11
11
  dbt_platform_helper/commands/environment.py,sha256=zexiry6_dbOmD8w2lBrgdcFQKAG7XyJg9pvNtwtgPRk,3616
12
12
  dbt_platform_helper/commands/generate.py,sha256=4M0ZiGN2w-bwgPMxeItFfT6vA7sOMjuceHEN7RAYkhc,735
13
+ dbt_platform_helper/commands/internal.py,sha256=IzPEyie6lmiNATQ3sYDvDgvqJz__Eaz-3VzUaUtzmNQ,730
13
14
  dbt_platform_helper/commands/notify.py,sha256=DMXA0AHot6-7CMzmY0PXPMMBVnLgvQgXr6np6OnSQh4,3401
14
15
  dbt_platform_helper/commands/pipeline.py,sha256=PGpDDmyReVa4gdpXDwJEsHN51f5MgTIbm2AibTkuWrE,2580
15
16
  dbt_platform_helper/commands/secrets.py,sha256=AMwLCi7uxuMMfhDfGD8OcuIYMzU8q2VQXWxaiuztvzA,3296
@@ -28,10 +29,10 @@ dbt_platform_helper/domain/maintenance_page.py,sha256=pTY_GXAMzqowdLCXM7BmsbsUeZ
28
29
  dbt_platform_helper/domain/notify.py,sha256=_BWj5znDWtrSdJ5xzDBgnao4ukliBA5wiUZGobIDyiI,1894
29
30
  dbt_platform_helper/domain/pipelines.py,sha256=NrH9dl5Pzdds9TdWJmPZmgyBhHfcaN6byouBWI0W67s,8565
30
31
  dbt_platform_helper/domain/plans.py,sha256=X5-jKGiJDVWn0CRH1k5aV74fTH0E41HqFQcCo5kB4hI,1160
31
- dbt_platform_helper/domain/service.py,sha256=b1wtvINDhyMmauTb4Ed2wyyGQXsKPfB-SIcewjXiCwA,6771
32
+ dbt_platform_helper/domain/service.py,sha256=ByEXzGw_yr80b4FoI_TJEssB2oWcx_DAGFqOObD5mu4,9482
32
33
  dbt_platform_helper/domain/terraform_environment.py,sha256=g9PSuZeVXgboGNDXU7OGMiRATd67NU8S92HUGri1fbo,2471
33
34
  dbt_platform_helper/domain/versioning.py,sha256=pIL8VPAJHqX5kJBp3QIxII5vmUo4aIYW_U9u_KxUJd0,5494
34
- dbt_platform_helper/entities/platform_config_schema.py,sha256=IUwjxQ19SotiAHLe5K9lpftaw4tJmMk-U6PQbe-HzEU,27551
35
+ dbt_platform_helper/entities/platform_config_schema.py,sha256=8j6OK_YpU_oXY9pJg4A1TjHvSX-T8rzSfHTHbvvSnis,27682
35
36
  dbt_platform_helper/entities/semantic_version.py,sha256=VgQ6V6OgSaleuVmMB8Kl_yLoakXl2auapJTDbK00mfc,2679
36
37
  dbt_platform_helper/entities/service.py,sha256=GExA0gOiKIcY3WX4vx_j9VSv6BAeRm9-tIUbs7YkyFI,4169
37
38
  dbt_platform_helper/jinja2_tags.py,sha256=hKG6RS3zlxJHQ-Op9r2U2-MhWp4s3lZir4Ihe24ApJ0,540
@@ -102,12 +103,12 @@ dbt_platform_helper/utils/git.py,sha256=9jyLhv37KKE6r-_hb3zvjhTbluA81kdrOdNeG6MB
102
103
  dbt_platform_helper/utils/messages.py,sha256=nWA7BWLb7ND0WH5TejDN4OQUJSKYBxU4tyCzteCrfT0,142
103
104
  dbt_platform_helper/utils/template.py,sha256=g-Db-0I6a6diOHkgK1nYA0IxJSO4TRrjqOvlyeOR32o,950
104
105
  dbt_platform_helper/utils/validation.py,sha256=W5jKC2zp5Q7cJ0PT57GB-s9FkJXrNt1jmWojXRFymcY,1187
105
- platform_helper.py,sha256=LP9o5_1H9-FKbBa85FqW07QFPn6STg6D4gM2-QHaaD4,2048
106
+ platform_helper.py,sha256=APhyqhU6PYsuocg0fzPAwbUnqUxmoikYAlUIJSHsAnI,2175
106
107
  terraform/elasticache-redis/plans.yml,sha256=efJfkLuLC_5TwhLb9DalKHOuZFO79y6iei6Dg_tqKjI,1831
107
108
  terraform/opensearch/plans.yml,sha256=lQbUSNMGfvUeDMcGx8mSwzGQhMJU3EZ4J4tPzPKaq6c,1471
108
109
  terraform/postgres/plans.yml,sha256=plwCklW1VB_tNJFyUduRMZx9UANgiWH_7TGLWUaUEus,2553
109
- dbt_platform_helper-15.9.0.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
110
- dbt_platform_helper-15.9.0.dist-info/METADATA,sha256=nM4pw5jMBBu4AIRNHM_QXTqBJJupwtz8P6MlzWE9p3w,2732
111
- dbt_platform_helper-15.9.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
112
- dbt_platform_helper-15.9.0.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
113
- dbt_platform_helper-15.9.0.dist-info/RECORD,,
110
+ dbt_platform_helper-15.10.0.dist-info/METADATA,sha256=pf68aOIRfj_5MxXS2W9aTBmNwrJKhaVUbd6BgJA4LWU,2802
111
+ dbt_platform_helper-15.10.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
112
+ dbt_platform_helper-15.10.0.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
113
+ dbt_platform_helper-15.10.0.dist-info/licenses/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
114
+ dbt_platform_helper-15.10.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
platform_helper.py CHANGED
@@ -12,6 +12,7 @@ from dbt_platform_helper.commands.copilot import copilot as copilot_commands
12
12
  from dbt_platform_helper.commands.database import database as database_commands
13
13
  from dbt_platform_helper.commands.environment import environment as environment_commands
14
14
  from dbt_platform_helper.commands.generate import generate as generate_commands
15
+ from dbt_platform_helper.commands.internal import internal as internal_commands
15
16
  from dbt_platform_helper.commands.notify import notify as notify_commands
16
17
  from dbt_platform_helper.commands.pipeline import pipeline as pipeline_commands
17
18
  from dbt_platform_helper.commands.secrets import secrets as secrets_commands
@@ -36,6 +37,7 @@ platform_helper.add_command(config_commands)
36
37
  platform_helper.add_command(copilot_commands)
37
38
  platform_helper.add_command(environment_commands)
38
39
  platform_helper.add_command(generate_commands)
40
+ platform_helper.add_command(internal_commands)
39
41
  platform_helper.add_command(pipeline_commands)
40
42
  platform_helper.add_command(secrets_commands)
41
43
  platform_helper.add_command(service_commands)