schema.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. package config
  2. var schemaV1 = `{
  3. "$schema": "http://json-schema.org/draft-04/schema#",
  4. "id": "config_schema_v1.json",
  5. "type": "object",
  6. "patternProperties": {
  7. "^[a-zA-Z0-9._-]+$": {
  8. "$ref": "#/definitions/service"
  9. }
  10. },
  11. "additionalProperties": false,
  12. "definitions": {
  13. "service": {
  14. "id": "#/definitions/service",
  15. "type": "object",
  16. "properties": {
  17. "build": {"type": "string"},
  18. "cap_add": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  19. "cap_drop": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  20. "cgroup_parent": {"type": "string"},
  21. "command": {
  22. "oneOf": [
  23. {"type": "string"},
  24. {"type": "array", "items": {"type": "string"}}
  25. ]
  26. },
  27. "container_name": {"type": "string"},
  28. "cpu_shares": {"type": ["number", "string"]},
  29. "cpu_quota": {"type": ["number", "string"]},
  30. "cpuset": {"type": "string"},
  31. "devices": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  32. "dns": {"$ref": "#/definitions/string_or_list"},
  33. "dns_search": {"$ref": "#/definitions/string_or_list"},
  34. "dockerfile": {"type": "string"},
  35. "domainname": {"type": "string"},
  36. "entrypoint": {
  37. "oneOf": [
  38. {"type": "string"},
  39. {"type": "array", "items": {"type": "string"}}
  40. ]
  41. },
  42. "env_file": {"$ref": "#/definitions/string_or_list"},
  43. "environment": {"$ref": "#/definitions/list_or_dict"},
  44. "expose": {
  45. "type": "array",
  46. "items": {
  47. "type": ["string", "number"],
  48. "format": "expose"
  49. },
  50. "uniqueItems": true
  51. },
  52. "extends": {
  53. "oneOf": [
  54. {
  55. "type": "string"
  56. },
  57. {
  58. "type": "object",
  59. "properties": {
  60. "service": {"type": "string"},
  61. "file": {"type": "string"}
  62. },
  63. "required": ["service"],
  64. "additionalProperties": false
  65. }
  66. ]
  67. },
  68. "extra_hosts": {"$ref": "#/definitions/list_or_dict"},
  69. "external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  70. "hostname": {"type": "string"},
  71. "image": {"type": "string"},
  72. "ipc": {"type": "string"},
  73. "labels": {"$ref": "#/definitions/list_or_dict"},
  74. "links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  75. "log_driver": {"type": "string"},
  76. "log_opt": {"type": "object"},
  77. "mac_address": {"type": "string"},
  78. "mem_limit": {"type": ["number", "string"]},
  79. "memswap_limit": {"type": ["number", "string"]},
  80. "net": {"type": "string"},
  81. "pid": {"type": ["string", "null"]},
  82. "ports": {
  83. "type": "array",
  84. "items": {
  85. "type": ["string", "number"],
  86. "format": "ports"
  87. },
  88. "uniqueItems": true
  89. },
  90. "privileged": {"type": "boolean"},
  91. "read_only": {"type": "boolean"},
  92. "restart": {"type": "string"},
  93. "security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  94. "shm_size": {"type": ["number", "string"]},
  95. "stdin_open": {"type": "boolean"},
  96. "stop_signal": {"type": "string"},
  97. "tty": {"type": "boolean"},
  98. "ulimits": {
  99. "type": "object",
  100. "patternProperties": {
  101. "^[a-z]+$": {
  102. "oneOf": [
  103. {"type": "integer"},
  104. {
  105. "type":"object",
  106. "properties": {
  107. "hard": {"type": "integer"},
  108. "soft": {"type": "integer"}
  109. },
  110. "required": ["soft", "hard"],
  111. "additionalProperties": false
  112. }
  113. ]
  114. }
  115. }
  116. },
  117. "user": {"type": "string"},
  118. "volumes": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  119. "volume_driver": {"type": "string"},
  120. "volumes_from": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  121. "working_dir": {"type": "string"}
  122. },
  123. "dependencies": {
  124. "memswap_limit": ["mem_limit"]
  125. },
  126. "additionalProperties": false
  127. },
  128. "string_or_list": {
  129. "oneOf": [
  130. {"type": "string"},
  131. {"$ref": "#/definitions/list_of_strings"}
  132. ]
  133. },
  134. "list_of_strings": {
  135. "type": "array",
  136. "items": {"type": "string"},
  137. "uniqueItems": true
  138. },
  139. "list_or_dict": {
  140. "oneOf": [
  141. {
  142. "type": "object",
  143. "patternProperties": {
  144. ".+": {
  145. "type": ["string", "number", "null"]
  146. }
  147. },
  148. "additionalProperties": false
  149. },
  150. {"type": "array", "items": {"type": "string"}, "uniqueItems": true}
  151. ]
  152. },
  153. "constraints": {
  154. "service": {
  155. "id": "#/definitions/constraints/service",
  156. "anyOf": [
  157. {
  158. "required": ["build"],
  159. "not": {"required": ["image"]}
  160. },
  161. {
  162. "required": ["image"],
  163. "not": {"anyOf": [
  164. {"required": ["build"]},
  165. {"required": ["dockerfile"]}
  166. ]}
  167. }
  168. ]
  169. }
  170. }
  171. }
  172. }
  173. `
  174. var schemaV2 = `{
  175. "$schema": "http://json-schema.org/draft-04/schema#",
  176. "id": "config_schema_v2.0.json",
  177. "type": "object",
  178. "properties": {
  179. "version": {
  180. "type": "string"
  181. },
  182. "services": {
  183. "id": "#/properties/services",
  184. "type": "object",
  185. "patternProperties": {
  186. "^[a-zA-Z0-9._-]+$": {
  187. "$ref": "#/definitions/service"
  188. }
  189. },
  190. "additionalProperties": false
  191. },
  192. "networks": {
  193. "id": "#/properties/networks",
  194. "type": "object",
  195. "patternProperties": {
  196. "^[a-zA-Z0-9._-]+$": {
  197. "$ref": "#/definitions/network"
  198. }
  199. }
  200. },
  201. "volumes": {
  202. "id": "#/properties/volumes",
  203. "type": "object",
  204. "patternProperties": {
  205. "^[a-zA-Z0-9._-]+$": {
  206. "$ref": "#/definitions/volume"
  207. }
  208. },
  209. "additionalProperties": false
  210. }
  211. },
  212. "additionalProperties": false,
  213. "definitions": {
  214. "service": {
  215. "id": "#/definitions/service",
  216. "type": "object",
  217. "properties": {
  218. "build": {
  219. "oneOf": [
  220. {"type": "string"},
  221. {
  222. "type": "object",
  223. "properties": {
  224. "context": {"type": "string"},
  225. "dockerfile": {"type": "string"},
  226. "args": {"$ref": "#/definitions/list_or_dict"}
  227. },
  228. "additionalProperties": false
  229. }
  230. ]
  231. },
  232. "cap_add": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  233. "cap_drop": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  234. "cgroup_parent": {"type": "string"},
  235. "command": {
  236. "oneOf": [
  237. {"type": "string"},
  238. {"type": "array", "items": {"type": "string"}}
  239. ]
  240. },
  241. "container_name": {"type": "string"},
  242. "cpu_shares": {"type": ["number", "string"]},
  243. "cpu_quota": {"type": ["number", "string"]},
  244. "cpuset": {"type": "string"},
  245. "depends_on": {"$ref": "#/definitions/list_of_strings"},
  246. "devices": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  247. "dns": {"$ref": "#/definitions/string_or_list"},
  248. "dns_search": {"$ref": "#/definitions/string_or_list"},
  249. "domainname": {"type": "string"},
  250. "entrypoint": {
  251. "oneOf": [
  252. {"type": "string"},
  253. {"type": "array", "items": {"type": "string"}}
  254. ]
  255. },
  256. "env_file": {"$ref": "#/definitions/string_or_list"},
  257. "environment": {"$ref": "#/definitions/list_or_dict"},
  258. "expose": {
  259. "type": "array",
  260. "items": {
  261. "type": ["string", "number"],
  262. "format": "expose"
  263. },
  264. "uniqueItems": true
  265. },
  266. "extends": {
  267. "oneOf": [
  268. {
  269. "type": "string"
  270. },
  271. {
  272. "type": "object",
  273. "properties": {
  274. "service": {"type": "string"},
  275. "file": {"type": "string"}
  276. },
  277. "required": ["service"],
  278. "additionalProperties": false
  279. }
  280. ]
  281. },
  282. "external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  283. "extra_hosts": {"$ref": "#/definitions/list_or_dict"},
  284. "hostname": {"type": "string"},
  285. "image": {"type": "string"},
  286. "ipc": {"type": "string"},
  287. "labels": {"$ref": "#/definitions/list_or_dict"},
  288. "links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  289. "logging": {
  290. "type": "object",
  291. "properties": {
  292. "driver": {"type": "string"},
  293. "options": {"type": "object"}
  294. },
  295. "additionalProperties": false
  296. },
  297. "mac_address": {"type": "string"},
  298. "mem_limit": {"type": ["number", "string"]},
  299. "memswap_limit": {"type": ["number", "string"]},
  300. "network_mode": {"type": "string"},
  301. "networks": {
  302. "oneOf": [
  303. {"$ref": "#/definitions/list_of_strings"},
  304. {
  305. "type": "object",
  306. "patternProperties": {
  307. "^[a-zA-Z0-9._-]+$": {
  308. "oneOf": [
  309. {
  310. "type": "object",
  311. "properties": {
  312. "aliases": {"$ref": "#/definitions/list_of_strings"},
  313. "ipv4_address": {"type": "string"},
  314. "ipv6_address": {"type": "string"}
  315. },
  316. "additionalProperties": false
  317. },
  318. {"type": "null"}
  319. ]
  320. }
  321. },
  322. "additionalProperties": false
  323. }
  324. ]
  325. },
  326. "pid": {"type": ["string", "null"]},
  327. "ports": {
  328. "type": "array",
  329. "items": {
  330. "type": ["string", "number"],
  331. "format": "ports"
  332. },
  333. "uniqueItems": true
  334. },
  335. "privileged": {"type": "boolean"},
  336. "read_only": {"type": "boolean"},
  337. "restart": {"type": "string"},
  338. "security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  339. "shm_size": {"type": ["number", "string"]},
  340. "stdin_open": {"type": "boolean"},
  341. "stop_signal": {"type": "string"},
  342. "tmpfs": {"$ref": "#/definitions/string_or_list"},
  343. "tty": {"type": "boolean"},
  344. "ulimits": {
  345. "type": "object",
  346. "patternProperties": {
  347. "^[a-z]+$": {
  348. "oneOf": [
  349. {"type": "integer"},
  350. {
  351. "type":"object",
  352. "properties": {
  353. "hard": {"type": "integer"},
  354. "soft": {"type": "integer"}
  355. },
  356. "required": ["soft", "hard"],
  357. "additionalProperties": false
  358. }
  359. ]
  360. }
  361. }
  362. },
  363. "user": {"type": "string"},
  364. "volumes": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  365. "volume_driver": {"type": "string"},
  366. "volumes_from": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
  367. "working_dir": {"type": "string"}
  368. },
  369. "dependencies": {
  370. "memswap_limit": ["mem_limit"]
  371. },
  372. "additionalProperties": false
  373. },
  374. "network": {
  375. "id": "#/definitions/network",
  376. "type": "object",
  377. "properties": {
  378. "driver": {"type": "string"},
  379. "driver_opts": {
  380. "type": "object",
  381. "patternProperties": {
  382. "^.+$": {"type": ["string", "number"]}
  383. }
  384. },
  385. "ipam": {
  386. "type": "object",
  387. "properties": {
  388. "driver": {"type": "string"},
  389. "config": {
  390. "type": "array"
  391. }
  392. },
  393. "additionalProperties": false
  394. },
  395. "external": {
  396. "type": ["boolean", "object"],
  397. "properties": {
  398. "name": {"type": "string"}
  399. },
  400. "additionalProperties": false
  401. }
  402. },
  403. "additionalProperties": false
  404. },
  405. "volume": {
  406. "id": "#/definitions/volume",
  407. "type": ["object", "null"],
  408. "properties": {
  409. "driver": {"type": "string"},
  410. "driver_opts": {
  411. "type": "object",
  412. "patternProperties": {
  413. "^.+$": {"type": ["string", "number"]}
  414. }
  415. },
  416. "external": {
  417. "type": ["boolean", "object"],
  418. "properties": {
  419. "name": {"type": "string"}
  420. }
  421. },
  422. "additionalProperties": false
  423. },
  424. "additionalProperties": false
  425. },
  426. "string_or_list": {
  427. "oneOf": [
  428. {"type": "string"},
  429. {"$ref": "#/definitions/list_of_strings"}
  430. ]
  431. },
  432. "list_of_strings": {
  433. "type": "array",
  434. "items": {"type": "string"},
  435. "uniqueItems": true
  436. },
  437. "list_or_dict": {
  438. "oneOf": [
  439. {
  440. "type": "object",
  441. "patternProperties": {
  442. ".+": {
  443. "type": ["string", "number", "null"]
  444. }
  445. },
  446. "additionalProperties": false
  447. },
  448. {"type": "array", "items": {"type": "string"}, "uniqueItems": true}
  449. ]
  450. },
  451. "constraints": {
  452. "service": {
  453. "id": "#/definitions/constraints/service",
  454. "anyOf": [
  455. {"required": ["build"]},
  456. {"required": ["image"]}
  457. ],
  458. "properties": {
  459. "build": {
  460. "required": ["context"]
  461. }
  462. }
  463. }
  464. }
  465. }
  466. }
  467. `