Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

Commit

Permalink
chore(proc): change repo layout and config workflow
Browse files Browse the repository at this point in the history
Change layout of configurations and configuration schemas (see #1037)
Add schema validation to configurations-ci job.
  • Loading branch information
minherz committed Jun 9, 2023
1 parent 20142ac commit 9fc0c84
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 124 deletions.
38 changes: 34 additions & 4 deletions .github/workflows/configurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,49 @@ on:
pull_request:
types: [opened,synchronize,reopened]
paths:
- 'applications/**/*.yaml'
- 'configurations/**/*.yaml'
- 'provisioning/schemas/configuration/**/*.json'


jobs:

yamllint:
ci:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Check CLI script

- name: install ajv
run: npm install ajv-cli

- name: Lint configurations
run: yamllint configurations/**/*.yaml configurations/**/*.yml

- name: Lint schemas
run: echo "JSON liniting will be here"

- name: Schema validation
run: |-
for CONFIG_FILE in $(find configurations -mindepth 2 -maxdepth 2 -type f -name "*.yaml"); do
FILENAME=$(basename -s '.yaml' "${CONFIG_FILE@L}")
case "${FILENAME}" in
alerts)
dashboards)
healthchecks)
metrics)
services)
slos)
;;
*)
echo "Unknown file "${CONFIG_FILE}" 1>&2
continue
;;
esac
ajv --spec=draft2020 -s "provisioning/schemas/configuration/${FILENAME}.json" -d "${CONFIG_FILE}"
done
- name: Dry run
run: echo "Validation of Terraform plan for test configuration will be here"
112 changes: 0 additions & 112 deletions provisioning/configurations/schemas/notification_channel.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/alert.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Monitoring alert schema",
"title": "Monitoring alerts and notification channels schema",
"type": "object",
"required": [
"app-id",
Expand All @@ -19,10 +18,17 @@
},
"alerts": {
"type": "array",
"description": "A collection of alerts",
"description": "A collection of alert policy definitions",
"items": {
"$ref": "#/$defs/alert"
}
},
"channels": {
"type": "array",
"description": "A collection of notification channel definitions",
"items": {
"$ref": "#/$defs/channel"
}
}
},
"$defs": {
Expand Down Expand Up @@ -67,6 +73,49 @@
}
}
},
"channel": {
"type": "object",
"description": "",
"required": [
"name",
"type",
"labels"
],
"properties": {
"name": {
"type": "string",
"description": "A unique resource name for this notification channel",
"maxLength": 30
},
"display-name": {
"type": "string",
"description": "A human-readable name for this notification channel",
"maxLength": 512
},
"type": {
"enum": [
"email",
"pubsub",
"sms"
],
"description": "Supports sending notifications to email, PubSub and SMS"
},
"labels": {
"description": "Configuration fields that define the channel and its behavior for one of:",
"anyOf": [
{
"$ref": "#/$defs/emailLabels"
},
{
"$ref": "#/$defs/pubsubLabels"
},
{
"$ref": "#/$defs/smsLabels"
}
]
}
}
},
"condition": {
"type": "object",
"description": "A true/false test that determines when an alerting policy should open an incident",
Expand Down Expand Up @@ -130,6 +179,45 @@
},
"conditionAbsent": {},
"conditionMatchedLog": {},
"conditionMonitoringQueryLanguage": {}
"conditionMonitoringQueryLanguage": {},
"emailLabels": {
"type": "object",
"description": "Configuration for email notification channel",
"required": [
"email_address"
],
"properties": {
"email_address": {
"type": "string",
"description": "An address to send email"
}
}
},
"pubsubLabels": {
"type": "object",
"description": "Configuration for PubSub notification channel",
"required": [
"topic"
],
"properties": {
"topic": {
"type": "string",
"description": "A fully qualified resource name of the Pub/Sub topic to post notifications"
}
}
},
"smsLabels": {
"type": "object",
"description": "Configuration for SMS notification channel",
"required": [
"number"
],
"properties": {
"number": {
"type": "string",
"describing": "A phone number to text notifications"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/dashboard.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Monitoring dashboard schema",
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/uptime_check.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Uptime check schema",
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/log_based_metric.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Log-based metric schema",
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/slo.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Service's SLO schema",
"type": "object",
Expand Down

0 comments on commit 9fc0c84

Please sign in to comment.