Skip to content

Commit

Permalink
Allow for patch in place
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Sep 3, 2024
1 parent 24021be commit 5d912ca
Show file tree
Hide file tree
Showing 24 changed files with 245 additions and 25 deletions.
14 changes: 14 additions & 0 deletions scripts/update_schemas_manually.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,20 @@
),
],
),
ResourcePatch(
resource_type="AWS::EC2::Subnet",
patches=[
Patch(
values={
"dependentExcluded": {
"AvailabilityZone": ["AvailabilityZoneId"],
"AvailabilityZoneId": ["AvailabilityZone"],
},
},
path="/",
),
],
),
]
)

Expand Down
10 changes: 10 additions & 0 deletions src/cfnlint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ def __call__(self, parser, namespace, values, option_string=None):
help="Update the CloudFormation Specs",
action="store_true",
)
advanced.add_argument(
"-p",
"--patch-specs",
help="Patch the CloudFormation Specs in place",
action="store_true",
)
advanced.add_argument(
"--update-documentation", help=argparse.SUPPRESS, action="store_true"
)
Expand Down Expand Up @@ -792,6 +798,10 @@ def custom_rules(self):
def update_specs(self):
return self._get_argument_value("update_specs", False, False)

@property
def patch_specs(self):
return self._get_argument_value("patch_specs", False, False)

@property
def update_documentation(self):
return self._get_argument_value("update_documentation", False, False)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"op": "add",
"path": "/dependentExcluded",
"value": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
"type": "object"
}
},
"dependentExcluded": {
"AvailabilityZone": [
"AvailabilityZoneId"
],
"AvailabilityZoneId": [
"AvailabilityZone"
]
},
"handlers": {
"create": {
"permissions": [
Expand Down
9 changes: 9 additions & 0 deletions src/cfnlint/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ def update_resource_specs(force: bool = False):
PROVIDER_SCHEMA_MANAGER.update(force)


def patch_resource_specs():
# Pool() uses cpu count if no number of processors is specified
# Pool() only implements the Context Manager protocol from Python3.3 onwards,
# so it will fail Python2.7 style linting, as well as throw AttributeError

# Update provider Schemas
PROVIDER_SCHEMA_MANAGER.patch_schemas()


def update_documentation(rules):
# Update the overview of all rules in the linter
filename = "docs/rules.md"
Expand Down
4 changes: 4 additions & 0 deletions src/cfnlint/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ def cli(self) -> None:
cfnlint.maintenance.update_resource_specs(self.config.force)
sys.exit(0)

if self.config.patch_specs:
cfnlint.maintenance.patch_resource_specs()
sys.exit(0)

if self.config.update_iam_policies:
cfnlint.maintenance.update_iam_policies()
sys.exit(0)
Expand Down
Loading

0 comments on commit 5d912ca

Please sign in to comment.