Skip to content

Commit 5e133f8

Browse files
committed
Add schema file for 'zendt' playbooks
- This schema can be used to validate `zendt` playbook yaml files.
1 parent f03e378 commit 5e133f8

File tree

1 file changed

+344
-0
lines changed

1 file changed

+344
-0
lines changed

zendhq/zendt-playbook.json

+344
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,344 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"definitions": {
4+
"rpc": {
5+
"type": "object",
6+
"properties": {
7+
"rpc": {
8+
"type": "string",
9+
"title": "JsonRPC method",
10+
"description": "Name of the JsonRPC method. For example: 'rpc: \"zray.subscribe\"'"
11+
},
12+
"params": {
13+
"type": "object",
14+
"title": "JsonRPC params",
15+
"description": "JsonRPC method parameters as key-value pairs that will be converted into a Json object."
16+
},
17+
"result": {
18+
"type": ["string", "number"],
19+
"title": "JsonRPC result",
20+
"description": "Expected JsonRPC method result. For example: 'result: \"OK\"'"
21+
},
22+
"store": {
23+
"type": "string",
24+
"title": "Store result",
25+
"description": "Store the JsonRPC method result in a named local variable. For example: 'store: \"JQ_JOB_ID\"'"
26+
},
27+
"store_global": {
28+
"type": "string",
29+
"title": "Store result",
30+
"description": "Store the JsonRPC method result in a named global variable. For example: 'store_global: \"JQ_JOB_ID\"'"
31+
}
32+
},
33+
"required": ["rpc"],
34+
"additionalProperties": false
35+
},
36+
"get": {
37+
"type": "object",
38+
"properties": {
39+
"get": {
40+
"type": "string",
41+
"title": "HTTP Get",
42+
"description": "URL for the HTTP GET request without the address and port number. For example: 'get: \"jq_add_job.php\"'"
43+
},
44+
"response": {
45+
"type": "integer",
46+
"title": "HTTP Response Code",
47+
"description": "Expected HTTP response code. For example: 'response: 200'"
48+
},
49+
"result": {
50+
"type": "string",
51+
"title": "Expected result",
52+
"description": "Expected result from the HTTP request. The HTTP response body must be a JSON object containing the 'result' member. For example: 'result: \"OK\"'"
53+
},
54+
"store": {
55+
"type": "string",
56+
"title": "Store result",
57+
"description": "Store the result from the HTTP request into a local named variable. The HTTP response body must be a JSON object containing the 'result' member. For example: 'store: \"JQ_JOB_ID\"'"
58+
},
59+
"store_global": {
60+
"type": "string",
61+
"title": "Store result",
62+
"description": "Store the result from the HTTP request into a global named variable. The HTTP response body must be a JSON object containing the 'result' member. For example: 'store_global: \"JQ_JOB_ID\"'"
63+
},
64+
"token": {
65+
"type": "string",
66+
"title": "Z-Ray Token",
67+
"description": "Optional token to use for Z-Ray activation. For example: 'token: \"${ZRAY_TOKEN}\"'"
68+
}
69+
},
70+
"required": ["get"],
71+
"additionalProperties": false
72+
},
73+
"exec": {
74+
"type": "object",
75+
"properties": {
76+
"exec": {
77+
"type": "string",
78+
"title": "Exec",
79+
"description": "Command to execute with optional arguments. For example: 'exec: \"zendhqctl jobqueue queue list\"'"
80+
},
81+
"name": {
82+
"type": "string",
83+
"title": "Name",
84+
"description": "Optional name of the task"
85+
},
86+
"skip": {
87+
"type": "string",
88+
"title": "Skip task",
89+
"description": "Optionally skip the task with a reason. For example: 'skip: \"Not implemented\"'"
90+
},
91+
"exit": {
92+
"type": "integer",
93+
"title": "Exit code",
94+
"description": "Expected exit code. For example: 'exit: 0'"
95+
},
96+
"if_has_var": {
97+
"type": "string",
98+
"title": "Execute if variable exists",
99+
"description": "Executes the task only if the named variable exists. For example: 'if_has_var: \"DEFAULT_QUEUE_ID\"'"
100+
},
101+
"stdout": {
102+
"type": "array",
103+
"title": "stdout checks",
104+
"description": "A list of regular expression checks to match against the stdout",
105+
"items": {
106+
"$ref": "#/definitions/check"
107+
}
108+
},
109+
"stderr": {
110+
"type": "array",
111+
"title": "stderr checks",
112+
"description": "A list of regular expression checks to match against the stderr",
113+
"items": {
114+
"$ref": "#/definitions/check"
115+
}
116+
}
117+
},
118+
"required": ["exec"],
119+
"additionalProperties": false
120+
},
121+
"check": {
122+
"type": "object",
123+
"properties": {
124+
"check": {
125+
"type": "string",
126+
"title": "Check",
127+
"description": "Name of the check"
128+
},
129+
"optional": {
130+
"type": "string",
131+
"title": "Optional check",
132+
"description": "Name of the optional check"
133+
},
134+
"regexp": {
135+
"type": "string",
136+
"title": "Regular expression",
137+
"description": "Regular expression to match against the output",
138+
"format": "regex"
139+
},
140+
"captures": {
141+
"type": "array",
142+
"title": "Captures",
143+
"description": "A list of actions performed on captured values. The list must be a sequence of actions up to the total number of captures, but not more.",
144+
"items": {
145+
"$ref": "#/definitions/capture"
146+
}
147+
}
148+
},
149+
"oneOf": [
150+
{
151+
"required": ["check"]
152+
},
153+
{
154+
"required": ["optional"]
155+
}
156+
],
157+
"additionalProperties": false
158+
},
159+
"capture": {
160+
"type": "object",
161+
"properties": {
162+
"eq": {
163+
"type": "string",
164+
"title": "Expected value",
165+
"description": "Value to compare against the captured value"
166+
},
167+
"store": {
168+
"type": "string",
169+
"title": "Store captured value",
170+
"description": "Name of the local storage variable to store the captured value. For example: 'store: \"JQ_JOB_ID\"'"
171+
},
172+
"store_global": {
173+
"type": "string",
174+
"title": "Store captured value",
175+
"description": "Name of the global storage variable to store the captured value. For example: 'store_global: \"JQ_JOB_ID\"'"
176+
}
177+
},
178+
"oneOf": [
179+
{
180+
"required": ["eq"]
181+
},
182+
{
183+
"required": ["store"]
184+
},
185+
{
186+
"required": ["store_global"]
187+
}
188+
],
189+
"additionalProperties": false
190+
},
191+
"event": {
192+
"type": "object",
193+
"properties": {
194+
"event": {
195+
"type": "string",
196+
"title": "JsonRPC Event",
197+
"description": "Name of the JsonRPC event. For example: 'event: \"jq.job_status\"'"
198+
},
199+
"fields": {
200+
"type": "array",
201+
"title": "Event fields",
202+
"description": "List of expected fields in the JsonRPC event",
203+
"items": {
204+
"$ref": "#/definitions/field"
205+
}
206+
},
207+
"cfields": {
208+
"type": "array",
209+
"title": "Condition fields",
210+
"description": "List of JsonRPC fields to match the event before checking the event",
211+
"items": {
212+
"$ref": "#/definitions/cfield"
213+
}
214+
},
215+
"count": {
216+
"type": "integer",
217+
"title": "Event count",
218+
"default": 1,
219+
"description": "Number of times the event is expected to occur (default is 1)"
220+
},
221+
"regexp": {
222+
"type": "string",
223+
"format": "regex",
224+
"title": "Regular expression",
225+
"description": "Regular expression applied to the whole JsonRPC response that must match at least once"
226+
}
227+
},
228+
"required": ["event"],
229+
"additionalProperties": false
230+
},
231+
"field": {
232+
"type": "object",
233+
"properties": {
234+
"name": {
235+
"type": "string",
236+
"title": "Field name",
237+
"description": "Name of the Json element. Can be a Json path, like: 'name: \"stack_trace[2].function_name\"'"
238+
},
239+
"type": {
240+
"type": "string",
241+
"title": "Field type",
242+
"description": "Expected type of the Json value.",
243+
"enum": [ "null", "array", "object", "undefined", "string", "double", "bool", "int", "uint" ]
244+
},
245+
"store": {
246+
"type": "string",
247+
"title": "Variable name",
248+
"description": "Name of the local variable to store the field value"
249+
},
250+
"value": {
251+
"type": ["boolean", "string", "number"],
252+
"title": "Value",
253+
"description": "Expected value of the field. Can be a variable, but then it must be a single variable without any extra text"
254+
},
255+
"regexp": {
256+
"type": "string",
257+
"title": "Regular expression",
258+
"description": "Regular expression applied to the value of the field that must match."
259+
},
260+
"flags": {
261+
"type": "string",
262+
"title": "Optional flags",
263+
"description": "Optional comma-separated list of flags.\nValid flags:\n* base64 - expects the field value to be base64 encoded"
264+
}
265+
},
266+
"required": ["name"],
267+
"additionalProperties": false
268+
},
269+
"cfield": {
270+
"type": "object",
271+
"properties": {
272+
"name": {
273+
"type": "string",
274+
"title": "Field name",
275+
"description": "Name of the field"
276+
},
277+
"value": {
278+
"type": ["boolean", "string", "number"],
279+
"title": "Value",
280+
"description": "Expected value of the field"
281+
}
282+
},
283+
"required": ["name"],
284+
"additionalProperties": false
285+
}
286+
},
287+
"properties": {
288+
"test": {
289+
"type": "string",
290+
"title": "Name",
291+
"description": "Name of the test"
292+
},
293+
"description": {
294+
"type": "string",
295+
"title": "Description",
296+
"description": "Optional description of the test"
297+
},
298+
"timeout": {
299+
"type": "integer",
300+
"title": "Timeout [msec]",
301+
"default": 1000,
302+
"description": "Timeout value in milliseconds. Default value is 1000 msec."
303+
},
304+
"tasks": {
305+
"type": "array",
306+
"title": "Tasks to run",
307+
"description": "A list of zendt tasks to run",
308+
"items": {
309+
"anyOf": [
310+
{
311+
"$ref": "#/definitions/rpc"
312+
},
313+
{
314+
"$ref": "#/definitions/get"
315+
},
316+
{
317+
"$ref": "#/definitions/exec"
318+
}
319+
]
320+
}
321+
},
322+
"expect": {
323+
"type": "object",
324+
"title": "Expectations",
325+
"description": "Expected results of the test",
326+
"properties": {
327+
"events": {
328+
"type": "array",
329+
"title": "Events",
330+
"description": "A list of expected JsonRPC events",
331+
"items": {
332+
"anyOf": [
333+
{
334+
"$ref": "#/definitions/event"
335+
}
336+
]
337+
}
338+
}
339+
}
340+
}
341+
},
342+
"required": ["test", "tasks"],
343+
"additionalProperties": false
344+
}

0 commit comments

Comments
 (0)