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

Commit 485b88c

Browse files
committed
chore(proc): change repo layout and config workflow
Change layout of configurations and configuration schemas (see #1037) Add schema validation to configurations-ci job.
1 parent 20142ac commit 485b88c

File tree

7 files changed

+128
-125
lines changed

7 files changed

+128
-125
lines changed

.github/workflows/configurations.yaml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,50 @@ on:
2222
pull_request:
2323
types: [opened,synchronize,reopened]
2424
paths:
25-
- 'applications/**/*.yaml'
25+
- 'configurations/**/*.yaml'
26+
- 'provisioning/schemas/configuration/**/*.json'
2627

2728

2829
jobs:
2930

30-
yamllint:
31+
ci:
3132
runs-on: ubuntu-latest
3233
permissions:
3334
contents: read
3435

3536
steps:
3637
- name: Checkout source code
3738
uses: actions/checkout@v3
38-
39-
- name: Check CLI script
40-
run: yamllint configurations/**/*.yaml configurations/**/*.yml
39+
40+
- name: install ajv
41+
run: npm install ajv-cli
42+
43+
- name: Lint configurations
44+
run: |-
45+
cd "${{ github.workspace }}"
46+
CONFIG_FILES=$(find configurations -mindepth 2 -maxdepth 2 -type f \( -name "*.yaml" -o -name "*.yml" \))
47+
if [[ -n "$CONFIG_FILES" ]]; then
48+
yamllint configurations/**/*.yaml configurations/**/*.yml
49+
fi
50+
51+
- name: Lint schemas
52+
run: echo "JSON liniting will be here"
53+
54+
- name: Schema validation
55+
run: |-
56+
cd "${{ github.workspace }}"
57+
for CONFIG_FILE in $(find configurations -mindepth 2 -maxdepth 2 -type f -name "*.yaml"); do
58+
FILENAME=$(basename -s ".yaml" "${CONFIG_FILE@L}")
59+
case "${FILENAME}" in
60+
alerts | dashboards | healthchecks | metrics | services | slos)
61+
;;
62+
*)
63+
echo "Unknown file ${CONFIG_FILE}" 1>&2
64+
continue
65+
;;
66+
esac
67+
ajv --spec=draft2020 -s "provisioning/schemas/configuration/${FILENAME}.json" -d "${CONFIG_FILE}"
68+
done
69+
70+
- name: Dry run
71+
run: echo "Validation of Terraform plan for test configuration will be here"

provisioning/configurations/schemas/notification_channel.json

Lines changed: 0 additions & 112 deletions
This file was deleted.

provisioning/configurations/schemas/alert.json renamed to provisioning/schemas/configuration/alerts.json

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/alert.json",
32
"$schema": "https://json-schema.org/draft/2020-12/schema",
4-
"title": "Monitoring alert schema",
3+
"title": "Monitoring alerts and notification channels schema",
54
"type": "object",
65
"required": [
76
"app-id",
@@ -19,10 +18,17 @@
1918
},
2019
"alerts": {
2120
"type": "array",
22-
"description": "A collection of alerts",
21+
"description": "A collection of alert policy definitions",
2322
"items": {
2423
"$ref": "#/$defs/alert"
2524
}
25+
},
26+
"channels": {
27+
"type": "array",
28+
"description": "A collection of notification channel definitions",
29+
"items": {
30+
"$ref": "#/$defs/channel"
31+
}
2632
}
2733
},
2834
"$defs": {
@@ -67,6 +73,49 @@
6773
}
6874
}
6975
},
76+
"channel": {
77+
"type": "object",
78+
"description": "",
79+
"required": [
80+
"name",
81+
"type",
82+
"labels"
83+
],
84+
"properties": {
85+
"name": {
86+
"type": "string",
87+
"description": "A unique resource name for this notification channel",
88+
"maxLength": 30
89+
},
90+
"display-name": {
91+
"type": "string",
92+
"description": "A human-readable name for this notification channel",
93+
"maxLength": 512
94+
},
95+
"type": {
96+
"enum": [
97+
"email",
98+
"pubsub",
99+
"sms"
100+
],
101+
"description": "Supports sending notifications to email, PubSub and SMS"
102+
},
103+
"labels": {
104+
"description": "Configuration fields that define the channel and its behavior for one of:",
105+
"anyOf": [
106+
{
107+
"$ref": "#/$defs/emailLabels"
108+
},
109+
{
110+
"$ref": "#/$defs/pubsubLabels"
111+
},
112+
{
113+
"$ref": "#/$defs/smsLabels"
114+
}
115+
]
116+
}
117+
}
118+
},
70119
"condition": {
71120
"type": "object",
72121
"description": "A true/false test that determines when an alerting policy should open an incident",
@@ -130,6 +179,45 @@
130179
},
131180
"conditionAbsent": {},
132181
"conditionMatchedLog": {},
133-
"conditionMonitoringQueryLanguage": {}
182+
"conditionMonitoringQueryLanguage": {},
183+
"emailLabels": {
184+
"type": "object",
185+
"description": "Configuration for email notification channel",
186+
"required": [
187+
"email_address"
188+
],
189+
"properties": {
190+
"email_address": {
191+
"type": "string",
192+
"description": "An address to send email"
193+
}
194+
}
195+
},
196+
"pubsubLabels": {
197+
"type": "object",
198+
"description": "Configuration for PubSub notification channel",
199+
"required": [
200+
"topic"
201+
],
202+
"properties": {
203+
"topic": {
204+
"type": "string",
205+
"description": "A fully qualified resource name of the Pub/Sub topic to post notifications"
206+
}
207+
}
208+
},
209+
"smsLabels": {
210+
"type": "object",
211+
"description": "Configuration for SMS notification channel",
212+
"required": [
213+
"number"
214+
],
215+
"properties": {
216+
"number": {
217+
"type": "string",
218+
"describing": "A phone number to text notifications"
219+
}
220+
}
221+
}
134222
}
135223
}

provisioning/configurations/schemas/dashboard.json renamed to provisioning/schemas/configuration/dashboards.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/dashboard.json",
32
"$schema": "https://json-schema.org/draft/2020-12/schema",
43
"title": "Monitoring dashboard schema",
54
"type": "object",

provisioning/configurations/schemas/uptime_check.json renamed to provisioning/schemas/configuration/healthchecks.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/uptime_check.json",
32
"$schema": "https://json-schema.org/draft/2020-12/schema",
43
"title": "Uptime check schema",
54
"type": "object",

provisioning/configurations/schemas/log_based_metric.json renamed to provisioning/schemas/configuration/metrics.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/log_based_metric.json",
32
"$schema": "https://json-schema.org/draft/2020-12/schema",
43
"title": "Log-based metric schema",
54
"type": "object",

provisioning/configurations/schemas/slo.json renamed to provisioning/schemas/configuration/slos.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/slo.json",
32
"$schema": "https://json-schema.org/draft/2020-12/schema",
43
"title": "Service's SLO schema",
54
"type": "object",

0 commit comments

Comments
 (0)