From 9fcb9eb723ef6dc221a0b977e49f6446839c738a Mon Sep 17 00:00:00 2001 From: xibz Date: Tue, 16 Apr 2024 12:57:50 -0500 Subject: [PATCH 1/5] Changes snake cased fields to camel casing This commit improves consistency in our spec and examples by having all keys be camel cased. This made 4 changes: chain_id -> chainId context_id -> contextId link_kind -> linkKind link_type -> linkType Signed-off-by: xibz --- .github/linters/.eslintrc.yml | 21 ++++ .github/workflows/main.yml | 1 + custom/schema.json | 174 ++++++++++++++-------------- examples/incident_detected.json | 39 ++++--- examples/incident_reported.json | 32 ++--- examples/incident_resolved.json | 42 +++---- examples/testcaserun_finished.json | 2 +- examples/testoutput_published.json | 4 +- examples/testsuiterun_finished.json | 6 +- schemas/servicedeployed.json | 4 +- 10 files changed, 178 insertions(+), 147 deletions(-) create mode 100644 .github/linters/.eslintrc.yml diff --git a/.github/linters/.eslintrc.yml b/.github/linters/.eslintrc.yml new file mode 100644 index 00000000..39da2e9b --- /dev/null +++ b/.github/linters/.eslintrc.yml @@ -0,0 +1,21 @@ +plugins: + - jsonc +overrides: + - files: "*.json" + parser: "jsonc-eslint-parser" + rules: + # These are the set of rules that belong to jsonc. For more information, + # https://ota-meshi.github.io/eslint-plugin-jsonc/rules + jsonc/comma-dangle: + - error + jsonc/indent: + - error + - 2 + jsonc/key-name-casing: + - error + - camelCase: true + snake_case: false + jsonc/key-spacing: + - error + jsonc/no-dupe-keys: + - error diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 57f58db2..41a971ec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,6 +31,7 @@ jobs: DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_MARKDOWN: true + VALIDATE_JSON: true jsonschema: name: Validate Schemas and Examples diff --git a/custom/schema.json b/custom/schema.json index 4af49f94..3648bdb8 100644 --- a/custom/schema.json +++ b/custom/schema.json @@ -1,93 +1,93 @@ { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://cdevents.dev/0.4.0/schema/custom", - "properties": { - "context": { - "properties": { - "version": { - "type": "string", - "minLength": 1 - }, - "id": { - "type": "string", - "minLength": 1 - }, - "source": { - "type": "string", - "minLength": 1, - "format": "uri-reference" - }, - "type": { - "type": "string", - "pattern": "^dev.cdeventsx.[a-zA-Z0-9]+-[a-zA-Z]+.[a-zA-Z]+$" - }, - "timestamp": { - "type": "string", - "format": "date-time" - }, - "schemaUri": { - "type": "string", - "minLength": 1, - "format": "uri" - } + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://cdevents.dev/0.4.0/schema/custom", + "properties": { + "context": { + "properties": { + "version": { + "type": "string", + "minLength": 1 }, - "additionalProperties": false, - "type": "object", - "required": [ - "version", - "id", - "source", - "type", - "timestamp" - ] - }, - "subject": { - "properties": { - "id": { - "type": "string", - "minLength": 1 - }, - "source": { - "type": "string", - "minLength": 1, - "format": "uri-reference" - }, - "type": { - "type": "string", - "pattern": "^[a-zA-Z0-9]+-[a-zA-Z]+$" - }, - "content": { - "type": "object", - "additionalProperties": true - } + "id": { + "type": "string", + "minLength": 1 + }, + "source": { + "type": "string", + "minLength": 1, + "format": "uri-reference" + }, + "type": { + "type": "string", + "pattern": "^dev.cdeventsx.[a-zA-Z0-9]+-[a-zA-Z]+.[a-zA-Z]+$" }, - "additionalProperties": false, - "type": "object", - "required": [ - "id", - "type", - "content" - ] + "timestamp": { + "type": "string", + "format": "date-time" + }, + "schemaUri": { + "type": "string", + "minLength": 1, + "format": "uri" + } }, - "customData": { - "oneOf": [ - { - "type": "object" - }, - { - "type": "string", - "contentEncoding": "base64" - } - ] + "additionalProperties": false, + "type": "object", + "required": [ + "version", + "id", + "source", + "type", + "timestamp" + ] + }, + "subject": { + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "source": { + "type": "string", + "minLength": 1, + "format": "uri-reference" + }, + "type": { + "type": "string", + "pattern": "^[a-zA-Z0-9]+-[a-zA-Z]+$" + }, + "content": { + "type": "object", + "additionalProperties": true + } }, - "customDataContentType": { - "type": "string" - } + "additionalProperties": false, + "type": "object", + "required": [ + "id", + "type", + "content" + ] + }, + "customData": { + "oneOf": [ + { + "type": "object" + }, + { + "type": "string", + "contentEncoding": "base64" + } + ] }, - "additionalProperties": false, - "type": "object", - "required": [ - "context", - "subject" - ] - } \ No newline at end of file + "customDataContentType": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "context", + "subject" + ] +} \ No newline at end of file diff --git a/examples/incident_detected.json b/examples/incident_detected.json index 7eda29ab..005eb5a5 100644 --- a/examples/incident_detected.json +++ b/examples/incident_detected.json @@ -1,28 +1,37 @@ { "context": { +<<<<<<< HEAD "version": "0.4.0", "id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708", "chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b", "source": "/monitoring/prod1", "type": "dev.cdevents.incident.detected.0.2.0", "timestamp": "2022-11-11T13:52:20.079Z" +======= + "version": "0.4.0", + "id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708", + "chain_id": "4c8cb7dd-3448-41de-8768-eec704e2829b", + "source": "/monitoring/prod1", + "type": "dev.cdevents.incident.detected.0.2.0", + "timestamp": "2022-11-11T13:52:20.079Z" +>>>>>>> 2816601 (Changes snake cased fields to camel casing) }, "subject": { - "id": "incident-123", - "source": "/monitoring/prod1", - "type": "incident", - "content": { - "description": "Response time above threshold of 100ms", - "environment": { - "id": "prod1", - "source": "/iaas/geo1" - }, - "service": { - "id": "myApp", - "source": "/clusterA/namespaceB" - }, - "artifactId": "pkg:oci/myapp@sha256%3A0b31b1c02ff458ad9b7b81cbdf8f028bd54699fa151f221d1e8de6817db93427" - } + "id": "incident-123", + "source": "/monitoring/prod1", + "type": "incident", + "content": { + "description": "Response time above threshold of 100ms", + "environment": { + "id": "prod1", + "source": "/iaas/geo1" + }, + "service": { + "id": "myApp", + "source": "/clusterA/namespaceB" + }, + "artifactId": "pkg:oci/myapp@sha256%3A0b31b1c02ff458ad9b7b81cbdf8f028bd54699fa151f221d1e8de6817db93427" + } }, "customData": { "metric": "responseTime", diff --git a/examples/incident_reported.json b/examples/incident_reported.json index 00033a59..bc9d53bb 100644 --- a/examples/incident_reported.json +++ b/examples/incident_reported.json @@ -8,22 +8,22 @@ "timestamp": "2022-11-11T13:52:20.079Z" }, "subject": { - "id": "incident-123", - "source": "/monitoring/prod1", - "type": "incident", - "content": { - "description": "Response time above threshold of 100ms", - "environment": { - "id": "prod1", - "source": "/iaas/geo1" - }, - "service": { - "id": "myApp", - "source": "/clusterA/namespaceB" - }, - "artifactId": "pkg:oci/myapp@sha256%3A0b31b1c02ff458ad9b7b81cbdf8f028bd54699fa151f221d1e8de6817db93427", - "ticketURI": "https://my-issues.example/incidents/ticket-345" - } + "id": "incident-123", + "source": "/monitoring/prod1", + "type": "incident", + "content": { + "description": "Response time above threshold of 100ms", + "environment": { + "id": "prod1", + "source": "/iaas/geo1" + }, + "service": { + "id": "myApp", + "source": "/clusterA/namespaceB" + }, + "artifactId": "pkg:oci/myapp@sha256%3A0b31b1c02ff458ad9b7b81cbdf8f028bd54699fa151f221d1e8de6817db93427", + "ticketURI": "https://my-issues.example/incidents/ticket-345" + } }, "customData": { "severity": "medium", diff --git a/examples/incident_resolved.json b/examples/incident_resolved.json index 443afe3a..436d7e4f 100644 --- a/examples/incident_resolved.json +++ b/examples/incident_resolved.json @@ -1,28 +1,28 @@ { "context": { - "version": "0.4.0", - "id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708", - "chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b", - "source": "/monitoring/prod1", - "type": "dev.cdevents.incident.resolved.0.2.0", - "timestamp": "2022-11-11T13:52:20.079Z" + "version": "0.4.0", + "id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708", + "chain_id": "4c8cb7dd-3448-41de-8768-eec704e2829b", + "source": "/monitoring/prod1", + "type": "dev.cdevents.incident.resolved.0.2.0", + "timestamp": "2022-11-11T13:52:20.079Z" }, "subject": { - "id": "incident-123", - "source": "/monitoring/prod1", - "type": "incident", - "content": { - "description": "Response time restored below 100ms", - "environment": { - "id": "prod1", - "source": "/iaas/geo1" - }, - "service": { - "id": "myApp", - "source": "/clusterA/namespaceB" - }, - "artifactId": "pkg:oci/myapp@sha256%3A0b31b1c02ff458ad9b7b81cbdf8f028bd54699fa151f221d1e8de6817db93439" - } + "id": "incident-123", + "source": "/monitoring/prod1", + "type": "incident", + "content": { + "description": "Response time restored below 100ms", + "environment": { + "id": "prod1", + "source": "/iaas/geo1" + }, + "service": { + "id": "myApp", + "source": "/clusterA/namespaceB" + }, + "artifactId": "pkg:oci/myapp@sha256%3A0b31b1c02ff458ad9b7b81cbdf8f028bd54699fa151f221d1e8de6817db93439" + } }, "customData": { "metric": "responseTime", diff --git a/examples/testcaserun_finished.json b/examples/testcaserun_finished.json index be854811..bdbeaaee 100644 --- a/examples/testcaserun_finished.json +++ b/examples/testcaserun_finished.json @@ -13,7 +13,7 @@ "source": "/event/source/123", "type": "testCaseRun", "content": { - "outcome" : "pass", + "outcome": "pass", "environment": { "id": "dev", "source": "testkube-dev-123" diff --git a/examples/testoutput_published.json b/examples/testoutput_published.json index 8fc7998d..794b9f80 100644 --- a/examples/testoutput_published.json +++ b/examples/testoutput_published.json @@ -13,8 +13,8 @@ "source": "/event/source/testrunreport-12123", "type": "testOutput", "content": { - "outputType" : "video", - "format" : "video/quicktime", + "outputType": "video", + "format": "video/quicktime", "testCaseRun": { "id": "myTestCaseRun123", "source": "testkube-dev-123" diff --git a/examples/testsuiterun_finished.json b/examples/testsuiterun_finished.json index 1d398a59..26326701 100644 --- a/examples/testsuiterun_finished.json +++ b/examples/testsuiterun_finished.json @@ -13,9 +13,9 @@ "source": "/event/source/123", "type": "testSuiteRun", "content": { - "outcome" : "fail", - "severity" : "critical", - "reason" : "Host 123.34.23.32 not found", + "outcome": "fail", + "severity": "critical", + "reason": "Host 123.34.23.32 not found", "environment": { "id": "dev", "source": "testkube-dev-123" diff --git a/schemas/servicedeployed.json b/schemas/servicedeployed.json index 74c0a214..f373cffc 100644 --- a/schemas/servicedeployed.json +++ b/schemas/servicedeployed.json @@ -117,8 +117,8 @@ "type": "object" }, { - "type": "string", - "contentEncoding": "base64" + "type": "string", + "contentEncoding": "base64" } ] }, From 80bb76026bc4422e473028db0879b6208c4cbd6d Mon Sep 17 00:00:00 2001 From: xibz Date: Tue, 14 May 2024 13:16:05 -0500 Subject: [PATCH 2/5] fixup! Changes snake cased fields to camel casing Signed-off-by: xibz --- .github/linters/.eslintrc.yml | 4 +++- examples/incident_reported.json | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/linters/.eslintrc.yml b/.github/linters/.eslintrc.yml index 39da2e9b..07ae1d4e 100644 --- a/.github/linters/.eslintrc.yml +++ b/.github/linters/.eslintrc.yml @@ -1,7 +1,9 @@ plugins: - jsonc overrides: - - files: "*.json" + - files: + - "schema/*.json" + - "examples/*.json" parser: "jsonc-eslint-parser" rules: # These are the set of rules that belong to jsonc. For more information, diff --git a/examples/incident_reported.json b/examples/incident_reported.json index bc9d53bb..376111a6 100644 --- a/examples/incident_reported.json +++ b/examples/incident_reported.json @@ -1,11 +1,11 @@ { "context": { - "version": "0.4.0", - "id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708", - "chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b", - "source": "/monitoring/prod1", - "type": "dev.cdevents.incident.reported.0.2.0", - "timestamp": "2022-11-11T13:52:20.079Z" + "version": "0.4.0", + "id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708", + "chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b", + "source": "/monitoring/prod1", + "type": "dev.cdevents.incident.reported.0.2.0", + "timestamp": "2022-11-11T13:52:20.079Z" }, "subject": { "id": "incident-123", From 85686f4b5ccfbc3afe87886a0afe26409f38bfc9 Mon Sep 17 00:00:00 2001 From: xibz Date: Tue, 14 May 2024 13:41:09 -0500 Subject: [PATCH 3/5] Consistent strings Signed-off-by: xibz --- .github/linters/.eslintrc.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/linters/.eslintrc.yml b/.github/linters/.eslintrc.yml index 07ae1d4e..e40bc3a1 100644 --- a/.github/linters/.eslintrc.yml +++ b/.github/linters/.eslintrc.yml @@ -2,9 +2,9 @@ plugins: - jsonc overrides: - files: - - "schema/*.json" - - "examples/*.json" - parser: "jsonc-eslint-parser" + - schemas/*.json + - examples/*.json + parser: jsonc-eslint-parser rules: # These are the set of rules that belong to jsonc. For more information, # https://ota-meshi.github.io/eslint-plugin-jsonc/rules From d9a44fcfaae352001673deaeb5d83248e5de4587 Mon Sep 17 00:00:00 2001 From: xibz Date: Tue, 14 May 2024 13:49:20 -0500 Subject: [PATCH 4/5] Fixing some missed issues Signed-off-by: xibz --- .github/linters/.eslintrc.yml | 5 +++-- examples/incident_detected.json | 11 +---------- examples/incident_resolved.json | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/linters/.eslintrc.yml b/.github/linters/.eslintrc.yml index e40bc3a1..da4783ab 100644 --- a/.github/linters/.eslintrc.yml +++ b/.github/linters/.eslintrc.yml @@ -2,8 +2,9 @@ plugins: - jsonc overrides: - files: - - schemas/*.json - - examples/*.json + - schemas/**/*.json + - examples/**/*.json + - custom/**/*.json parser: jsonc-eslint-parser rules: # These are the set of rules that belong to jsonc. For more information, diff --git a/examples/incident_detected.json b/examples/incident_detected.json index 005eb5a5..18357a87 100644 --- a/examples/incident_detected.json +++ b/examples/incident_detected.json @@ -1,20 +1,11 @@ { "context": { -<<<<<<< HEAD - "version": "0.4.0", - "id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708", - "chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b", - "source": "/monitoring/prod1", - "type": "dev.cdevents.incident.detected.0.2.0", - "timestamp": "2022-11-11T13:52:20.079Z" -======= "version": "0.4.0", "id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708", - "chain_id": "4c8cb7dd-3448-41de-8768-eec704e2829b", + "chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b", "source": "/monitoring/prod1", "type": "dev.cdevents.incident.detected.0.2.0", "timestamp": "2022-11-11T13:52:20.079Z" ->>>>>>> 2816601 (Changes snake cased fields to camel casing) }, "subject": { "id": "incident-123", diff --git a/examples/incident_resolved.json b/examples/incident_resolved.json index 436d7e4f..f62e735c 100644 --- a/examples/incident_resolved.json +++ b/examples/incident_resolved.json @@ -2,7 +2,7 @@ "context": { "version": "0.4.0", "id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708", - "chain_id": "4c8cb7dd-3448-41de-8768-eec704e2829b", + "chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b", "source": "/monitoring/prod1", "type": "dev.cdevents.incident.resolved.0.2.0", "timestamp": "2022-11-11T13:52:20.079Z" From ce06d74dbd861886275f4dccdf5dc91249870249 Mon Sep 17 00:00:00 2001 From: xibz Date: Tue, 14 May 2024 17:33:04 -0500 Subject: [PATCH 5/5] Add FILTER_REGEX_INCLUDE Signed-off-by: xibz --- .github/linters/.eslintrc.yml | 5 +---- .github/workflows/main.yml | 12 +++++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/linters/.eslintrc.yml b/.github/linters/.eslintrc.yml index da4783ab..3459e021 100644 --- a/.github/linters/.eslintrc.yml +++ b/.github/linters/.eslintrc.yml @@ -1,10 +1,7 @@ plugins: - jsonc overrides: - - files: - - schemas/**/*.json - - examples/**/*.json - - custom/**/*.json + - files: "*.json" parser: jsonc-eslint-parser rules: # These are the set of rules that belong to jsonc. For more information, diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 41a971ec..affa29ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,10 +28,20 @@ jobs: uses: github/super-linter/slim@v4 env: VALIDATE_ALL_CODEBASE: true - DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_MARKDOWN: true VALIDATE_JSON: true + # superlinter runs each linter on a per file bases and does not look + # at tool specific configuration to determine whether or not to the + # lint the given file. + # + # Due to that we need to globally include or exclude files. This also + # makes tools less flexible with one another in that if a tool + # requires a specific folder to be included and excluded, but other + # tools require must lint the excluded folder, then this pattern does + # not work. Instead superlinter cannot be used in that case, and the + # linter itself needs to be ran outside of superlinter. + FILTER_REGEX_INCLUDE: .*\/(custom|examples|schemas)\/.* jsonschema: name: Validate Schemas and Examples