diff --git a/.github/ci/prefetch-images.sh b/.github/ci/prefetch-images.sh index db4cb22c62..2286266fea 100755 --- a/.github/ci/prefetch-images.sh +++ b/.github/ci/prefetch-images.sh @@ -50,8 +50,10 @@ starts() { grep -qE "$(IFS='|'; echo "$*")" "$SHARD_FILE" } # The image a test constant pins, or empty (and a log line) when the constant cannot be read. +# TestImages is found by name rather than by its package path, which a package rename changes. +TEST_IMAGES="$(find src/test/java -path '*/testing/TestImages.java' -print -quit)" test_image() { - image="$(grep -oE "$1 *= *\"[^\"]+\"" src/test/java/io/github/hectorvent/floci/testing/TestImages.java | grep -oE '"[^"]+"' | tr -d '"')" + image="$(grep -oE "$1 *= *\"[^\"]+\"" "${TEST_IMAGES:-/dev/null}" | grep -oE '"[^"]+"' | tr -d '"')" [ -n "$image" ] || echo "$(date -u +%H:%M:%S) prefetch skipped: TestImages.$1 not readable" >> "$PREFETCH_LOG" echo "$image" } diff --git a/.github/workflows/docs-actions.yml b/.github/workflows/docs-actions.yml index b8726e02ec..917a265f33 100644 --- a/.github/workflows/docs-actions.yml +++ b/.github/workflows/docs-actions.yml @@ -14,6 +14,7 @@ on: - 'docs/**' - 'mkdocs.yml' - 'tools/docs/**' + - 'tools/java_sources.py' - 'Makefile' - '.github/workflows/docs-actions.yml' push: @@ -25,6 +26,7 @@ on: - 'docs/**' - 'mkdocs.yml' - 'tools/docs/**' + - 'tools/java_sources.py' - 'Makefile' - '.github/workflows/docs-actions.yml' diff --git a/.github/workflows/partition-literals.yml b/.github/workflows/partition-literals.yml index e8b472d927..b24f1485bd 100644 --- a/.github/workflows/partition-literals.yml +++ b/.github/workflows/partition-literals.yml @@ -17,6 +17,7 @@ on: - 'src/main/java/**' - 'src/main/resources/aws/**' - 'tools/partition/**' + - 'tools/java_sources.py' - 'tools/rename/**' - 'tools/aws/**' - 'tools/slr/**' @@ -33,6 +34,7 @@ on: - 'src/main/java/**' - 'src/main/resources/aws/**' - 'tools/partition/**' + - 'tools/java_sources.py' - 'tools/rename/**' - 'tools/aws/**' - 'tools/slr/**' diff --git a/tools/docs/check_service_matrix.py b/tools/docs/check_service_matrix.py index a7e66ae005..17d42ff797 100644 --- a/tools/docs/check_service_matrix.py +++ b/tools/docs/check_service_matrix.py @@ -41,7 +41,10 @@ except ModuleNotFoundError: import yaml -CATALOG_SOURCE = "src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java" +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +from java_sources import PACKAGE_DIR, package_source # noqa: E402 + +CATALOG_SOURCE = f"{PACKAGE_DIR}/core/common/ResolvedServiceCatalog.java" MATRIX_DOC = "docs/services/index.md" REGISTRY = "tools/docs/service_matrix.yaml" @@ -236,7 +239,7 @@ def extract_action_counts(repo_root: Path, required_sources: frozenset[str] = fr if not isinstance(relative_path, str): raise ValueError(f"{REGISTRY}: action count source '{slug}' needs a source path") actions = regen_action_docs.extract_switch_actions( - (repo_root / relative_path).read_text(encoding="utf-8") + (repo_root / package_source(relative_path)).read_text(encoding="utf-8") ) if not actions: raise ValueError(f"{REGISTRY}: action count source '{slug}' has no actions") diff --git a/tools/docs/regen_action_docs.py b/tools/docs/regen_action_docs.py index 37f269be4c..128f89d53f 100644 --- a/tools/docs/regen_action_docs.py +++ b/tools/docs/regen_action_docs.py @@ -26,6 +26,9 @@ from pathlib import Path import yaml +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +from java_sources import SERVICES_PACKAGE_DIR, package_source # noqa: E402 + MARKER_START = "" MARKER_END = "" @@ -325,7 +328,7 @@ def _load_registry(repo_root: Path) -> tuple[list[ServiceEntry], set[Path]]: entries: list[ServiceEntry] = [] for item in raw.get("services") or []: sources = [ - Source(path=repo_root / s["path"], mode=s["mode"]) + Source(path=repo_root / package_source(s["path"]), mode=s["mode"]) for s in item.get("sources") or [] ] handler = item.get("handler") @@ -336,11 +339,11 @@ def _load_registry(repo_root: Path) -> tuple[list[ServiceEntry], set[Path]]: sources=sources, rename_actions=dict(item.get("rename_actions") or {}), exclude_actions=frozenset(item.get("exclude_actions") or []), - handler=repo_root / handler if handler else None, + handler=repo_root / package_source(handler) if handler else None, ) ) deferred = { - (repo_root / d["path"]).resolve() + (repo_root / package_source(d["path"])).resolve() for d in raw.get("deferred_handlers") or [] } return entries, deferred @@ -369,7 +372,7 @@ def _find_unregistered_handlers( or added to deferred_handlers (with a reason), or this fails --strict. REST controllers are opt-in (per-judgment) and not flagged here. """ - services_root = repo_root / "src/main/java/io/github/hectorvent/floci/services" + services_root = repo_root / SERVICES_PACKAGE_DIR registered = {s.path.resolve() for entry in entries for s in entry.sources} registered |= {entry.handler.resolve() for entry in entries if entry.handler} registered |= deferred diff --git a/tools/docs/regen_cfn_resource_types.py b/tools/docs/regen_cfn_resource_types.py index df334f53f9..8331174803 100644 --- a/tools/docs/regen_cfn_resource_types.py +++ b/tools/docs/regen_cfn_resource_types.py @@ -23,11 +23,14 @@ from pathlib import Path import yaml +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +from java_sources import SERVICES_PACKAGE_DIR # noqa: E402 + REPO_ROOT = Path(__file__).resolve().parents[2] INVENTORY = REPO_ROOT / "src/test/resources/cloudformation/supported-resource-types.tsv" CONFIG = Path(__file__).resolve().parent / "cfn_resource_types.yaml" DOC = REPO_ROOT / "docs/services/cloudformation.md" -PROVISIONER_DIR = REPO_ROOT / "src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners" +PROVISIONER_DIR = REPO_ROOT / SERVICES_PACKAGE_DIR / "cloudformation/provisioners" MARKER_START = "" MARKER_END = "" diff --git a/tools/docs/service_inventory.py b/tools/docs/service_inventory.py index b3379cab15..29bdf60e2b 100644 --- a/tools/docs/service_inventory.py +++ b/tools/docs/service_inventory.py @@ -39,11 +39,13 @@ import yaml import check_service_matrix as csm -CONFIG_SOURCE = "src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java" +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +from java_sources import PACKAGE_DIR, SERVICES_PACKAGE_DIR # noqa: E402 + +CONFIG_SOURCE = f"{PACKAGE_DIR}/config/EmulatorConfig.java" APPLICATION_YML = "src/main/resources/application.yml" README = "README.md" SERVICES_YAML = "tools/docs/services.yaml" -PACKAGE_DIR = "src/main/java/io/github/hectorvent/floci/services" # Warn this far ahead of a deferred entry's expiry, so a red main is a decision rather # than a surprise on the morning the date passes. @@ -290,7 +292,7 @@ def collect(repo_root: Path) -> dict: ), "yaml_keys": yaml_keys, "yaml_enabled": yaml_enabled, - "packages": sorted(p.name for p in (repo_root / PACKAGE_DIR).iterdir() if p.is_dir()), + "packages": sorted(p.name for p in (repo_root / SERVICES_PACKAGE_DIR).iterdir() if p.is_dir()), "matrix_rows": parse_matrix_rows( (repo_root / csm.MATRIX_DOC).read_text(encoding="utf-8") ), @@ -500,13 +502,13 @@ def render(result: dict) -> str: w("") w("3. SOURCE (keyspace: Java package, naming normalised)") - line("services/ packages", c["service_packages"], PACKAGE_DIR) + line("services/ packages", c["service_packages"], SERVICES_PACKAGE_DIR) delta("no descriptor, explained", pkg["noted"]) for p in pkg["noted"]: note(f"{p}: {PACKAGE_NOTES[p]}") if pkg["unregistered"]: delta("UNREGISTERED", pkg["unregistered"]) - note(f"A package under {PACKAGE_DIR} that no descriptor(...) names.") + note(f"A package under {SERVICES_PACKAGE_DIR} that no descriptor(...) names.") note("Register it, or add it to PACKAGE_NOTES with the reason it has none.") else: line("= every other package registered", "", "ADVISORY, no gate") diff --git a/tools/docs/service_matrix.yaml b/tools/docs/service_matrix.yaml index da4af43300..0a097d78bb 100644 --- a/tools/docs/service_matrix.yaml +++ b/tools/docs/service_matrix.yaml @@ -67,21 +67,22 @@ deferred: [] # Non-tabular pages with one Query/JSON action dispatcher per numeric base row. # These counts are checked against the handler switch, without flattening the # grouped documentation. Anchored and mixed-dispatch rows need separate rules. +# Paths are relative to the Java package root, PACKAGE_DIR in tools/java_sources.py. action_count_sources: - autoscaling: src/main/java/io/github/hectorvent/floci/services/autoscaling/AutoScalingQueryHandler.java - cloudmap: src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapHandler.java - codebuild: src/main/java/io/github/hectorvent/floci/services/codebuild/CodeBuildJsonHandler.java - codedeploy: src/main/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployJsonHandler.java - cognito: src/main/java/io/github/hectorvent/floci/services/cognito/CognitoJsonHandler.java - config: src/main/java/io/github/hectorvent/floci/services/configservice/ConfigServiceJsonHandler.java - ec2: src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java - ecs: src/main/java/io/github/hectorvent/floci/services/ecs/EcsJsonHandler.java - elastic-beanstalk: src/main/java/io/github/hectorvent/floci/services/elasticbeanstalk/ElasticBeanstalkQueryHandler.java - elb: src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2QueryHandler.java - elb-classic: src/main/java/io/github/hectorvent/floci/services/elb/ElbClassicQueryHandler.java - glue: src/main/java/io/github/hectorvent/floci/services/glue/GlueJsonHandler.java - iam: src/main/java/io/github/hectorvent/floci/services/iam/IamQueryHandler.java - resource-groups-tagging: src/main/java/io/github/hectorvent/floci/services/resourcegroupstagging/ResourceGroupsTaggingJsonHandler.java + autoscaling: services/autoscaling/AutoScalingQueryHandler.java + cloudmap: services/cloudmap/CloudMapHandler.java + codebuild: services/codebuild/CodeBuildJsonHandler.java + codedeploy: services/codedeploy/CodeDeployJsonHandler.java + cognito: services/cognito/CognitoJsonHandler.java + config: services/configservice/ConfigServiceJsonHandler.java + ec2: services/ec2/Ec2QueryHandler.java + ecs: services/ecs/EcsJsonHandler.java + elastic-beanstalk: services/elasticbeanstalk/ElasticBeanstalkQueryHandler.java + elb: services/elbv2/ElbV2QueryHandler.java + elb-classic: services/elb/ElbClassicQueryHandler.java + glue: services/glue/GlueJsonHandler.java + iam: services/iam/IamQueryHandler.java + resource-groups-tagging: services/resourcegroupstagging/ResourceGroupsTaggingJsonHandler.java # docs/services pages that intentionally have no Service Matrix row of their own. facet_pages: diff --git a/tools/docs/services.yaml b/tools/docs/services.yaml index 2644eaa67e..5e197c710a 100644 --- a/tools/docs/services.yaml +++ b/tools/docs/services.yaml @@ -8,42 +8,45 @@ # docs, mixed-mode (ses), S3 query-string dispatch, and non-tabular docs are tracked # as follow-ups; their switch handlers are acknowledged in deferred_handlers below so # the new-service sentinel only fires on genuinely unregistered handlers. +# +# Source paths (path, handler) are relative to the Java package root, PACKAGE_DIR in +# tools/java_sources.py, so they do not change when the package moves. services: - service: account doc: docs/services/account.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/account/AccountController.java, mode: rest } + - { path: services/account/AccountController.java, mode: rest } - service: accessanalyzer doc: docs/services/access-analyzer.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/accessanalyzer/AccessAnalyzerController.java, mode: rest } + - { path: services/accessanalyzer/AccessAnalyzerController.java, mode: rest } - service: acm doc: docs/services/acm.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/acm/AcmJsonHandler.java, mode: switch } + - { path: services/acm/AcmJsonHandler.java, mode: switch } - service: applicationautoscaling doc: docs/services/applicationautoscaling.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/applicationautoscaling/ApplicationAutoScalingJsonHandler.java, mode: switch } + - { path: services/applicationautoscaling/ApplicationAutoScalingJsonHandler.java, mode: switch } - service: athena doc: docs/services/athena.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/athena/AthenaJsonHandler.java, mode: switch } + - { path: services/athena/AthenaJsonHandler.java, mode: switch } - service: bedrock doc: docs/services/bedrock.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/bedrock/BedrockController.java, mode: rest } + - { path: services/bedrock/BedrockController.java, mode: rest } - service: bedrock-agentcore-control doc: docs/services/bedrock-agentcore.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/bedrockagentcorecontrol/BedrockAgentCoreControlController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/services/bedrockagentcorecontrol/BedrockAgentCoreIdentityController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/services/bedrockagentcorecontrol/BedrockAgentCoreGatewayController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/services/bedrockagentcorecontrol/BedrockAgentCoreMemoryController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/services/bedrockagentcorecontrol/BedrockAgentCoreToolsController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/services/bedrockagentcorecontrol/BedrockAgentCoreGatewayRuleController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/services/bedrockagentcorecontrol/BedrockAgentCoreResourcePolicyController.java, mode: rest } + - { path: services/bedrockagentcorecontrol/BedrockAgentCoreControlController.java, mode: rest } + - { path: services/bedrockagentcorecontrol/BedrockAgentCoreIdentityController.java, mode: rest } + - { path: services/bedrockagentcorecontrol/BedrockAgentCoreGatewayController.java, mode: rest } + - { path: services/bedrockagentcorecontrol/BedrockAgentCoreMemoryController.java, mode: rest } + - { path: services/bedrockagentcorecontrol/BedrockAgentCoreToolsController.java, mode: rest } + - { path: services/bedrockagentcorecontrol/BedrockAgentCoreGatewayRuleController.java, mode: rest } + - { path: services/bedrockagentcorecontrol/BedrockAgentCoreResourcePolicyController.java, mode: rest } rename_actions: CreateEndpoint: CreateAgentRuntimeEndpoint GetEndpoint: GetAgentRuntimeEndpoint @@ -63,24 +66,24 @@ services: - service: ce doc: docs/services/ce.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/ce/CostExplorerJsonHandler.java, mode: switch } + - { path: services/ce/CostExplorerJsonHandler.java, mode: switch } - service: cloudformation doc: docs/services/cloudformation.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationQueryHandler.java, mode: switch } + - { path: services/cloudformation/CloudFormationQueryHandler.java, mode: switch } - service: cloudhsmv2 doc: docs/services/cloudhsmv2.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/cloudhsmv2/CloudHsmV2JsonHandler.java, mode: switch } + - { path: services/cloudhsmv2/CloudHsmV2JsonHandler.java, mode: switch } - service: cloudtrail doc: docs/services/cloudtrail.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/cloudtrail/CloudTrailJsonHandler.java, mode: switch } + - { path: services/cloudtrail/CloudTrailJsonHandler.java, mode: switch } - service: codeartifact doc: docs/services/codeartifact.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/codeartifact/CodeArtifactController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/core/common/V1TagsController.java, mode: rest } + - { path: services/codeartifact/CodeArtifactController.java, mode: rest } + - { path: core/common/V1TagsController.java, mode: rest } rename_actions: ListTagsForResourceByQuery: ListTagsForResource exclude_actions: @@ -90,8 +93,8 @@ services: - service: codegurureviewer doc: docs/services/codegurureviewer.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/codegurureviewer/CodeGuruReviewerController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java, mode: rest } + - { path: services/codegurureviewer/CodeGuruReviewerController.java, mode: rest } + - { path: core/common/SharedTagsController.java, mode: rest } rename_actions: ListTags: ListTagsForResource TagResourcePost: TagResource @@ -103,17 +106,17 @@ services: - service: lambdaweb doc: docs/services/lambda-web-functions.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/lambdaweb/LambdaWebController.java, mode: rest } + - { path: services/lambdaweb/LambdaWebController.java, mode: rest } - service: marketplace doc: docs/services/marketplace.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceCatalogController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceAgreementService.java, mode: switch } - - { path: src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceEntitlementController.java, mode: switch } - - { path: src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceDeploymentController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceReportingController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceMeteringService.java, mode: switch } - - { path: src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceDiscoveryController.java, mode: rest } + - { path: services/marketplace/MarketplaceCatalogController.java, mode: rest } + - { path: services/marketplace/MarketplaceAgreementService.java, mode: switch } + - { path: services/marketplace/MarketplaceEntitlementController.java, mode: switch } + - { path: services/marketplace/MarketplaceDeploymentController.java, mode: rest } + - { path: services/marketplace/MarketplaceReportingController.java, mode: rest } + - { path: services/marketplace/MarketplaceMeteringService.java, mode: switch } + - { path: services/marketplace/MarketplaceDiscoveryController.java, mode: rest } exclude_actions: - AgreementType - Status @@ -141,19 +144,19 @@ services: - service: comprehend doc: docs/services/comprehend.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/comprehend/ComprehendJsonHandler.java, mode: switch } + - { path: services/comprehend/ComprehendJsonHandler.java, mode: switch } - service: controlcatalog doc: docs/services/controlcatalog.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/controlcatalog/ControlCatalogController.java, mode: rest } + - { path: services/controlcatalog/ControlCatalogController.java, mode: rest } rename_actions: GetControl: GetControl ListControls: ListControls - service: appintegrations doc: docs/services/appintegrations.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/appintegrations/AppIntegrationsController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java, mode: rest } + - { path: services/appintegrations/AppIntegrationsController.java, mode: rest } + - { path: core/common/SharedTagsController.java, mode: rest } rename_actions: ListTags: ListTagsForResource TagResourcePost: TagResource @@ -165,8 +168,8 @@ services: - service: dlm doc: docs/services/dlm.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/dlm/DlmController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java, mode: rest } + - { path: services/dlm/DlmController.java, mode: rest } + - { path: core/common/SharedTagsController.java, mode: rest } rename_actions: ListTags: ListTagsForResource TagResourcePost: TagResource @@ -178,8 +181,8 @@ services: - service: connect doc: docs/services/connect.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/connect/ConnectController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java, mode: rest } + - { path: services/connect/ConnectController.java, mode: rest } + - { path: core/common/SharedTagsController.java, mode: rest } rename_actions: ListTags: ListTagsForResource TagResourcePost: TagResource @@ -191,58 +194,58 @@ services: - service: rekognition doc: docs/services/rekognition.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/rekognition/RekognitionJsonHandler.java, mode: switch } + - { path: services/rekognition/RekognitionJsonHandler.java, mode: switch } - service: translate doc: docs/services/translate.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/translate/TranslateJsonHandler.java, mode: switch } + - { path: services/translate/TranslateJsonHandler.java, mode: switch } - service: detective doc: docs/services/detective.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/detective/DetectiveController.java, mode: rest } + - { path: services/detective/DetectiveController.java, mode: rest } - service: dms doc: docs/services/dms.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/dms/DmsJsonHandler.java, mode: switch } + - { path: services/dms/DmsJsonHandler.java, mode: switch } - service: docdb doc: docs/services/docdb.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/docdb/DocDbQueryHandler.java, mode: switch } + - { path: services/docdb/DocDbQueryHandler.java, mode: switch } - service: dsql doc: docs/services/dsql.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/dsql/DsqlController.java, mode: rest } + - { path: services/dsql/DsqlController.java, mode: rest } - service: efs doc: docs/services/efs.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/efs/EfsController.java, mode: rest } + - { path: services/efs/EfsController.java, mode: rest } - service: organizations doc: docs/services/organizations.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/organizations/OrganizationsJsonHandler.java, mode: switch } + - { path: services/organizations/OrganizationsJsonHandler.java, mode: switch } - service: elasticache doc: docs/services/elasticache.md exclude_actions: [SubnetIds, SecurityGroupIds, SnapshotArnsToRestore] sources: - - { path: src/main/java/io/github/hectorvent/floci/services/elasticache/ElastiCacheQueryHandler.java, mode: switch } - - { path: src/main/java/io/github/hectorvent/floci/services/elasticache/ElastiCacheServerlessQueryHandler.java, mode: switch } + - { path: services/elasticache/ElastiCacheQueryHandler.java, mode: switch } + - { path: services/elasticache/ElastiCacheServerlessQueryHandler.java, mode: switch } - service: emr doc: docs/services/emr.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/emr/EmrHandler.java, mode: switch } + - { path: services/emr/EmrHandler.java, mode: switch } - service: eventbridge doc: docs/services/eventbridge.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/eventbridge/EventBridgeHandler.java, mode: switch } + - { path: services/eventbridge/EventBridgeHandler.java, mode: switch } - service: firehose doc: docs/services/firehose.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/firehose/FirehoseJsonHandler.java, mode: switch } + - { path: services/firehose/FirehoseJsonHandler.java, mode: switch } - service: resource-explorer-2 doc: docs/services/resource-explorer.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/resourceexplorer2/ResourceExplorer2Controller.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java, mode: rest } + - { path: services/resourceexplorer2/ResourceExplorer2Controller.java, mode: rest } + - { path: core/common/SharedTagsController.java, mode: rest } rename_actions: ListTags: ListTagsForResource TagResourcePost: TagResource @@ -254,8 +257,8 @@ services: - service: fis doc: docs/services/fis.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/fis/FisController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java, mode: rest } + - { path: services/fis/FisController.java, mode: rest } + - { path: core/common/SharedTagsController.java, mode: rest } rename_actions: ListTags: ListTagsForResource TagResourcePost: TagResource @@ -267,55 +270,55 @@ services: - service: kinesis doc: docs/services/kinesis.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/kinesis/KinesisJsonHandler.java, mode: switch } + - { path: services/kinesis/KinesisJsonHandler.java, mode: switch } - service: kinesisanalytics doc: docs/services/kinesisanalytics.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/kinesisanalytics/KinesisAnalyticsV2JsonHandler.java, mode: switch } + - { path: services/kinesisanalytics/KinesisAnalyticsV2JsonHandler.java, mode: switch } - service: kms doc: docs/services/kms.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/kms/KmsJsonHandler.java, mode: switch } + - { path: services/kms/KmsJsonHandler.java, mode: switch } - service: memorydb doc: docs/services/memorydb.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/memorydb/MemoryDbHandler.java, mode: switch } + - { path: services/memorydb/MemoryDbHandler.java, mode: switch } - service: macie2 doc: docs/services/macie2.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/macie2/MacieController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/services/securityadmin/SecurityAdminController.java, mode: rest } + - { path: services/macie2/MacieController.java, mode: rest } + - { path: services/securityadmin/SecurityAdminController.java, mode: rest } rename_actions: ListAdmin: ListOrganizationAdminAccounts - service: resource-groups doc: docs/services/resource-groups.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/resourcegroups/ResourceGroupsController.java, mode: rest } + - { path: services/resourcegroups/ResourceGroupsController.java, mode: rest } - service: inspector2 doc: docs/services/inspector2.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/inspector2/Inspector2Controller.java, mode: rest } + - { path: services/inspector2/Inspector2Controller.java, mode: rest } - service: neptune doc: docs/services/neptune.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/neptune/NeptuneQueryHandler.java, mode: switch } + - { path: services/neptune/NeptuneQueryHandler.java, mode: switch } - service: networkfirewall doc: docs/services/network-firewall.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/networkfirewall/NetworkFirewallJsonHandler.java, mode: switch } + - { path: services/networkfirewall/NetworkFirewallJsonHandler.java, mode: switch } - service: ram doc: docs/services/ram.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/ram/RamController.java, mode: rest } + - { path: services/ram/RamController.java, mode: rest } - service: rds doc: docs/services/rds.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/rds/RdsQueryHandler.java, mode: switch } + - { path: services/rds/RdsQueryHandler.java, mode: switch } exclude_actions: [SubnetIds, VpcSecurityGroupIds, OptionsToRemove, ValuesToAdd, ValuesToRemove] - service: redshift doc: docs/services/redshift.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandler.java, mode: switch } + - { path: services/redshift/RedshiftQueryHandler.java, mode: switch } # SubnetIds / VpcSecurityGroupIds / IamRoles / AddIamRoles / RemoveIamRoles / TagKeys / TagValues / # DbGroups / ScheduleDefinitions are labels of an inner member-name switch (memberKeyRegex), not # actions, same shape as the rds exclusions above. @@ -323,31 +326,31 @@ services: - service: redshiftdata doc: docs/services/redshift-data.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/redshiftdata/RedshiftDataJsonHandler.java, mode: switch } + - { path: services/redshiftdata/RedshiftDataJsonHandler.java, mode: switch } # ExecuteSql / BatchExecuteSql are the deprecated pre-2020 operations: the handler # recognizes them only to return a ValidationException, they are not supported actions. exclude_actions: [ExecuteSql, BatchExecuteSql] - service: redshiftserverless doc: docs/services/redshift-serverless.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/redshiftserverless/RedshiftServerlessJsonHandler.java, mode: switch } - - { path: src/main/java/io/github/hectorvent/floci/services/redshiftserverless/RedshiftServerlessAdminJsonHandler.java, mode: switch } + - { path: services/redshiftserverless/RedshiftServerlessJsonHandler.java, mode: switch } + - { path: services/redshiftserverless/RedshiftServerlessAdminJsonHandler.java, mode: switch } - service: cognitoidentity doc: docs/services/cognitoidentity.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/cognitoidentity/CognitoIdentityJsonHandler.java, mode: switch } + - { path: services/cognitoidentity/CognitoIdentityJsonHandler.java, mode: switch } - service: globalaccelerator doc: docs/services/globalaccelerator.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorJsonHandler.java, mode: switch } + - { path: services/globalaccelerator/GlobalAcceleratorJsonHandler.java, mode: switch } - service: datasync doc: docs/services/datasync.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/datasync/DataSyncJsonHandler.java, mode: switch } + - { path: services/datasync/DataSyncJsonHandler.java, mode: switch } - service: route53 doc: docs/services/route53.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/route53/Route53Controller.java, mode: rest } + - { path: services/route53/Route53Controller.java, mode: rest } # JAX-RS method names use Java casing; map them onto the canonical Route 53 action names. rename_actions: AssociateVpcWithHostedZone: AssociateVPCWithHostedZone @@ -360,16 +363,16 @@ services: - service: route53resolver doc: docs/services/route53resolver.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/route53resolver/Route53ResolverJsonHandler.java, mode: switch } + - { path: services/route53resolver/Route53ResolverJsonHandler.java, mode: switch } - service: sagemaker doc: docs/services/sagemaker.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/sagemaker/SageMakerJsonHandler.java, mode: switch } + - { path: services/sagemaker/SageMakerJsonHandler.java, mode: switch } - service: securityhub doc: docs/services/securityhub.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/securityhub/SecurityHubController.java, mode: rest } - - { path: src/main/java/io/github/hectorvent/floci/core/common/SharedTagsController.java, mode: rest } + - { path: services/securityhub/SecurityHubController.java, mode: rest } + - { path: core/common/SharedTagsController.java, mode: rest } rename_actions: ListTags: ListTagsForResource TagResourcePost: TagResource @@ -381,92 +384,92 @@ services: - service: secretsmanager doc: docs/services/secrets-manager.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/secretsmanager/SecretsManagerJsonHandler.java, mode: switch } + - { path: services/secretsmanager/SecretsManagerJsonHandler.java, mode: switch } - service: servicecatalog doc: docs/services/service-catalog.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/servicecatalog/ServiceCatalogJsonHandler.java, mode: switch } + - { path: services/servicecatalog/ServiceCatalogJsonHandler.java, mode: switch } - service: servicequotas doc: docs/services/servicequotas.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/servicequotas/ServiceQuotasJsonHandler.java, mode: switch } + - { path: services/servicequotas/ServiceQuotasJsonHandler.java, mode: switch } - service: ssoadmin doc: docs/services/ssoadmin.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminJsonHandler.java, mode: switch } + - { path: services/ssoadmin/SsoAdminJsonHandler.java, mode: switch } - service: identitystore doc: docs/services/identitystore.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/identitystore/IdentityStoreJsonHandler.java, mode: switch } + - { path: services/identitystore/IdentityStoreJsonHandler.java, mode: switch } - service: budgets doc: docs/services/budgets.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/budgets/BudgetsJsonHandler.java, mode: switch } + - { path: services/budgets/BudgetsJsonHandler.java, mode: switch } - service: verifiedpermissions doc: docs/services/verifiedpermissions.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/verifiedpermissions/VerifiedPermissionsJsonHandler.java, mode: switch } + - { path: services/verifiedpermissions/VerifiedPermissionsJsonHandler.java, mode: switch } - service: timestream-influxdb doc: docs/services/timestream-influxdb.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/timestreaminfluxdb/TimestreamInfluxDbJsonHandler.java, mode: switch } + - { path: services/timestreaminfluxdb/TimestreamInfluxDbJsonHandler.java, mode: switch } - service: sqs doc: docs/services/sqs.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/sqs/SqsJsonHandler.java, mode: switch } - - { path: src/main/java/io/github/hectorvent/floci/services/sqs/SqsQueryHandler.java, mode: switch } + - { path: services/sqs/SqsJsonHandler.java, mode: switch } + - { path: services/sqs/SqsQueryHandler.java, mode: switch } - service: stepfunctions doc: docs/services/step-functions.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/stepfunctions/StepFunctionsJsonHandler.java, mode: switch } + - { path: services/stepfunctions/StepFunctionsJsonHandler.java, mode: switch } - service: swf doc: docs/services/swf.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/swf/SwfJsonHandler.java, mode: switch } + - { path: services/swf/SwfJsonHandler.java, mode: switch } - service: wafv2 doc: docs/services/wafv2.md sources: - - { path: src/main/java/io/github/hectorvent/floci/services/wafv2/WafV2Handler.java, mode: switch } + - { path: services/wafv2/WafV2Handler.java, mode: switch } # Switch handlers that exist but are intentionally not yet covered (see reasons). # A NEW switch handler not listed here and not registered above fails `--strict`. deferred_handlers: - - { path: src/main/java/io/github/hectorvent/floci/services/apigatewayv2/ApiGatewayV2JsonHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/applicationautoscaling/ScalingPolicyAlarmActionHandler.java } # not a JSON/Query action dispatcher — its `case "X" ->` arms are the StepScaling AdjustmentType switch, not AWS actions - - { path: src/main/java/io/github/hectorvent/floci/services/autoscaling/AutoScalingQueryHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/bcmpricingcalculator/BcmPricingCalculatorJsonHandler.java } # focused workload-estimate surface - - { path: src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsJsonHandler.java } # no standalone action table yet - - { path: src/main/java/io/github/hectorvent/floci/services/cloudcontrol/CloudControlJsonHandler.java } # no standalone action table yet - - { path: src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/CloudWatchLogsHandler.java } # multi-table doc (nested handler) - - { path: src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/CloudWatchLogsMetricFilterHandler.java } # multi-table doc (nested handler, reached through CloudWatchLogsHandler) - - { path: src/main/java/io/github/hectorvent/floci/services/cloudwatch/metrics/CloudWatchMetricsJsonHandler.java } # multi-table doc (nested handler) - - { path: src/main/java/io/github/hectorvent/floci/services/cloudwatch/metrics/CloudWatchMetricsQueryHandler.java } # multi-table doc (nested handler) - - { path: src/main/java/io/github/hectorvent/floci/services/codebuild/CodeBuildJsonHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployJsonHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/cognito/CognitoJsonHandler.java } # non-tabular doc (grouped/inline); separate docs effort - - { path: src/main/java/io/github/hectorvent/floci/services/configservice/ConfigServiceJsonHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/cur/CurJsonHandler.java } # no standalone action table yet - - { path: src/main/java/io/github/hectorvent/floci/services/dynamodb/NativeDynamoDbJsonHandler.java } # multi-table doc - - { path: src/main/java/io/github/hectorvent/floci/services/dynamodb/NativeDynamoDbStreamsJsonHandler.java } # multi-table doc - - { path: src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/ecr/EcrJsonHandler.java } # doc packs multiple actions per row (`A` / `B`) + REST endpoints; needs de-grouping - - { path: src/main/java/io/github/hectorvent/floci/services/ecs/EcsJsonHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/elasticbeanstalk/ElasticBeanstalkQueryHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/elb/ElbClassicQueryHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2QueryHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/glue/GlueJsonHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/iam/IamQueryHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/iam/StsQueryHandler.java } # sts (lives in iam package); single-table, registerable next - - { path: src/main/java/io/github/hectorvent/floci/services/lakeformation/LakeFormationJsonHandler.java } # no standalone action table yet - - { path: src/main/java/io/github/hectorvent/floci/services/lightsail/LightsailJsonHandler.java } # non-tabular doc (grouped/inline); standalone action table to be added - - { path: src/main/java/io/github/hectorvent/floci/services/pricing/PricingJsonHandler.java } # no standalone action table yet - - { path: src/main/java/io/github/hectorvent/floci/services/resourcegroupstagging/ResourceGroupsTaggingJsonHandler.java } # non-tabular doc (grouped/inline) - - { path: src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java } # mixed-mode (Query + REST surface) - - { path: src/main/java/io/github/hectorvent/floci/services/sns/SnsJsonHandler.java } # multi-table doc - - { path: src/main/java/io/github/hectorvent/floci/services/sns/SnsQueryHandler.java } # multi-table doc - - { path: src/main/java/io/github/hectorvent/floci/services/ssm/Ec2MessagesJsonHandler.java } # multi-table doc - - { path: src/main/java/io/github/hectorvent/floci/services/ssm/SsmJsonHandler.java } # multi-table doc - - { path: src/main/java/io/github/hectorvent/floci/services/textract/TextractJsonHandler.java } # no standalone action table yet - - { path: src/main/java/io/github/hectorvent/floci/services/transcribe/TranscribeJsonHandler.java } # no standalone action table yet - - { path: src/main/java/io/github/hectorvent/floci/services/transfer/TransferHandler.java } # multi-table doc + - { path: services/apigatewayv2/ApiGatewayV2JsonHandler.java } # non-tabular doc (grouped/inline) + - { path: services/applicationautoscaling/ScalingPolicyAlarmActionHandler.java } # not a JSON/Query action dispatcher — its `case "X" ->` arms are the StepScaling AdjustmentType switch, not AWS actions + - { path: services/autoscaling/AutoScalingQueryHandler.java } # non-tabular doc (grouped/inline) + - { path: services/bcmpricingcalculator/BcmPricingCalculatorJsonHandler.java } # focused workload-estimate surface + - { path: services/bcmdataexports/BcmDataExportsJsonHandler.java } # no standalone action table yet + - { path: services/cloudcontrol/CloudControlJsonHandler.java } # no standalone action table yet + - { path: services/cloudmap/CloudMapHandler.java } # non-tabular doc (grouped/inline) + - { path: services/cloudwatch/logs/CloudWatchLogsHandler.java } # multi-table doc (nested handler) + - { path: services/cloudwatch/logs/CloudWatchLogsMetricFilterHandler.java } # multi-table doc (nested handler, reached through CloudWatchLogsHandler) + - { path: services/cloudwatch/metrics/CloudWatchMetricsJsonHandler.java } # multi-table doc (nested handler) + - { path: services/cloudwatch/metrics/CloudWatchMetricsQueryHandler.java } # multi-table doc (nested handler) + - { path: services/codebuild/CodeBuildJsonHandler.java } # non-tabular doc (grouped/inline) + - { path: services/codedeploy/CodeDeployJsonHandler.java } # non-tabular doc (grouped/inline) + - { path: services/cognito/CognitoJsonHandler.java } # non-tabular doc (grouped/inline); separate docs effort + - { path: services/configservice/ConfigServiceJsonHandler.java } # non-tabular doc (grouped/inline) + - { path: services/cur/CurJsonHandler.java } # no standalone action table yet + - { path: services/dynamodb/NativeDynamoDbJsonHandler.java } # multi-table doc + - { path: services/dynamodb/NativeDynamoDbStreamsJsonHandler.java } # multi-table doc + - { path: services/ec2/Ec2QueryHandler.java } # non-tabular doc (grouped/inline) + - { path: services/ecr/EcrJsonHandler.java } # doc packs multiple actions per row (`A` / `B`) + REST endpoints; needs de-grouping + - { path: services/ecs/EcsJsonHandler.java } # non-tabular doc (grouped/inline) + - { path: services/elasticbeanstalk/ElasticBeanstalkQueryHandler.java } # non-tabular doc (grouped/inline) + - { path: services/elb/ElbClassicQueryHandler.java } # non-tabular doc (grouped/inline) + - { path: services/elbv2/ElbV2QueryHandler.java } # non-tabular doc (grouped/inline) + - { path: services/glue/GlueJsonHandler.java } # non-tabular doc (grouped/inline) + - { path: services/iam/IamQueryHandler.java } # non-tabular doc (grouped/inline) + - { path: services/iam/StsQueryHandler.java } # sts (lives in iam package); single-table, registerable next + - { path: services/lakeformation/LakeFormationJsonHandler.java } # no standalone action table yet + - { path: services/lightsail/LightsailJsonHandler.java } # non-tabular doc (grouped/inline); standalone action table to be added + - { path: services/pricing/PricingJsonHandler.java } # no standalone action table yet + - { path: services/resourcegroupstagging/ResourceGroupsTaggingJsonHandler.java } # non-tabular doc (grouped/inline) + - { path: services/ses/SesQueryHandler.java } # mixed-mode (Query + REST surface) + - { path: services/sns/SnsJsonHandler.java } # multi-table doc + - { path: services/sns/SnsQueryHandler.java } # multi-table doc + - { path: services/ssm/Ec2MessagesJsonHandler.java } # multi-table doc + - { path: services/ssm/SsmJsonHandler.java } # multi-table doc + - { path: services/textract/TextractJsonHandler.java } # no standalone action table yet + - { path: services/transcribe/TranscribeJsonHandler.java } # no standalone action table yet + - { path: services/transfer/TransferHandler.java } # multi-table doc diff --git a/tools/docs/test_check_service_matrix.py b/tools/docs/test_check_service_matrix.py index d618217353..fd94418f20 100644 --- a/tools/docs/test_check_service_matrix.py +++ b/tools/docs/test_check_service_matrix.py @@ -139,7 +139,7 @@ Another link to [SQS](sqs.md). ]) def test_non_tabular_action_counts_follow_dispatcher(slug, handler): root = c._repo_root() - source = root / "src/main/java/io/github/hectorvent/floci/services" / handler + source = root / c.PACKAGE_DIR / "services" / handler expected = len(set(c.regen_action_docs.extract_switch_actions( source.read_text(encoding="utf-8") ))) @@ -156,8 +156,8 @@ def test_non_tabular_action_count_tracks_new_dispatch_cases(tmp_path): ) registry = tmp_path / "tools/docs/service_matrix.yaml" registry.parent.mkdir(parents=True) - registry.write_text("action_count_sources:\n glue: src/GlueJsonHandler.java\n", encoding="utf-8") - handler = tmp_path / "src/GlueJsonHandler.java" + registry.write_text("action_count_sources:\n glue: services/GlueJsonHandler.java\n", encoding="utf-8") + handler = tmp_path / c.PACKAGE_DIR / "services/GlueJsonHandler.java" handler.parent.mkdir(parents=True) handler.write_text( 'case "CreateTable" -> create();\ncase "GetTable" -> get();\n', @@ -189,8 +189,8 @@ def test_generated_action_table_requires_numeric_matrix_count(tmp_path): ) registry = tmp_path / "tools/docs/service_matrix.yaml" registry.parent.mkdir(parents=True) - registry.write_text("action_count_sources:\n glue: src/GlueJsonHandler.java\n", encoding="utf-8") - handler = tmp_path / "src/GlueJsonHandler.java" + registry.write_text("action_count_sources:\n glue: services/GlueJsonHandler.java\n", encoding="utf-8") + handler = tmp_path / c.PACKAGE_DIR / "services/GlueJsonHandler.java" handler.parent.mkdir(parents=True) handler.write_text('case "CreateTable" -> create();\ncase "GetTable" -> get();\n', encoding="utf-8") @@ -225,11 +225,11 @@ def test_non_tabular_action_source_cannot_be_removed_silently(tmp_path): registry = tmp_path / "tools/docs/service_matrix.yaml" registry.parent.mkdir(parents=True) registry.write_text( - "action_count_sources:\n glue: src/GlueJsonHandler.java\n" - " ec2: src/Ec2QueryHandler.java\n", encoding="utf-8", + "action_count_sources:\n glue: services/GlueJsonHandler.java\n" + " ec2: services/Ec2QueryHandler.java\n", encoding="utf-8", ) - source_dir = tmp_path / "src" - source_dir.mkdir() + source_dir = tmp_path / c.PACKAGE_DIR / "services" + source_dir.mkdir(parents=True) (source_dir / "GlueJsonHandler.java").write_text( 'case "CreateTable" -> create();\ncase "GetTable" -> get();\n', encoding="utf-8", ) @@ -239,7 +239,7 @@ def test_non_tabular_action_source_cannot_be_removed_silently(tmp_path): required = frozenset({"glue", "ec2"}) assert c.extract_action_counts(tmp_path, required) == {"glue": 2, "ec2": 1} - registry.write_text("action_count_sources:\n glue: src/GlueJsonHandler.java\n", encoding="utf-8") + registry.write_text("action_count_sources:\n glue: services/GlueJsonHandler.java\n", encoding="utf-8") with pytest.raises(ValueError, match="required action count source\\(s\\) missing: ec2"): c.extract_action_counts(tmp_path, required) @@ -354,3 +354,20 @@ def test_find_unlinked_pages_ignores_non_markdown(tmp_path): (tmp_path / "ssm.md").write_text("# page\n") (tmp_path / "diagram.svg").write_text("") assert c.find_unlinked_pages(tmp_path, slugs={"ssm"}, facet_pages=set()) == [] + + +def test_action_count_source_paths_are_relative_to_the_package_root(tmp_path): + matrix = tmp_path / "docs/services/index.md" + matrix.parent.mkdir(parents=True) + matrix.write_text( + "## Service Matrix\n\n| [Glue](glue.md) | Query | JSON | 2 |\n\n## Common Setup\n", + encoding="utf-8", + ) + registry = tmp_path / "tools/docs/service_matrix.yaml" + registry.parent.mkdir(parents=True) + registry.write_text( + f"action_count_sources:\n glue: {c.PACKAGE_DIR}/services/GlueJsonHandler.java\n", encoding="utf-8", + ) + + with pytest.raises(ValueError, match="relative to"): + c.extract_action_counts(tmp_path) diff --git a/tools/java_sources.py b/tools/java_sources.py new file mode 100644 index 0000000000..9ef81b90c8 --- /dev/null +++ b/tools/java_sources.py @@ -0,0 +1,19 @@ +"""Where Floci's Java sources live: the one place the tools under tools/ name the Java package. + +Tools import the paths from here instead of writing src/main/java//... themselves, so a +package rename changes this file and nothing else in tools/. Registries that list source files +(tools/docs/services.yaml, tools/docs/service_matrix.yaml) hold paths relative to PACKAGE_DIR. +""" +from __future__ import annotations + +SOURCE_ROOT = "src/main/java" +PACKAGE_DIR = f"{SOURCE_ROOT}/io/github/hectorvent/floci" +SERVICES_PACKAGE_DIR = f"{PACKAGE_DIR}/services" + + +def package_source(relative: str) -> str: + """The repo-relative path of a source file a registry lists relative to PACKAGE_DIR.""" + if relative.startswith(("src/", "/")): + raise ValueError(f"{relative}: registry paths are relative to {PACKAGE_DIR}/, " + f"for example services/sqs/SqsJsonHandler.java") + return f"{PACKAGE_DIR}/{relative}" diff --git a/tools/partition/partition_literals.py b/tools/partition/partition_literals.py index 8158924e62..5fc30263ba 100644 --- a/tools/partition/partition_literals.py +++ b/tools/partition/partition_literals.py @@ -45,9 +45,12 @@ from pathlib import Path import yaml +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +from java_sources import PACKAGE_DIR, SOURCE_ROOT as SOURCE_DIR # noqa: E402 + REPO_ROOT = Path(__file__).resolve().parents[2] -SOURCE_ROOT = REPO_ROOT / "src/main/java" -PACKAGE_ROOT = SOURCE_ROOT / "io/github/hectorvent/floci" +SOURCE_ROOT = REPO_ROOT / SOURCE_DIR +PACKAGE_ROOT = REPO_ROOT / PACKAGE_DIR TOOL_DIR = Path(__file__).resolve().parent ALLOWLIST = TOOL_DIR / "allowlist.yaml" BASELINE = TOOL_DIR / "baseline.tsv" diff --git a/tools/partition/test_partition_literals.py b/tools/partition/test_partition_literals.py index be9d6dc2b0..7186a32d7b 100644 --- a/tools/partition/test_partition_literals.py +++ b/tools/partition/test_partition_literals.py @@ -476,10 +476,11 @@ def test_check_treats_an_escaped_literal_as_absent(tmp_path): # Audit and CLI # --------------------------------------------------------------------------- # def test_package_of_groups_by_service_and_falls_back_to_the_parent(): - assert p.package_of("src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java") == "services/s3" - assert p.package_of("src/main/java/io/github/hectorvent/floci/core/common/AwsArnUtils.java") == "core/common" - assert p.package_of("src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java") == "config" - assert p.package_of("src/main/java/io/github/hectorvent/floci/services/s3/model/Bucket.java") == "services/s3" + root = p.PACKAGE_ROOT.relative_to(p.REPO_ROOT).as_posix() + assert p.package_of(f"{root}/services/s3/S3Service.java") == "services/s3" + assert p.package_of(f"{root}/core/common/AwsArnUtils.java") == "core/common" + assert p.package_of(f"{root}/config/EmulatorConfig.java") == "config" + assert p.package_of(f"{root}/services/s3/model/Bucket.java") == "services/s3" assert p.package_of("elsewhere/x/Y.java") == "elsewhere/x"