Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds JSON linting #205

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins:
- jsonc
overrides:
- files: "*.json"
afrittoli marked this conversation as resolved.
Show resolved Hide resolved
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
13 changes: 12 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +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
Expand Down
174 changes: 87 additions & 87 deletions custom/schema.json
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://cdevents.dev/0.5.0-draft/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.5.0-draft/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"
]
}
"customDataContentType": {
"type": "string"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"context",
"subject"
]
}
42 changes: 21 additions & 21 deletions examples/incident_detected.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"context": {
"version": "0.5.0-draft",
"id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708",
"chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b",
"source": "/monitoring/prod1",
"type": "dev.cdevents.incident.detected.0.3.0-draft",
"timestamp": "2022-11-11T13:52:20.079Z"
"version": "0.5.0-draft",
"id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708",
"chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b",
"source": "/monitoring/prod1",
"type": "dev.cdevents.incident.detected.0.3.0-draft",
"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"
}
"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",
Expand Down
44 changes: 22 additions & 22 deletions examples/incident_reported.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"context": {
"version": "0.5.0-draft",
"id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708",
"chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b",
"source": "/monitoring/prod1",
"type": "dev.cdevents.incident.reported.0.3.0-draft",
"timestamp": "2022-11-11T13:52:20.079Z"
"version": "0.5.0-draft",
"id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708",
"chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b",
"source": "/monitoring/prod1",
"type": "dev.cdevents.incident.reported.0.3.0-draft",
"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",
Expand Down
42 changes: 21 additions & 21 deletions examples/incident_resolved.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"context": {
"version": "0.5.0-draft",
"id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708",
"chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b",
"source": "/monitoring/prod1",
"type": "dev.cdevents.incident.resolved.0.3.0-draft",
"timestamp": "2022-11-11T13:52:20.079Z"
"version": "0.5.0-draft",
"id": "F4BD2B55-B6F6-4F44-AF72-BD2D0E7A8708",
"chainId": "4c8cb7dd-3448-41de-8768-eec704e2829b",
"source": "/monitoring/prod1",
"type": "dev.cdevents.incident.resolved.0.3.0-draft",
"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",
Expand Down
2 changes: 1 addition & 1 deletion examples/testcaserun_finished.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"source": "/event/source/123",
"type": "testCaseRun",
"content": {
"outcome" : "pass",
"outcome": "pass",
"environment": {
"id": "dev",
"source": "testkube-dev-123"
Expand Down
4 changes: 2 additions & 2 deletions examples/testoutput_published.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading
Loading