dbt-platform-helper 13.1.2__py3-none-any.whl → 13.3.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 (57) hide show
  1. dbt_platform_helper/commands/application.py +2 -4
  2. dbt_platform_helper/commands/codebase.py +11 -7
  3. dbt_platform_helper/commands/conduit.py +1 -3
  4. dbt_platform_helper/commands/config.py +12 -314
  5. dbt_platform_helper/commands/copilot.py +14 -8
  6. dbt_platform_helper/commands/database.py +17 -9
  7. dbt_platform_helper/commands/environment.py +5 -6
  8. dbt_platform_helper/commands/generate.py +2 -3
  9. dbt_platform_helper/commands/notify.py +1 -3
  10. dbt_platform_helper/commands/pipeline.py +1 -3
  11. dbt_platform_helper/commands/secrets.py +1 -3
  12. dbt_platform_helper/commands/version.py +2 -2
  13. dbt_platform_helper/domain/codebase.py +17 -9
  14. dbt_platform_helper/domain/config.py +345 -0
  15. dbt_platform_helper/domain/copilot.py +158 -157
  16. dbt_platform_helper/domain/maintenance_page.py +42 -15
  17. dbt_platform_helper/domain/pipelines.py +1 -1
  18. dbt_platform_helper/domain/terraform_environment.py +1 -1
  19. dbt_platform_helper/domain/versioning.py +161 -30
  20. dbt_platform_helper/providers/aws/__init__.py +0 -0
  21. dbt_platform_helper/providers/{aws.py → aws/exceptions.py} +10 -0
  22. dbt_platform_helper/providers/aws/interfaces.py +13 -0
  23. dbt_platform_helper/providers/aws/opensearch.py +23 -0
  24. dbt_platform_helper/providers/aws/redis.py +21 -0
  25. dbt_platform_helper/providers/aws/sso_auth.py +61 -0
  26. dbt_platform_helper/providers/cache.py +40 -4
  27. dbt_platform_helper/providers/config.py +2 -1
  28. dbt_platform_helper/providers/config_validator.py +28 -25
  29. dbt_platform_helper/providers/copilot.py +1 -1
  30. dbt_platform_helper/providers/io.py +5 -2
  31. dbt_platform_helper/providers/kms.py +22 -0
  32. dbt_platform_helper/providers/load_balancers.py +26 -15
  33. dbt_platform_helper/providers/parameter_store.py +47 -0
  34. dbt_platform_helper/providers/platform_config_schema.py +17 -0
  35. dbt_platform_helper/providers/semantic_version.py +18 -88
  36. dbt_platform_helper/providers/terraform_manifest.py +1 -0
  37. dbt_platform_helper/providers/version.py +102 -26
  38. dbt_platform_helper/providers/version_status.py +80 -0
  39. dbt_platform_helper/providers/yaml_file.py +0 -1
  40. dbt_platform_helper/utils/aws.py +24 -142
  41. dbt_platform_helper/utils/git.py +3 -1
  42. dbt_platform_helper/utils/tool_versioning.py +12 -0
  43. {dbt_platform_helper-13.1.2.dist-info → dbt_platform_helper-13.3.0.dist-info}/METADATA +2 -2
  44. {dbt_platform_helper-13.1.2.dist-info → dbt_platform_helper-13.3.0.dist-info}/RECORD +48 -47
  45. {dbt_platform_helper-13.1.2.dist-info → dbt_platform_helper-13.3.0.dist-info}/WHEEL +1 -1
  46. platform_helper.py +1 -1
  47. dbt_platform_helper/providers/opensearch.py +0 -36
  48. dbt_platform_helper/providers/platform_helper_versioning.py +0 -107
  49. dbt_platform_helper/providers/redis.py +0 -34
  50. dbt_platform_helper/templates/svc/manifest-backend.yml +0 -69
  51. dbt_platform_helper/templates/svc/manifest-public.yml +0 -109
  52. dbt_platform_helper/utils/cloudfoundry.py +0 -14
  53. dbt_platform_helper/utils/files.py +0 -59
  54. dbt_platform_helper/utils/manifests.py +0 -18
  55. dbt_platform_helper/utils/versioning.py +0 -91
  56. {dbt_platform_helper-13.1.2.dist-info → dbt_platform_helper-13.3.0.dist-info}/LICENSE +0 -0
  57. {dbt_platform_helper-13.1.2.dist-info → dbt_platform_helper-13.3.0.dist-info}/entry_points.txt +0 -0
