From cfc28df260e3ff3d853ba33da73d744879df6047 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Mon, 14 Oct 2024 08:38:42 -0700 Subject: [PATCH] don't create empty files --- .github/workflows/maintenance-v1.yaml | 2 +- scripts/boto/_manual_patches.py | 20 ----- scripts/boto/update_schemas_from_boto.py | 74 ++++++++++--------- .../aws_appintegrations_application/boto.json | 1 - .../boto.json | 1 - .../boto.json | 1 - .../boto.json | 16 ++-- .../all/aws_athena_datacatalog/boto.json | 1 - .../boto.json | 1 - .../aws_autoscaling_scheduledaction/boto.json | 1 - .../all/aws_datapipeline_pipeline/boto.json | 1 - .../aws_emr_securityconfiguration/boto.json | 1 - .../extensions/all/aws_emr_step/boto.json | 1 - .../extensions/all/aws_emr_studio/boto.json | 1 - .../aws_emr_studiosessionmapping/boto.json | 1 - .../all/aws_evidently_experiment/boto.json | 1 - .../all/aws_evidently_feature/boto.json | 1 - .../all/aws_evidently_launch/boto.json | 1 - .../all/aws_evidently_project/boto.json | 1 - .../all/aws_evidently_segment/boto.json | 1 - .../all/aws_glue_database/boto.json | 1 - .../all/aws_glue_registry/boto.json | 1 - .../all/aws_glue_usageprofile/boto.json | 1 - .../aws_iottwinmaker_componenttype/boto.json | 1 - .../all/aws_iottwinmaker_entity/boto.json | 1 - .../all/aws_iottwinmaker_scene/boto.json | 1 - .../all/aws_lakeformation_tag/boto.json | 1 - .../all/aws_sagemaker_modelcard/boto.json | 1 - 28 files changed, 47 insertions(+), 89 deletions(-) delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_application/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_dataintegration/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_eventintegration/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_athena_datacatalog/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_autoscaling_autoscalinggroup/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_autoscaling_scheduledaction/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_datapipeline_pipeline/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_emr_securityconfiguration/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_emr_step/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_emr_studio/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_emr_studiosessionmapping/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_experiment/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_feature/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_launch/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_project/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_segment/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_glue_database/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_glue_registry/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_glue_usageprofile/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_componenttype/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_entity/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_scene/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_lakeformation_tag/boto.json delete mode 100644 src/cfnlint/data/schemas/patches/extensions/all/aws_sagemaker_modelcard/boto.json diff --git a/.github/workflows/maintenance-v1.yaml b/.github/workflows/maintenance-v1.yaml index 45c71d8ab2..8997f7360a 100644 --- a/.github/workflows/maintenance-v1.yaml +++ b/.github/workflows/maintenance-v1.yaml @@ -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 diff --git a/scripts/boto/_manual_patches.py b/scripts/boto/_manual_patches.py index da36799c6b..00eaf57165 100644 --- a/scripts/boto/_manual_patches.py +++ b/scripts/boto/_manual_patches.py @@ -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"], @@ -57,10 +47,6 @@ ), }, "AWS::ApplicationAutoScaling::ScalingPolicy": { - "/properties/PolicyType": Patch( - source=["application-autoscaling", "2016-02-06"], - shape="PolicyType", - ), ( "/definitions/PredefinedMetricSpecification/" "properties/PredefinedMetricType" @@ -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"], diff --git a/scripts/boto/update_schemas_from_boto.py b/scripts/boto/update_schemas_from_boto.py index 5e1b4be1e4..978c5bbe00 100755 --- a/scripts/boto/update_schemas_from_boto.py +++ b/scripts/boto/update_schemas_from_boto.py @@ -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, diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_application/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_application/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_application/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_dataintegration/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_dataintegration/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_dataintegration/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_eventintegration/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_eventintegration/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_appintegrations_eventintegration/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_applicationautoscaling_scalingpolicy/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_applicationautoscaling_scalingpolicy/boto.json index 472b7ff68f..7a98f1835b 100644 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_applicationautoscaling_scalingpolicy/boto.json +++ b/src/cfnlint/data/schemas/patches/extensions/all/aws_applicationautoscaling_scalingpolicy/boto.json @@ -1,12 +1,4 @@ [ - { - "op": "add", - "path": "/properties/PolicyType/enum", - "value": [ - "StepScaling", - "TargetTrackingScaling" - ] - }, { "op": "add", "path": "/definitions/PredefinedMetricSpecification/properties/PredefinedMetricType/enum", @@ -94,5 +86,13 @@ "sagemaker:variant:DesiredProvisionedConcurrency", "workspaces:workspacespool:DesiredUserSessions" ] + }, + { + "op": "add", + "path": "/properties/PolicyType/enum", + "value": [ + "StepScaling", + "TargetTrackingScaling" + ] } ] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_athena_datacatalog/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_athena_datacatalog/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_athena_datacatalog/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_autoscaling_autoscalinggroup/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_autoscaling_autoscalinggroup/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_autoscaling_autoscalinggroup/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_autoscaling_scheduledaction/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_autoscaling_scheduledaction/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_autoscaling_scheduledaction/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_datapipeline_pipeline/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_datapipeline_pipeline/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_datapipeline_pipeline/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_securityconfiguration/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_securityconfiguration/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_securityconfiguration/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_step/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_step/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_step/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_studio/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_studio/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_studio/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_studiosessionmapping/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_studiosessionmapping/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_emr_studiosessionmapping/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_experiment/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_experiment/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_experiment/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_feature/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_feature/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_feature/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_launch/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_launch/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_launch/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_project/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_project/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_project/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_segment/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_segment/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_evidently_segment/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_glue_database/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_glue_database/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_glue_database/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_glue_registry/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_glue_registry/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_glue_registry/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_glue_usageprofile/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_glue_usageprofile/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_glue_usageprofile/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_componenttype/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_componenttype/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_componenttype/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_entity/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_entity/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_entity/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_scene/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_scene/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_iottwinmaker_scene/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_lakeformation_tag/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_lakeformation_tag/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_lakeformation_tag/boto.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/src/cfnlint/data/schemas/patches/extensions/all/aws_sagemaker_modelcard/boto.json b/src/cfnlint/data/schemas/patches/extensions/all/aws_sagemaker_modelcard/boto.json deleted file mode 100644 index fe51488c70..0000000000 --- a/src/cfnlint/data/schemas/patches/extensions/all/aws_sagemaker_modelcard/boto.json +++ /dev/null @@ -1 +0,0 @@ -[]