From 1543c0cc406e8f83c81eca2a111342049672518f Mon Sep 17 00:00:00 2001 From: "Anthony T. Lannutti" Date: Wed, 5 Aug 2026 10:13:26 -0500 Subject: [PATCH 1/3] feat: add Datadog schema hooks - Add check-datadog-continuous-testing hook for datadog-ci.(json|yml|yaml) - Add check-datadog-service-definition hook for service.datadog.(json|yml|yaml) - Add check-datadog-software-catalog hook for entity.datadog.(json|yml|yaml) All three schemas are from DataDog/schema repository under Apache 2.0 license. Schemas support remote $ref dependencies which are resolved automatically. --- .pre-commit-hooks.yaml | 33 + CHANGELOG.rst | 3 + docs/precommit_usage.rst | 42 ++ docs/usage.rst | 3 + .../vendor/datadog-continuous-testing.json | 573 ++++++++++++++++++ .../vendor/datadog-service-definition.json | 131 ++++ .../vendor/datadog-software-catalog.json | 148 +++++ .../vendor/licenses/LICENSE.datadog | 176 ++++++ .../sha256/datadog-continuous-testing.sha256 | 1 + .../sha256/datadog-service-definition.sha256 | 1 + .../sha256/datadog-software-catalog.sha256 | 1 + src/check_jsonschema/catalog.py | 39 ++ tests/acceptance/test_hook_file_matches.py | 44 ++ 13 files changed, 1195 insertions(+) create mode 100644 src/check_jsonschema/builtin_schemas/vendor/datadog-continuous-testing.json create mode 100644 src/check_jsonschema/builtin_schemas/vendor/datadog-service-definition.json create mode 100644 src/check_jsonschema/builtin_schemas/vendor/datadog-software-catalog.json create mode 100644 src/check_jsonschema/builtin_schemas/vendor/licenses/LICENSE.datadog create mode 100644 src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-continuous-testing.sha256 create mode 100644 src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-service-definition.sha256 create mode 100644 src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-software-catalog.sha256 diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 28a2597d5..f3dcbc7b4 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -139,6 +139,39 @@ )$ types: [yaml] +# this hook is autogenerated from a script +# to modify this hook, update `src/check_jsonschema/catalog.py` +# and run `just generate-hooks` or `tox run -e generate-hooks-config` +- id: check-datadog-continuous-testing + name: Validate Datadog Continuous Testing config + description: 'Validate Datadog Continuous Testing config against the schema provided by SchemaStore' + entry: check-jsonschema --builtin-schema vendor.datadog-continuous-testing + language: python + files: (^|.*/)datadog-ci\.(json|ya?ml)$ + types_or: [json,yaml] + +# this hook is autogenerated from a script +# to modify this hook, update `src/check_jsonschema/catalog.py` +# and run `just generate-hooks` or `tox run -e generate-hooks-config` +- id: check-datadog-service-definition + name: Validate Datadog Service Definition + description: 'Validate Datadog Service Definition against the schema provided by SchemaStore' + entry: check-jsonschema --builtin-schema vendor.datadog-service-definition + language: python + files: (^|.*/)service\.datadog\.(json|ya?ml)$ + types_or: [json,yaml] + +# this hook is autogenerated from a script +# to modify this hook, update `src/check_jsonschema/catalog.py` +# and run `just generate-hooks` or `tox run -e generate-hooks-config` +- id: check-datadog-software-catalog + name: Validate Datadog Software Catalog entity + description: 'Validate Datadog Software Catalog entity against the schema provided by SchemaStore' + entry: check-jsonschema --builtin-schema vendor.datadog-software-catalog + language: python + files: (^|.*/)entity\.datadog\.(json|ya?ml)$ + types_or: [json,yaml] + # this hook is autogenerated from a script # to modify this hook, update `src/check_jsonschema/catalog.py` # and run `just generate-hooks` or `tox run -e generate-hooks-config` diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4630b456a..3da0c0cb4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,9 @@ CHANGELOG Unreleased ---------- +- Add Datadog schema hooks: ``check-datadog-continuous-testing``, + ``check-datadog-service-definition``, and ``check-datadog-software-catalog`` + .. vendor-insert-here - Add a dedicated ``check-github-workflows-require-timeout`` pre-commit hook for diff --git a/docs/precommit_usage.rst b/docs/precommit_usage.rst index 6a44ee65e..f4ecfcc23 100644 --- a/docs/precommit_usage.rst +++ b/docs/precommit_usage.rst @@ -183,6 +183,48 @@ Validate Docker Compose files against the schema provided by SchemaStore - id: check-compose-spec +``check-datadog-continuous-testing`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Validate Datadog Continuous Testing config against the schema provided by SchemaStore + +.. code-block:: yaml + :caption: example config + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.37.4 + hooks: + - id: check-datadog-continuous-testing + + +``check-datadog-service-definition`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Validate Datadog Service Definition against the schema provided by SchemaStore + +.. code-block:: yaml + :caption: example config + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.37.4 + hooks: + - id: check-datadog-service-definition + + +``check-datadog-software-catalog`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Validate Datadog Software Catalog entity against the schema provided by SchemaStore + +.. code-block:: yaml + :caption: example config + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.37.4 + hooks: + - id: check-datadog-software-catalog + + ``check-dependabot`` ~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/usage.rst b/docs/usage.rst index 3031c9921..b2085f0ee 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -96,6 +96,9 @@ SchemaStore and other sources: - ``vendor.cloudbuild`` - ``vendor.codecov`` - ``vendor.compose-spec`` +- ``vendor.datadog-continuous-testing`` +- ``vendor.datadog-service-definition`` +- ``vendor.datadog-software-catalog`` - ``vendor.dependabot`` - ``vendor.drone-ci`` - ``vendor.github-actions`` diff --git a/src/check_jsonschema/builtin_schemas/vendor/datadog-continuous-testing.json b/src/check_jsonschema/builtin_schemas/vendor/datadog-continuous-testing.json new file mode 100644 index 000000000..f319ff53a --- /dev/null +++ b/src/check_jsonschema/builtin_schemas/vendor/datadog-continuous-testing.json @@ -0,0 +1,573 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "Assertion": { + "properties": { + "actual": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + }, + { + "format": "date-time", + "type": "string" + }, + { + "type": "object" + } + ] + }, + "errorMessage": { + "type": "string" + }, + "operator": { + "$ref": "#/definitions/Operator" + }, + "property": { + "type": "string" + }, + "target": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + }, + { + "format": "date-time", + "type": "string" + }, + { + "type": "object" + } + ] + }, + "type": { + "type": "string" + }, + "valid": { + "type": "boolean" + } + }, + "required": [ + "actual", + "operator", + "target", + "type", + "valid" + ], + "type": "object" + }, + "BasicAuthCredentials": { + "properties": { + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "required": [ + "password", + "username" + ], + "type": "object" + }, + "CookiesObject": { + "properties": { + "append": { + "description": "Whether to append or replace the original cookies.", + "markdownDescription": "Whether to append or replace the original cookies.", + "type": "boolean" + }, + "value": { + "description": "Cookie header to add or replace (e.g. `name1=value1;name2=value2;`).", + "markdownDescription": "Cookie header to add or replace (e.g. `name1=value1;name2=value2;`).", + "type": "string" + } + }, + "required": [ + "value" + ], + "type": "object" + }, + "ExecutionRule": { + "enum": [ + "blocking", + "non_blocking", + "skipped" + ], + "type": "string" + }, + "LocalTestDefinition": { + "properties": { + "config": { + "properties": { + "assertions": { + "items": { + "$ref": "#/definitions/Assertion" + }, + "type": "array" + }, + "request": { + "properties": { + "dnsServer": { + "type": "string" + }, + "headers": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + }, + "host": { + "type": "string" + }, + "method": { + "type": "string" + }, + "port": { + "type": "number" + }, + "timeout": { + "type": "number" + }, + "url": { + "type": "string" + } + }, + "required": [ + "headers", + "method", + "timeout", + "url" + ], + "type": "object" + }, + "steps": { + "items": { + "properties": { + "subtype": { + "type": "string" + } + }, + "required": [ + "subtype" + ], + "type": "object" + }, + "type": "array" + }, + "variables": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "assertions", + "variables" + ], + "type": "object" + }, + "locations": { + "items": { + "type": "string" + }, + "type": "array" + }, + "name": { + "type": "string" + }, + "options": { + "$ref": "#/definitions/OptionsWithUnsupportedFields" + }, + "public_id": { + "description": "Can be used to link to an existing remote test.", + "markdownDescription": "Can be used to link to an existing remote test.", + "type": "string" + }, + "steps": { + "items": { + "$ref": "#/definitions/TestStepWithUnsupportedFields" + }, + "type": "array" + }, + "subtype": { + "type": "string" + }, + "type": { + "enum": [ + "api", + "browser", + "mobile" + ], + "type": "string" + } + }, + "required": [ + "config", + "locations", + "name", + "options", + "type" + ], + "type": "object" + }, + "LocalTriggerConfig": { + "properties": { + "localTestDefinition": { + "$ref": "#/definitions/LocalTestDefinition" + }, + "suite": { + "description": "Name of a test suite (for JUnit reports).", + "markdownDescription": "Name of a test suite (for JUnit reports).", + "type": "string" + }, + "testOverrides": { + "$ref": "#/definitions/UserConfigOverride", + "description": "Overrides for this Synthetic test only. This takes precedence over all other overrides.", + "markdownDescription": "Overrides for this Synthetic test only. This takes precedence over all other overrides." + } + }, + "required": [ + "localTestDefinition" + ], + "type": "object" + }, + "MobileApplication": { + "properties": { + "applicationId": { + "type": "string" + }, + "referenceId": { + "type": "string" + }, + "referenceType": { + "enum": [ + "latest", + "version", + "temporary" + ], + "type": "string" + } + }, + "required": [ + "applicationId", + "referenceId", + "referenceType" + ], + "type": "object" + }, + "MultiLocator": { + "additionalProperties": {}, + "type": "object" + }, + "Operator": { + "enum": [ + "contains", + "doesNotContain", + "is", + "isNot", + "isInLessThan", + "isInMoreThan", + "lessThan", + "lessThanOrEqual", + "moreThan", + "moreThanOrEqual", + "matches", + "doesNotMatch", + "validatesJSONPath", + "validatesXPath" + ], + "type": "string" + }, + "OptionsWithUnsupportedFields": { + "properties": { + "bindings": { + "anyOf": [ + { + "type": "null" + }, + { + "items": {}, + "type": "array" + } + ] + }, + "ci": { + "properties": { + "executionRule": { + "$ref": "#/definitions/ExecutionRule" + } + }, + "required": [ + "executionRule" + ], + "type": "object" + }, + "device_ids": { + "items": { + "type": "string" + }, + "type": "array" + }, + "min_failure_duration": { + "type": "number" + }, + "min_location_failed": {}, + "mobileApplication": { + "$ref": "#/definitions/MobileApplication" + }, + "monitor_name": { + "type": "string" + }, + "monitor_options": {}, + "monitor_priority": { + "type": "number" + }, + "retry": { + "properties": { + "count": { + "type": "number" + } + }, + "type": "object" + }, + "tick_every": { + "type": "number" + } + }, + "type": "object" + }, + "RemoteTriggerConfig": { + "properties": { + "id": { + "description": "Public ID of a test (e.g. `abc-def-ghi`), or its full URL (e.g. `https://app.datadoghq.com/synthetics/details/abc-def-ghi`).", + "markdownDescription": "Public ID of a test (e.g. `abc-def-ghi`), or its full URL (e.g. `https://app.datadoghq.com/synthetics/details/abc-def-ghi`).", + "pattern": "^(https://.*)?([a-z2-9]{3}-[a-z2-9]{3}-[a-z2-9]{3})$", + "type": "string" + }, + "suite": { + "description": "Name of a test suite (for JUnit reports).", + "markdownDescription": "Name of a test suite (for JUnit reports).", + "type": "string" + }, + "testOverrides": { + "$ref": "#/definitions/UserConfigOverride", + "description": "Overrides for this Synthetic test only. This takes precedence over all other overrides.", + "markdownDescription": "Overrides for this Synthetic test only. This takes precedence over all other overrides." + } + }, + "required": [ + "id" + ], + "type": "object" + }, + "RetryConfig": { + "properties": { + "count": { + "description": "The number of attempts to perform in case of test failure.", + "markdownDescription": "The number of attempts to perform in case of test failure.", + "type": "number" + }, + "interval": { + "description": "The interval between attempts in milliseconds.", + "markdownDescription": "The interval between attempts in milliseconds.", + "type": "number" + } + }, + "required": [ + "count", + "interval" + ], + "type": "object" + }, + "TestStepWithUnsupportedFields": { + "properties": { + "params": { + "properties": { + "element": { + "properties": { + "multiLocator": { + "$ref": "#/definitions/MultiLocator" + }, + "userLocator": {} + }, + "type": "object" + } + }, + "type": "object" + }, + "public_id": { + "type": "string" + } + }, + "required": [ + "params" + ], + "type": "object" + }, + "TriggerConfig": { + "anyOf": [ + { + "$ref": "#/definitions/RemoteTriggerConfig" + }, + { + "$ref": "#/definitions/LocalTriggerConfig" + } + ] + }, + "UserConfigOverride": { + "properties": { + "allowInsecureCertificates": { + "description": "Override the certificate checks in Synthetic API and Browser tests.", + "markdownDescription": "Override the certificate checks in Synthetic API and Browser tests.", + "type": "boolean" + }, + "basicAuth": { + "$ref": "#/definitions/BasicAuthCredentials", + "description": "Override the credentials for basic authentication.", + "markdownDescription": "Override the credentials for basic authentication." + }, + "body": { + "description": "Override the data to send in API tests.", + "markdownDescription": "Override the data to send in API tests.", + "type": "string" + }, + "bodyType": { + "description": "Override the content type for the data to send in API tests.", + "markdownDescription": "Override the content type for the data to send in API tests.", + "type": "string" + }, + "cookies": { + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/definitions/CookiesObject" + } + ], + "description": "Override the cookies for API and browser tests.\n- If this is a string, it is used to replace the original cookies.\n- If this is an object, the format must be `{append?: boolean, value: string}`, and depending on the value of `append`, it is appended or replaces the original cookies.", + "markdownDescription": "Override the cookies for API and browser tests.\n- If this is a string, it is used to replace the original cookies.\n- If this is an object, the format must be `{append?: boolean, value: string}`, and depending on the value of `append`, it is appended or replaces the original cookies." + }, + "defaultStepTimeout": { + "description": "Override the maximum duration of steps in seconds for browser tests. This does not override individually set step timeouts.", + "markdownDescription": "Override the maximum duration of steps in seconds for browser tests. This does not override individually set step timeouts.", + "type": "number" + }, + "deviceIds": { + "description": "Override the list of devices on which to run the Synthetic tests.", + "items": { + "type": "string" + }, + "markdownDescription": "Override the list of devices on which to run the Synthetic tests.", + "type": "array" + }, + "executionRule": { + "$ref": "#/definitions/ExecutionRule", + "description": "Override the execution rule for Synthetic tests.\n\nThe execution rule for the test defines the behavior of the CI batch in case of a failing test. It accepts one of the following values:\n\n- `blocking`: A failed test causes the CI batch to fail.\n- `non_blocking`: A failed test does not cause the CI batch to fail.\n- `skipped`: The test is not run at all.", + "markdownDescription": "Override the execution rule for Synthetic tests.\n\nThe execution rule for the test defines the behavior of the CI batch in case of a failing test. It accepts one of the following values:\n\n- `blocking`: A failed test causes the CI batch to fail.\n- `non_blocking`: A failed test does not cause the CI batch to fail.\n- `skipped`: The test is not run at all." + }, + "followRedirects": { + "description": "Override whether or not to follow HTTP redirections in API tests.", + "markdownDescription": "Override whether or not to follow HTTP redirections in API tests.", + "type": "boolean" + }, + "headers": { + "additionalProperties": { + "type": "string" + }, + "description": "Override the headers in the API and browser tests.\n\nThis object specifies the headers to be replaced in the test. It should have keys representing the names of the headers to be replaced, and values indicating the new header values.", + "markdownDescription": "Override the headers in the API and browser tests.\n\nThis object specifies the headers to be replaced in the test. It should have keys representing the names of the headers to be replaced, and values indicating the new header values.", + "type": "object" + }, + "locations": { + "description": "Override the list of locations to run the test from. The possible values are listed [in this API response](https://app.datadoghq.com/api/v1/synthetics/locations?only_public=true).", + "items": { + "type": "string" + }, + "markdownDescription": "Override the list of locations to run the test from. The possible values are listed [in this API response](https://app.datadoghq.com/api/v1/synthetics/locations?only_public=true).", + "type": "array" + }, + "mobileApplicationVersion": { + "description": "Override the mobile application version for Synthetic mobile application tests. The version must be uploaded and available within Datadog.", + "markdownDescription": "Override the mobile application version for Synthetic mobile application tests. The version must be uploaded and available within Datadog.", + "type": "string" + }, + "mobileApplicationVersionFilePath": { + "description": "Override the application version for Synthetic mobile application tests.", + "markdownDescription": "Override the application version for Synthetic mobile application tests.", + "type": "string" + }, + "resourceUrlSubstitutionRegexes": { + "description": "An array of regex patterns to modify resource URLs in the test. This can be useful for dynamically changing resource URLs during test execution.\n\nEach regex pattern should be in the format:\n\n- **`your_regex|your_substitution`**: The pipe-based syntax, to avoid any conflicts with / characters in URLs. - For example, `https://example.com(.*)|http://subdomain.example.com$1` to transform `https://example.com/resource` to `http://subdomain.example.com/resource`.\n- **`s/your_regex/your_substitution/modifiers`**: The slash syntax, which supports modifiers. - For example, `s/(https://www.)(.*)/$1staging-$2/` to transform `https://www.example.com/resource` into `https://www.staging-example.com/resource`.", + "items": { + "type": "string" + }, + "markdownDescription": "An array of regex patterns to modify resource URLs in the test. This can be useful for dynamically changing resource URLs during test execution.\n\nEach regex pattern should be in the format:\n\n- **`your_regex|your_substitution`**: The pipe-based syntax, to avoid any conflicts with / characters in URLs.\n - For example, `https://example.com(.*)|http://subdomain.example.com$1` to transform `https://example.com/resource` to `http://subdomain.example.com/resource`.\n- **`s/your_regex/your_substitution/modifiers`**: The slash syntax, which supports modifiers.\n - For example, `s/(https://www.)(.*)/$1staging-$2/` to transform `https://www.example.com/resource` into `https://www.staging-example.com/resource`.", + "type": "array" + }, + "retry": { + "$ref": "#/definitions/RetryConfig", + "description": "Override the retry policy for the test.", + "markdownDescription": "Override the retry policy for the test." + }, + "setCookies": { + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/definitions/CookiesObject" + } + ], + "description": "Override the `Set-Cookie` headers in browser tests only.\n- If this is a string, it is used to replace the original `Set-Cookie` headers.\n- If this is an object, the format must be `{append?: boolean, value: string}`, and depending on the value of `append`, it is appended or replaces the original `Set-Cookie` headers.", + "markdownDescription": "Override the `Set-Cookie` headers in browser tests only.\n- If this is a string, it is used to replace the original `Set-Cookie` headers.\n- If this is an object, the format must be `{append?: boolean, value: string}`, and depending on the value of `append`, it is appended or replaces the original `Set-Cookie` headers." + }, + "startUrl": { + "description": "Override the start URL for API and browser tests.\n\nLocal and [global variables](https://docs.datadoghq.com/synthetics/platform/settings/?tab=specifyvalue#global-variables) specified in the URL (for example, `{{ URL }}`) are replaced when the test is run.\n\nYou can combine this with the `variables` override to override both the start URL and the variable values. For example:\n\n```bash\n--override startUrl=\"{{ URL }}?static_hash={{ STATIC_HASH }}\" --override variables.STATIC_HASH=abcdef ```", + "markdownDescription": "Override the start URL for API and browser tests.\n\nLocal and [global variables](https://docs.datadoghq.com/synthetics/platform/settings/?tab=specifyvalue#global-variables) specified in the URL (for example, `{{ URL }}`) are replaced when the test is run.\n\nYou can combine this with the `variables` override to override both the start URL and the variable values. For example:\n\n```bash\n--override startUrl=\"{{ URL }}?static_hash={{ STATIC_HASH }}\" --override variables.STATIC_HASH=abcdef\n```", + "type": "string" + }, + "startUrlSubstitutionRegex": { + "description": "A regex to modify the starting URL of browser and HTTP tests, whether it comes from the original test or the `startUrl` override.\n\nIf the URL contains variables, this regex applies after the interpolation of the variables.\n\nThere are two possible formats:\n\n- **`your_regex|your_substitution`**: The pipe-based syntax, to avoid any conflicts with `/` characters in URLs. - For example, `https://example.com(.*)|http://subdomain.example.com$1` to transform `https://example.com/test` to `http://subdomain.example.com/test`.\n- **`s/your_regex/your_substitution/modifiers`**: The slash syntax, which supports modifiers. - For example, `s/(https://www.)(.*)/$1extra-$2/` to transform `https://www.example.com` into `https://www.extra-example.com`.", + "markdownDescription": "A regex to modify the starting URL of browser and HTTP tests, whether it comes from the original test or the `startUrl` override.\n\nIf the URL contains variables, this regex applies after the interpolation of the variables.\n\nThere are two possible formats:\n\n- **`your_regex|your_substitution`**: The pipe-based syntax, to avoid any conflicts with `/` characters in URLs.\n - For example, `https://example.com(.*)|http://subdomain.example.com$1` to transform `https://example.com/test` to `http://subdomain.example.com/test`.\n- **`s/your_regex/your_substitution/modifiers`**: The slash syntax, which supports modifiers.\n - For example, `s/(https://www.)(.*)/$1extra-$2/` to transform `https://www.example.com` into `https://www.extra-example.com`.", + "type": "string" + }, + "testTimeout": { + "description": "Override the maximum duration in seconds for browser tests.", + "markdownDescription": "Override the maximum duration in seconds for browser tests.", + "type": "number" + }, + "variables": { + "additionalProperties": { + "type": "string" + }, + "description": "Override existing or inject new local and [global variables](https://docs.datadoghq.com/synthetics/platform/settings/?tab=specifyvalue#global-variables) in Synthetic tests.\n\nThis object should include keys corresponding to the names of the variables to be replaced, and values representing the new values for these variables.", + "markdownDescription": "Override existing or inject new local and [global variables](https://docs.datadoghq.com/synthetics/platform/settings/?tab=specifyvalue#global-variables) in Synthetic tests.\n\nThis object should include keys corresponding to the names of the variables to be replaced, and values representing the new values for these variables.", + "type": "object" + } + }, + "type": "object" + } + }, + "properties": { + "tests": { + "items": { + "$ref": "#/definitions/TriggerConfig" + }, + "type": "array" + } + }, + "required": [ + "tests" + ], + "type": "object" +} diff --git a/src/check_jsonschema/builtin_schemas/vendor/datadog-service-definition.json b/src/check_jsonschema/builtin_schemas/vendor/datadog-service-definition.json new file mode 100644 index 000000000..9266afadb --- /dev/null +++ b/src/check_jsonschema/builtin_schemas/vendor/datadog-service-definition.json @@ -0,0 +1,131 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/service.schema.json", + "title": "Service Definition Versions [v1, v2, v2.1, v2.2, v3]", + "oneOf": [ + { + "allOf": [ + { + "properties": { + "schema-version": { + "const": "v1" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v1/schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "schema-version": { + "const": "v2" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v2/schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "schema-version": { + "const": "v2.1" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v2.1/schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "schema-version": { + "const": "v2.2" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v2.2/schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "apiVersion": { + "const": "v3" + }, + "kind": { + "const": "service" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v3/service.schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "apiVersion": { + "const": "v3" + }, + "kind": { + "const": "queue" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v3/queue.schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "apiVersion": { + "const": "v3" + }, + "kind": { + "const": "datastore" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v3/datastore.schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "apiVersion": { + "const": "v3" + }, + "kind": { + "const": "system" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v3/system.schema.json" + } + ] + } + ] +} diff --git a/src/check_jsonschema/builtin_schemas/vendor/datadog-software-catalog.json b/src/check_jsonschema/builtin_schemas/vendor/datadog-software-catalog.json new file mode 100644 index 000000000..af0b588da --- /dev/null +++ b/src/check_jsonschema/builtin_schemas/vendor/datadog-software-catalog.json @@ -0,0 +1,148 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/entity.schema.json", + "title": "Software Catalog Definition Versions [v2, v2.1, v2.2, v3]", + "oneOf": [ + { + "allOf": [ + { + "properties": { + "schema-version": { + "const": "v2" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v2/schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "schema-version": { + "const": "v2.1" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v2.1/schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "schema-version": { + "const": "v2.2" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v2.2/schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "apiVersion": { + "const": "v3" + }, + "kind": { + "const": "service" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v3/service.schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "apiVersion": { + "const": "v3" + }, + "kind": { + "const": "queue" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v3/queue.schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "apiVersion": { + "const": "v3" + }, + "kind": { + "const": "datastore" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v3/datastore.schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "apiVersion": { + "const": "v3" + }, + "kind": { + "const": "api" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v3/api.schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "apiVersion": { + "const": "v3" + }, + "kind": { + "const": "system" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v3/system.schema.json" + } + ] + }, + { + "allOf": [ + { + "properties": { + "apiVersion": { + "const": "v3" + } + } + }, + { + "$ref": "https://raw.githubusercontent.com/DataDog/schema/main/service-catalog/v3/custom.schema.json" + } + ] + } + ] +} diff --git a/src/check_jsonschema/builtin_schemas/vendor/licenses/LICENSE.datadog b/src/check_jsonschema/builtin_schemas/vendor/licenses/LICENSE.datadog new file mode 100644 index 000000000..1b5ec8b78 --- /dev/null +++ b/src/check_jsonschema/builtin_schemas/vendor/licenses/LICENSE.datadog @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-continuous-testing.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-continuous-testing.sha256 new file mode 100644 index 000000000..792f1afe3 --- /dev/null +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-continuous-testing.sha256 @@ -0,0 +1 @@ +935079681dd9fb2a776b4ed208a1f669deefc7653f261272288a33552d0a15ed diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-service-definition.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-service-definition.sha256 new file mode 100644 index 000000000..328cdaf8b --- /dev/null +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-service-definition.sha256 @@ -0,0 +1 @@ +de80902111694beac03ffa65fc7f939804c569d02efa00f69033499f8122cbda diff --git a/src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-software-catalog.sha256 b/src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-software-catalog.sha256 new file mode 100644 index 000000000..7bb302637 --- /dev/null +++ b/src/check_jsonschema/builtin_schemas/vendor/sha256/datadog-software-catalog.sha256 @@ -0,0 +1 @@ +3762fcdd1b6ae0a7081238d449061d83d78765dcd9264e1fc5951b0d2f6c33b3 diff --git a/src/check_jsonschema/catalog.py b/src/check_jsonschema/catalog.py index 10933c119..4208ae3eb 100644 --- a/src/check_jsonschema/catalog.py +++ b/src/check_jsonschema/catalog.py @@ -158,6 +158,45 @@ def _githubusercontent_url(owner: str, repo: str, ref: str, path: str) -> str: "types": "yaml", }, }, + "datadog-continuous-testing": { + "url": _githubusercontent_url( + "DataDog", + "schema", + "main", + "datadog-ci/synthetics/test-config.schema.json", + ), + "hook_config": { + "name": "Validate Datadog Continuous Testing config", + "files": r"(^|.*/)datadog-ci\.(json|ya?ml)$", + "types_or": ["json", "yaml"], + }, + }, + "datadog-service-definition": { + "url": _githubusercontent_url( + "DataDog", + "schema", + "main", + "service-catalog/service.schema.json", + ), + "hook_config": { + "name": "Validate Datadog Service Definition", + "files": r"(^|.*/)service\.datadog\.(json|ya?ml)$", + "types_or": ["json", "yaml"], + }, + }, + "datadog-software-catalog": { + "url": _githubusercontent_url( + "DataDog", + "schema", + "main", + "service-catalog/entity.schema.json", + ), + "hook_config": { + "name": "Validate Datadog Software Catalog entity", + "files": r"(^|.*/)entity\.datadog\.(json|ya?ml)$", + "types_or": ["json", "yaml"], + }, + }, "dependabot": { "url": "https://json.schemastore.org/dependabot-2.0.json", "hook_config": { diff --git a/tests/acceptance/test_hook_file_matches.py b/tests/acceptance/test_hook_file_matches.py index 7c007a707..445a84aa7 100644 --- a/tests/acceptance/test_hook_file_matches.py +++ b/tests/acceptance/test_hook_file_matches.py @@ -94,6 +94,50 @@ def get_hook_config(hookid): "good": ("CITATION.cff",), "bad": ("CITATION.yml",), }, + "check-datadog-continuous-testing": { + "good": ( + "datadog-ci.json", + "datadog-ci.yml", + "datadog-ci.yaml", + "tests/datadog-ci.json", + "ci/datadog-ci.yaml", + ), + "bad": ( + "datadog.json", + "ci.json", + "datadog-ci.txt", + ), + }, + "check-datadog-service-definition": { + "good": ( + "service.datadog.yml", + "service.datadog.yaml", + "service.datadog.json", + "services/service.datadog.yml", + "docs/service.datadog.yaml", + ), + "bad": ( + "datadog.yml", + "service.yml", + "service-datadog.yaml", + "my-service.datadog.yml", + ), + }, + "check-datadog-software-catalog": { + "good": ( + "entity.datadog.yml", + "entity.datadog.yaml", + "entity.datadog.json", + "catalog/entity.datadog.yml", + "services/entity.datadog.yaml", + ), + "bad": ( + "datadog.yml", + "entity.yml", + "entity-datadog.yaml", + "my-entity.datadog.yml", + ), + }, "check-codecov": { "good": ( "codecov.yml", From a489edb021d5803ae2cb27884f08d022428ab340 Mon Sep 17 00:00:00 2001 From: "Anthony T. Lannutti" Date: Wed, 5 Aug 2026 10:35:31 -0500 Subject: [PATCH 2/3] docs: Add PR attribution to CHANGELOG --- CHANGELOG.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3da0c0cb4..844fd24e5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,7 +9,8 @@ Unreleased ---------- - Add Datadog schema hooks: ``check-datadog-continuous-testing``, - ``check-datadog-service-definition``, and ``check-datadog-software-catalog`` + ``check-datadog-service-definition``, and ``check-datadog-software-catalog``. + Thanks :user:`lannuttia`! (:pr:`701`) .. vendor-insert-here From 3a944ca558e039763356e219de7605dfe65c36b6 Mon Sep 17 00:00:00 2001 From: "Anthony T. Lannutti" Date: Wed, 5 Aug 2026 10:41:45 -0500 Subject: [PATCH 3/3] docs: Add issue reference to CHANGELOG --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 844fd24e5..ae6ab2bab 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,7 +10,7 @@ Unreleased - Add Datadog schema hooks: ``check-datadog-continuous-testing``, ``check-datadog-service-definition``, and ``check-datadog-software-catalog``. - Thanks :user:`lannuttia`! (:pr:`701`) + Thanks :user:`lannuttia`! (:issue:`702`, :pr:`701`) .. vendor-insert-here