@@ -1,109 +0,0 @@
1
- # {% version_info %}
2
- # The manifest for the "{{ name }}" service.
3
- # Read the full specification for the "Load Balanced Web Service" type at:
4
- # https://aws.github.io/copilot-cli/docs/manifest/lb-web-service/
5
-
6
- # Your service name will be used in naming your resources like log groups, ECS services, etc.
7
- name: {{ name }}
8
- type: Load Balanced Web Service
9
-
10
- # Distribute traffic to your service.
11
- http:
12
- # Requests to this path will be forwarded to your service.
13
- # To match all requests you can use the "/" path.
14
- path: '/'
15
- # You can specify a custom health check path. The default is "/".
16
- # healthcheck: '/'
17
- target_container: nginx
18
- healthcheck:
19
- path: '/'
20
- port: 8080
21
- success_codes: '200,301,302'
22
- healthy_threshold: 3
23
- unhealthy_threshold: 2
24
- grace_period: 180s
25
-
26
- sidecars:
27
- nginx:
28
- port: 443
29
- image: public.ecr.aws/uktrade/nginx-dbt-platform:latest
30
- variables:
31
- SERVER: localhost:8000
32
-
33
- ipfilter:
34
- port: 8000
35
- image: public.ecr.aws/uktrade/ip-filter:latest
36
- variables:
37
- PORT: 8000
38
- SERVER: localhost:8080
39
- APPCONFIG_PROFILES: ipfilter:default:default
40
- IPFILTER_ENABLED: {{ ipfilter }}
41
- EMAIL: sre@digital.trade.gov.uk
42
- ADDITIONAL_IP_LIST: /${AWS_PROFILE}/EGRESS_IPS
43
-
44
- appconfig:
45
- port: 2772
46
- image: public.ecr.aws/aws-appconfig/aws-appconfig-agent:2.x
47
- essential: true
48
- variables:
49
- ROLE_ARN: arn:aws:iam::763451185160:role/AppConfigIpFilterRole
50
-
51
- # Configuration for your containers and service.
52
- image:
53
- location: {{ image_location }}
54
- # Port exposed through your container to route traffic to it.
55
- port: 8080
56
-
57
- cpu: 256 # Number of CPU units for the task.
58
- memory: 512 # Amount of memory in MiB used by the task.
59
- count: # See https://aws.github.io/copilot-cli/docs/manifest/lb-web-service/#count
60
- range: 2-10
61
- cooldown:
62
- in: 120s
63
- out: 60s
64
- cpu_percentage: 50
65
- exec: true # Enable running commands in your container.
66
- network:
67
- connect: true # Enable Service Connect for intra-environment traffic between services.
68
- vpc:
69
- placement: 'private'
70
-
71
- # The application currently may not work if the file system is readonly, e.g...
72
- # FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/workspace']
73
- # ...so you may need to comment out the two lines below...
74
- storage:
75
- readonly_fs: true # Limit to read-only access to mounted root filesystems.
76
-
77
- # Optional fields for more advanced use-cases.
78
- #
79
- variables: # Pass environment variables as key value pairs.
80
- PORT: 8080
81
- {%- for envvar, value in env_vars.items() %}
82
- {{ envvar }}: {{ value }}
83
- {%- endfor %}
84
-
85
- {% if secrets %}
86
- secrets: # Pass secrets from AWS Systems Manager (SSM) Parameter Store.
87
- {%- for secret, value in secrets.items() %}
88
- {{ secret }}: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/{{ value }}{% endfor -%}
89
- {% else %}
90
- # secrets: # Pass secrets from AWS Systems Manager (SSM) Parameter Store.
91
- {% endif %}
92
-
93
-
94
- # You can override any of the values defined above by environment.
95
- environments:
96
- {%- for env_name, env in environments.items() %}
97
- {{ env_name }}:
98
- http:
99
- alias: {{ env.url }}
100
- {%- if env.memory %}
101
- memory: {{ env.memory }}
102
- {%- endif %}
103
- {%- if env.count and env.count is mapping %}
104
- count: # For options see https://aws.github.io/copilot-cli/docs/manifest/lb-web-service/#count
105
- {{ env.count | to_yaml | indent(6) | trim }}
106
- {%- elif env.count %}
107
- count: {{ env.count }} # For options see https://aws.github.io/copilot-cli/docs/manifest/lb-web-service/#count
108
- {%- endif %}
109
- {%- endfor %}
@@ -1,14 +0,0 @@
1
- import click
2
- from cloudfoundry_client.client import CloudFoundryClient
3
-
4
-
5
- def get_cloud_foundry_client_or_abort():
6
- try:
7
- client = CloudFoundryClient.build_from_cf_config()
8
- click.secho("Logged in to Cloud Foundry", fg="green")
9
- return client
10
- except Exception as ex:
11
- click.secho("Could not connect to Cloud Foundry: ", fg="red", nl=False)
12
- click.secho(str(ex))
13
- click.secho("Please log in with: cf login", fg="yellow")
14
- exit(1)
@@ -1,59 +0,0 @@
1
- import click
2
- import yaml
3
- from jinja2 import Environment
4
- from jinja2 import FileSystemLoader
5
-
6
- from dbt_platform_helper.providers.files import FileProvider
7
-
8
-
9
- def to_yaml(value):
10
- return yaml.dump(value, sort_keys=False)
11
-
12
-
13
- # TODO - extract file provider functionality from this - and figure out what it actually does!
14
- # Move to the new file provider - or potentially copilot?
15
- def generate_override_files(base_path, file_path, output_dir):
16
- def generate_files_for_dir(pattern):
17
- for file in file_path.glob(pattern):
18
- if file.is_file():
19
- contents = file.read_text()
20
- file_name = str(file).removeprefix(f"{file_path}/")
21
- click.echo(
22
- FileProvider.mkfile(
23
- base_path,
24
- output_dir / file_name,
25
- contents,
26
- overwrite=True,
27
- )
28
- )
29
-
30
- generate_files_for_dir("*")
31
- generate_files_for_dir("bin/*")
32
-
33
-
34
- def generate_override_files_from_template(base_path, overrides_path, output_dir, template_data={}):
35
- templates = Environment(
36
- loader=FileSystemLoader(f"{overrides_path}"), keep_trailing_newline=True
37
- )
38
- environments = ",".join([env["name"] for env in template_data["environments"]])
39
- data = {"environments": environments}
40
-
41
- def generate_files_for_dir(pattern):
42
-
43
- for file in overrides_path.glob(pattern):
44
- if file.is_file():
45
- file_name = str(file).removeprefix(f"{overrides_path}/")
46
- contents = templates.get_template(str(file_name)).render(data)
47
- message = FileProvider.mkfile(
48
- base_path, output_dir / file_name, contents, overwrite=True
49
- )
50
- click.echo(message)
51
-
52
- generate_files_for_dir("*")
53
- generate_files_for_dir("bin/*")
54
-
55
-
56
- # TODO: we've moved this from versioning utils and removed the duplication in platform_helper_versioning
57
- # Need to review if this is the correct place for this function to reside longer-term
58
- def running_as_installed_package():
59
- return "site-packages" in __file__
@@ -1,18 +0,0 @@
1
- import yaml
2
-
3
-
4
- def get_service_name_from_manifest(manifest_path):
5
- with open(manifest_path) as manifest:
6
- document = yaml.safe_load(manifest)
7
- return document["name"]
8
-
9
-
10
- def get_repository_name_from_manifest(manifest_path):
11
- with open(manifest_path) as manifest:
12
- document = yaml.safe_load(manifest)
13
- image = document["image"]["location"]
14
-
15
- repository_with_tag = image.split("/", 1)[1]
16
- repository = repository_with_tag.split(":")[0]
17
-
18
- return repository
@@ -1,91 +0,0 @@
1
- import re
2
- import subprocess
3
- from pathlib import Path
4
-
5
- from dbt_platform_helper.constants import DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION
6
- from dbt_platform_helper.providers.platform_helper_versioning import (
7
- PlatformHelperVersioning,
8
- )
9
- from dbt_platform_helper.providers.semantic_version import PlatformHelperVersionStatus
10
- from dbt_platform_helper.providers.semantic_version import SemanticVersion
11
- from dbt_platform_helper.providers.semantic_version import VersionStatus
12
- from dbt_platform_helper.providers.validation import ValidationException
13
- from dbt_platform_helper.providers.version import GithubVersionProvider
14
- from dbt_platform_helper.providers.yaml_file import YamlFileProvider
15
-
16
-
17
- # TODO to be removed after config tests are updated - temporary wrapper mid-refactor
18
- def get_platform_helper_version_status(
19
- include_project_versions=True,
20
- yaml_provider=YamlFileProvider,
21
- ) -> PlatformHelperVersionStatus:
22
- return PlatformHelperVersioning(file_provider=yaml_provider).get_status(
23
- include_project_versions=include_project_versions
24
- )
25
-
26
-
27
- def get_required_terraform_platform_modules_version(
28
- cli_terraform_platform_modules_version, platform_config_terraform_modules_default_version
29
- ):
30
- version_preference_order = [
31
- cli_terraform_platform_modules_version,
32
- platform_config_terraform_modules_default_version,
33
- DEFAULT_TERRAFORM_PLATFORM_MODULES_VERSION,
34
- ]
35
- return [version for version in version_preference_order if version][0]
36
-
37
-
38
- ##################################################################################
39
- # Only used in Config domain
40
- # TODO Relocate along with tests when we refactor config command in DBTP-1538
41
- ##################################################################################
42
-
43
-
44
- # Getting version from the "Generated by" comment in a file that was generated from a template
45
- # TODO where does this belong? It sort of belongs to our platform-helper templating
46
- def get_template_generated_with_version(template_file_path: str) -> SemanticVersion:
47
- try:
48
- template_contents = Path(template_file_path).read_text()
49
- template_version = re.match(
50
- r"# Generated by platform-helper ([v.\-0-9]+)", template_contents
51
- ).group(1)
52
- return SemanticVersion.from_string(template_version)
53
- except (IndexError, AttributeError):
54
- raise ValidationException(f"Template {template_file_path} has no version information")
55
-
56
-
57
- def validate_template_version(app_version: SemanticVersion, template_file_path: str):
58
- app_version.validate_compatibility_with(get_template_generated_with_version(template_file_path))
59
-
60
-
61
- # Local version and latest release of tool.
62
- # Used only in config command.
63
- # TODO Move to config domain
64
- def get_copilot_versions() -> VersionStatus:
65
- copilot_version = None
66
-
67
- try:
68
- response = subprocess.run("copilot --version", capture_output=True, shell=True)
69
- [copilot_version] = re.findall(r"[0-9.]+", response.stdout.decode("utf8"))
70
- except ValueError:
71
- pass
72
-
73
- return VersionStatus(
74
- SemanticVersion.from_string(copilot_version),
75
- GithubVersionProvider.get_latest_version("aws/copilot-cli"),
76
- )
77
-
78
-
79
- # Local version and latest release of tool.
80
- # Used only in config command.
81
- # TODO Move to config domain
82
- def get_aws_versions() -> VersionStatus:
83
- aws_version = None
84
- try:
85
- response = subprocess.run("aws --version", capture_output=True, shell=True)
86
- matched = re.match(r"aws-cli/([0-9.]+)", response.stdout.decode("utf8"))
87
- aws_version = SemanticVersion.from_string(matched.group(1))
88
- except ValueError:
89
- pass
90
-
91
- return VersionStatus(aws_version, GithubVersionProvider.get_latest_version("aws/aws-cli", True))