Skip to content

Commit

Permalink
don't create empty files
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Oct 14, 2024
1 parent 8ea76a5 commit 9d2ddca
Show file tree
Hide file tree
Showing 28 changed files with 47 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maintenance-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
cfn-lint --update-documentation
scripts/update_specs_from_pricing.py
scripts/update_serverless_aws_policies.py
scripts/update_schemas_from_boto.py
scripts/boto/update_schemas_from_boto.py
scripts/update_schemas_from_aws_api.py
cfn-lint --update-specs
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
Expand Down
20 changes: 0 additions & 20 deletions scripts/boto/_manual_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@
shape="BrokerStorageType",
),
},
"AWS::AmazonMQ::Configuration": {
"/properties/AuthenticationStrategy": Patch(
source=["mq", "2017-11-27"],
shape="AuthenticationStrategy",
),
"/properties/EngineType": Patch(
source=["mq", "2017-11-27"],
shape="EngineType",
),
},
"AWS::ApiGateway::RestApi": {
"/properties/ApiKeySourceType": Patch(
source=["apigateway", "2015-07-09"],
Expand All @@ -57,10 +47,6 @@
),
},
"AWS::ApplicationAutoScaling::ScalingPolicy": {
"/properties/PolicyType": Patch(
source=["application-autoscaling", "2016-02-06"],
shape="PolicyType",
),
(
"/definitions/PredefinedMetricSpecification/"
"properties/PredefinedMetricType"
Expand Down Expand Up @@ -385,12 +371,6 @@
shape="StreamViewType",
),
},
"AWS::EC2::CustomerGateway": {
"/properties/Type": Patch(
source=["ec2", "2016-11-15"],
shape="GatewayType",
),
},
"AWS::EC2::EC2Fleet": {
"/definitions/OnDemandOptionsRequest/properties/AllocationStrategy": Patch(
source=["ec2", "2016-11-15"],
Expand Down
74 changes: 38 additions & 36 deletions scripts/boto/update_schemas_from_boto.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,45 +56,47 @@ def build_resource_type_patches(

output_file = resource_path / "boto.json"

with open(output_file, "w+") as fh:
d = []
boto_d = {}
for path, patch in resource_patches.items():
service_path = (
["botocore-master/botocore/data"] + patch.source + ["service-2.json"]
)
with open(os.path.join(dir, *service_path), "r") as f:
boto_d = json.load(f)

for field in ["enum", "pattern"]:
value = boto_d.get("shapes", {}).get(patch.shape, {}).get(field)
if not value:
d = []
boto_d = {}
for path, patch in resource_patches.items():
service_path = (
["botocore-master/botocore/data"] + patch.source + ["service-2.json"]
)
with open(os.path.join(dir, *service_path), "r") as f:
boto_d = json.load(f)

for field in ["enum", "pattern"]:
value = boto_d.get("shapes", {}).get(patch.shape, {}).get(field)
if not value:
continue
if field == "pattern":
if value == ".*":
continue
if field == "pattern":
if value == ".*":
continue
try:
re.compile(value)
except Exception:
LOGGER.info(
(
f"Pattern {value!r} failed to "
"compile for resource "
f"{resource_name!r}"
)
try:
re.compile(value)
except Exception:
LOGGER.info(
(
f"Pattern {value!r} failed to "
"compile for resource "
f"{resource_name!r}"
)
continue
if value:
d.append(
{
"op": "add",
"path": f"{path}/{field}",
"value": (
sorted(value) if isinstance(value, list) else value
),
}
)

continue
if value:
d.append(
{
"op": "add",
"path": f"{path}/{field}",
"value": (
sorted(value) if isinstance(value, list) else value
),
}
)

if not d:
return
with open(output_file, "w+") as fh:
json.dump(
d,
fh,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
[
{
"op": "add",
"path": "/properties/PolicyType/enum",
"value": [
"StepScaling",
"TargetTrackingScaling"
]
},
{
"op": "add",
"path": "/definitions/PredefinedMetricSpecification/properties/PredefinedMetricType/enum",
Expand Down Expand Up @@ -94,5 +86,13 @@
"sagemaker:variant:DesiredProvisionedConcurrency",
"workspaces:workspacespool:DesiredUserSessions"
]
},
{
"op": "add",
"path": "/properties/PolicyType/enum",
"value": [
"StepScaling",
"TargetTrackingScaling"
]
}
]

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 9d2ddca

Please sign in to comment.