Skip to content

Commit bd72234

Browse files
authored
Release 1.0 (#741)
1 parent 387fcd6 commit bd72234

108 files changed

Lines changed: 2283 additions & 3159 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cicd/buildspec_pr.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
version: 0.2
22

33
env:
4-
variables:
5-
PY_VERSION: 3.8
64
git-credential-helper: yes
75

86
phases:
97
install:
108
runtime-versions:
11-
python: "$(echo $PY_VERSION)"
9+
python: 3.10
1210
commands:
1311
- (pip --version && pip install pip -U)|| curl -s https://bootstrap.pypa.io/get-pip.py | python
1412
- python -m pip install poetry

.cicd/codebuild_pr.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Metadata:
66
Author: https://github.com/johnpreston
77

88
Parameters:
9+
CodeBuildImage:
10+
Type: String
11+
Default: aws/codebuild/standard:6.0
912
RepositoryOrganization:
1013
Type: String
1114

@@ -128,12 +131,10 @@ Resources:
128131
Type: NO_ARTIFACTS
129132
Environment:
130133
ComputeType: BUILD_GENERAL1_SMALL
131-
Image: aws/codebuild/standard:3.0
134+
Image:
135+
Ref: CodeBuildImage
132136
Type: LINUX_CONTAINER
133137
EnvironmentVariables:
134-
- Name: PY_VERSION
135-
Type: PLAINTEXT
136-
Value: 3.8
137138
- Name: KNOWN_BUCKET
138139
Type: PLAINTEXT
139140
Value: !Ref TemplatesBucket

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: pre-commit
22

33
on:
44
pull_request:
5-
push:
6-
branches: [main]
75

86
jobs:
97
pre-commit:

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ repos:
1919
- id: fix-byte-order-marker
2020

2121
- repo: https://github.com/asottile/pyupgrade
22-
rev: v3.15.0
22+
rev: v3.15.1
2323
hooks:
2424
- id: pyupgrade
2525
exclude: ^tests/
2626
args: [ "--py39-plus", "--keep-runtime-typing" ]
2727

2828
- repo: https://github.com/psf/black
29-
rev: 23.11.0
29+
rev: 24.2.0
3030
hooks:
3131
- id: black
3232

@@ -37,7 +37,7 @@ repos:
3737
additional_dependencies: [ black ]
3838

3939
- repo: https://github.com/pycqa/isort
40-
rev: 5.12.0
40+
rev: 5.13.2
4141
hooks:
4242
- id: isort
4343
args: [ "--profile", "black", "--filter-files" ]

AUTHORS.rst

Lines changed: 0 additions & 11 deletions
This file was deleted.

ecs_composex/appmesh/appmesh_mesh.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,11 @@ def define_nodes(self, settings: ComposeXSettings) -> None:
173173
node["Port"],
174174
self,
175175
settings,
176-
node[appmesh_params.BACKENDS_KEY]
177-
if keyisset(appmesh_params.BACKENDS_KEY, node)
178-
else None,
176+
(
177+
node[appmesh_params.BACKENDS_KEY]
178+
if keyisset(appmesh_params.BACKENDS_KEY, node)
179+
else None
180+
),
179181
)
180182
self.nodes[family.logical_name] = mesh_node
181183
self.nodes[family.logical_name].get_node_param = GetAtt(

ecs_composex/appmesh/appmesh_router.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,21 @@
3838
def define_http_route(route_match, route_nodes, http2: bool):
3939
route = appmesh.HttpRoute(
4040
Match=appmesh.HttpRouteMatch(
41-
Prefix=route_match[PREFIX_KEY]
42-
if keyisset(PREFIX_KEY, route_match)
43-
else Ref(AWS_NO_VALUE),
44-
Scheme=route_match[SCHEME_KEY].lower()
45-
if keyisset(SCHEME_KEY, route_match) and http2
46-
else Ref(AWS_NO_VALUE),
47-
Method=route_match[METHOD_KEY].upper()
48-
if keyisset(METHOD_KEY, route_match)
49-
else Ref(AWS_NO_VALUE),
41+
Prefix=(
42+
route_match[PREFIX_KEY]
43+
if keyisset(PREFIX_KEY, route_match)
44+
else Ref(AWS_NO_VALUE)
45+
),
46+
Scheme=(
47+
route_match[SCHEME_KEY].lower()
48+
if keyisset(SCHEME_KEY, route_match) and http2
49+
else Ref(AWS_NO_VALUE)
50+
),
51+
Method=(
52+
route_match[METHOD_KEY].upper()
53+
if keyisset(METHOD_KEY, route_match)
54+
else Ref(AWS_NO_VALUE)
55+
),
5056
),
5157
Action=appmesh.HttpRouteAction(
5258
WeightedTargets=[
@@ -238,9 +244,11 @@ def handle_tcp_route(self, routes, router, nodes):
238244
f"node {node[NAME_KEY]} is not defined as a virtual node."
239245
)
240246
route = appmesh.TcpRoute(
241-
Timeout=appmesh.TcpTimeout(Idle=appmesh.Duration(Unit="ms", Value=1))
242-
if keyisset("Timeout", route)
243-
else Ref(AWS_NO_VALUE),
247+
Timeout=(
248+
appmesh.TcpTimeout(Idle=appmesh.Duration(Unit="ms", Value=1))
249+
if keyisset("Timeout", route)
250+
else Ref(AWS_NO_VALUE)
251+
),
244252
Action=appmesh.TcpRouteAction(
245253
WeightedTargets=[
246254
appmesh.WeightedTarget(

ecs_composex/appmesh/appmesh_service.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,22 @@ def __init__(
120120
),
121121
Spec=appmesh.VirtualServiceSpec(
122122
Provider=appmesh.VirtualServiceProvider(
123-
VirtualNode=appmesh.VirtualNodeServiceProvider(
124-
VirtualNodeName=GetAtt(service_node.node, "VirtualNodeName")
125-
)
126-
if service_node
127-
else Ref(AWS_NO_VALUE),
128-
VirtualRouter=appmesh.VirtualRouterServiceProvider(
129-
VirtualRouterName=GetAtt(
130-
service_router.router, "VirtualRouterName"
123+
VirtualNode=(
124+
appmesh.VirtualNodeServiceProvider(
125+
VirtualNodeName=GetAtt(service_node.node, "VirtualNodeName")
131126
)
132-
)
133-
if service_router
134-
else Ref(AWS_NO_VALUE),
127+
if service_node
128+
else Ref(AWS_NO_VALUE)
129+
),
130+
VirtualRouter=(
131+
appmesh.VirtualRouterServiceProvider(
132+
VirtualRouterName=GetAtt(
133+
service_router.router, "VirtualRouterName"
134+
)
135+
)
136+
if service_router
137+
else Ref(AWS_NO_VALUE)
138+
),
135139
)
136140
),
137141
)

ecs_composex/cloudmap/cloudmap_ecs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ def __init__(
6767
self._sd_service = SdService(
6868
f"{namespace.logical_name}EcsServiceDiscovery{family.logical_name}",
6969
Description=Sub(f"{self.family.name} service"),
70-
NamespaceId=Ref(self.namespace.cfn_resource)
71-
if self.namespace.cfn_resource
72-
else self.namespace.namespace_id["ImportValue"],
70+
NamespaceId=(
71+
Ref(self.namespace.cfn_resource)
72+
if self.namespace.cfn_resource
73+
else self.namespace.namespace_id["ImportValue"]
74+
),
7375
HealthCheckCustomConfig=HealthCheckCustomConfig(FailureThreshold=1.0),
7476
DnsConfig=DnsConfig(
7577
RoutingPolicy="MULTIVALUE",

ecs_composex/common/settings.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from __future__ import annotations
99

10+
import json
1011
from typing import TYPE_CHECKING
1112

1213
if TYPE_CHECKING:
@@ -383,10 +384,10 @@ def set_efs(self) -> None:
383384
"Properties": volume.efs_definition,
384385
"MacroParameters": volume.parameters,
385386
"Lookup": volume.lookup,
386-
"Services": [
387-
{"name": service.name, "access": "RW"}
387+
"Services": {
388+
service.name: {"Access": "RW"}
388389
for service in volume.services
389-
],
390+
},
390391
"Settings": {"Subnets": "StorageSubnets"},
391392
"Volume": volume,
392393
}
@@ -513,13 +514,11 @@ def set_families(self) -> None:
513514
LOG.debug([self.families[family] for family in self.families])
514515

515516
def set_content(self, kwargs, content=None, fully_load=True):
516-
"""
517-
Method to initialize the compose content
517+
"""Method to initialize the compose content and validate as per the compose-x specs schemas."""
518+
from jsonschema import Draft7Validator
519+
520+
from ecs_composex.specs import REGISTRY
518521

519-
:param dict kwargs:
520-
:param dict content:
521-
:param bool fully_load:
522-
"""
523522
files = (
524523
[]
525524
if not keyisset(self.input_file_arg, kwargs)
@@ -529,16 +528,15 @@ def set_content(self, kwargs, content=None, fully_load=True):
529528
content_def = ComposeDefinition(files, content)
530529
self.original_content = content_def.definition
531530
self.compose_content = deepcopy(content_def.definition)
532-
source = pkg_files("ecs_composex").joinpath("specs/compose-spec.json")
533-
LOG.info(f"Validating against input schema {source}")
534-
resolver = jsonschema.RefResolver(
535-
f"file://{path.abspath(path.dirname(source))}/", None
536-
)
537-
jsonschema.validate(
538-
content_def.definition,
539-
loads(source.read_text()),
540-
resolver=resolver,
541-
)
531+
source = str(pkg_files("ecs_composex").joinpath("specs/compose-spec.json"))
532+
LOG.debug(f"Validating against input schema {source}")
533+
534+
with open(source) as compose_fd:
535+
content = compose_fd.read()
536+
schema = json.loads(content)
537+
538+
_eval = Draft7Validator(schema, registry=REGISTRY)
539+
_eval.validate(content_def.definition)
542540
if fully_load:
543541
self.set_secrets()
544542
self.set_volumes()

0 commit comments

Comments
 (0)