Skip to content

Commit e6eb757

Browse files
authored
Allow for patch in place (#3649)
* Allow for patch in place
1 parent 466004b commit e6eb757

File tree

25 files changed

+247
-27
lines changed

25 files changed

+247
-27
lines changed

scripts/update_schemas_manually.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,20 @@
15741574
),
15751575
],
15761576
),
1577+
ResourcePatch(
1578+
resource_type="AWS::EC2::Subnet",
1579+
patches=[
1580+
Patch(
1581+
values={
1582+
"dependentExcluded": {
1583+
"AvailabilityZone": ["AvailabilityZoneId"],
1584+
"AvailabilityZoneId": ["AvailabilityZone"],
1585+
},
1586+
},
1587+
path="/",
1588+
),
1589+
],
1590+
),
15771591
]
15781592
)
15791593

src/cfnlint/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,12 @@ def __call__(self, parser, namespace, values, option_string=None):
533533
help="Update the CloudFormation Specs",
534534
action="store_true",
535535
)
536+
advanced.add_argument(
537+
"-p",
538+
"--patch-specs",
539+
help="Patch the CloudFormation Specs in place",
540+
action="store_true",
541+
)
536542
advanced.add_argument(
537543
"--update-documentation", help=argparse.SUPPRESS, action="store_true"
538544
)
@@ -792,6 +798,10 @@ def custom_rules(self):
792798
def update_specs(self):
793799
return self._get_argument_value("update_specs", False, False)
794800

801+
@property
802+
def patch_specs(self):
803+
return self._get_argument_value("patch_specs", False, False)
804+
795805
@property
796806
def update_documentation(self):
797807
return self._get_argument_value("update_documentation", False, False)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"op": "add",
4+
"path": "/dependentExcluded",
5+
"value": {
6+
"AvailabilityZone": [
7+
"AvailabilityZoneId"
8+
],
9+
"AvailabilityZoneId": [
10+
"AvailabilityZone"
11+
]
12+
}
13+
}
14+
]

src/cfnlint/data/schemas/providers/af_south_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/ap_east_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/ap_northeast_2/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/ap_south_2/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/ap_southeast_3/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/ap_southeast_4/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/ap_southeast_5/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/ca_west_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/cn_northwest_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/eu_central_2/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/eu_north_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/eu_south_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/eu_south_2/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/il_central_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/me_south_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/us_east_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/us_gov_east_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/data/schemas/providers/us_gov_west_1/aws-ec2-subnet.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
"type": "object"
3434
}
3535
},
36+
"dependentExcluded": {
37+
"AvailabilityZone": [
38+
"AvailabilityZoneId"
39+
],
40+
"AvailabilityZoneId": [
41+
"AvailabilityZone"
42+
]
43+
},
3644
"handlers": {
3745
"create": {
3846
"permissions": [

src/cfnlint/maintenance.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ def update_resource_specs(force: bool = False):
2929
PROVIDER_SCHEMA_MANAGER.update(force)
3030

3131

32+
def patch_resource_specs():
33+
# Pool() uses cpu count if no number of processors is specified
34+
# Pool() only implements the Context Manager protocol from Python3.3 onwards,
35+
# so it will fail Python2.7 style linting, as well as throw AttributeError
36+
37+
# Update provider Schemas
38+
PROVIDER_SCHEMA_MANAGER.patch_schemas()
39+
40+
3241
def update_documentation(rules):
3342
# Update the overview of all rules in the linter
3443
filename = "docs/rules.md"

src/cfnlint/runner.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ def cli(self) -> None:
417417
cfnlint.maintenance.update_resource_specs(self.config.force)
418418
sys.exit(0)
419419

420+
if self.config.patch_specs:
421+
cfnlint.maintenance.patch_resource_specs()
422+
sys.exit(0)
423+
420424
if self.config.update_iam_policies:
421425
cfnlint.maintenance.update_iam_policies()
422426
sys.exit(0)

0 commit comments

Comments
 (0)