Skip to content

Commit a9f2bb2

Browse files
committed
attributes also can be declared as string (using variables)
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent a2bc3b4 commit a9f2bb2

File tree

3 files changed

+203
-61
lines changed

3 files changed

+203
-61
lines changed

schema/compose-spec.json

Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
"name": {
1515
"type": "string",
16-
"pattern": "^[a-z0-9][a-z0-9_-]*$",
1716
"description": "define the Compose project name, until user defines one explicitly."
1817
},
1918

@@ -94,7 +93,7 @@
9493
"develop": {"$ref": "#/definitions/development"},
9594
"deploy": {"$ref": "#/definitions/deployment"},
9695
"annotations": {"$ref": "#/definitions/list_or_dict"},
97-
"attach": {"type": "boolean"},
96+
"attach": {"type": ["boolean", "string"]},
9897
"build": {
9998
"oneOf": [
10099
{"type": "string"},
@@ -110,15 +109,15 @@
110109
"labels": {"$ref": "#/definitions/list_or_dict"},
111110
"cache_from": {"type": "array", "items": {"type": "string"}},
112111
"cache_to": {"type": "array", "items": {"type": "string"}},
113-
"no_cache": {"type": "boolean"},
112+
"no_cache": {"type": ["boolean", "string"]},
114113
"additional_contexts": {"$ref": "#/definitions/list_or_dict"},
115114
"network": {"type": "string"},
116-
"pull": {"type": "boolean"},
115+
"pull": {"type": ["boolean", "string"]},
117116
"target": {"type": "string"},
118117
"shm_size": {"type": ["integer", "string"]},
119118
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
120119
"isolation": {"type": "string"},
121-
"privileged": {"type": "boolean"},
120+
"privileged": {"type": ["boolean", "string"]},
122121
"secrets": {"$ref": "#/definitions/service_config_or_secret"},
123122
"tags": {"type": "array", "items": {"type": "string"}},
124123
"ulimits": {"$ref": "#/definitions/ulimits"},
@@ -148,7 +147,7 @@
148147
"type": "array",
149148
"items": {"$ref": "#/definitions/blkio_limit"}
150149
},
151-
"weight": {"type": "integer"},
150+
"weight": {"type": ["integer", "string"]},
152151
"weight_device": {
153152
"type": "array",
154153
"items": {"$ref": "#/definitions/blkio_weight"}
@@ -163,8 +162,14 @@
163162
"command": {"$ref": "#/definitions/command"},
164163
"configs": {"$ref": "#/definitions/service_config_or_secret"},
165164
"container_name": {"type": "string"},
166-
"cpu_count": {"type": "integer", "minimum": 0},
167-
"cpu_percent": {"type": "integer", "minimum": 0, "maximum": 100},
165+
"cpu_count": {"oneOf": [
166+
{"type": "string"},
167+
{"type": "integer", "minimum": 0}
168+
]},
169+
"cpu_percent": {"oneOf": [
170+
{"type": "string"},
171+
{"type": "integer", "minimum": 0, "maximum": 100}
172+
]},
168173
"cpu_shares": {"type": ["number", "string"]},
169174
"cpu_quota": {"type": ["number", "string"]},
170175
"cpu_period": {"type": ["number", "string"]},
@@ -193,7 +198,7 @@
193198
"type": "object",
194199
"additionalProperties": false,
195200
"properties": {
196-
"restart": {"type": "boolean"},
201+
"restart": {"type": ["boolean", "string"]},
197202
"required": {
198203
"type": "boolean",
199204
"default": true
@@ -254,7 +259,7 @@
254259
"healthcheck": {"$ref": "#/definitions/healthcheck"},
255260
"hostname": {"type": "string"},
256261
"image": {"type": "string"},
257-
"init": {"type": "boolean"},
262+
"init": {"type": ["boolean", "string"]},
258263
"ipc": {"type": "string"},
259264
"isolation": {"type": "string"},
260265
"labels": {"$ref": "#/definitions/list_or_dict"},
@@ -277,7 +282,7 @@
277282
"mac_address": {"type": "string"},
278283
"mem_limit": {"type": ["number", "string"]},
279284
"mem_reservation": {"type": ["string", "integer"]},
280-
"mem_swappiness": {"type": "integer"},
285+
"mem_swappiness": {"type": ["integer", "string"]},
281286
"memswap_limit": {"type": ["number", "string"]},
282287
"network_mode": {"type": "string"},
283288
"networks": {
@@ -315,24 +320,27 @@
315320
}
316321
]
317322
},
318-
"oom_kill_disable": {"type": "boolean"},
319-
"oom_score_adj": {"type": "integer", "minimum": -1000, "maximum": 1000},
323+
"oom_kill_disable": {"type": ["boolean", "string"]},
324+
"oom_score_adj": {"oneOf": [
325+
{"type": "string"},
326+
{"type": "integer", "minimum": -1000, "maximum": 1000}
327+
]},
320328
"pid": {"type": ["string", "null"]},
321329
"pids_limit": {"type": ["number", "string"]},
322330
"platform": {"type": "string"},
323331
"ports": {
324332
"type": "array",
325333
"items": {
326334
"oneOf": [
327-
{"type": "number", "format": "ports"},
328-
{"type": "string", "format": "ports"},
335+
{"type": "number"},
336+
{"type": "string"},
329337
{
330338
"type": "object",
331339
"properties": {
332340
"name": {"type": "string"},
333341
"mode": {"type": "string"},
334342
"host_ip": {"type": "string"},
335-
"target": {"type": "integer"},
343+
"target": {"type": ["integer", "string"]},
336344
"published": {"type": ["string", "integer"]},
337345
"protocol": {"type": "string"},
338346
"app_protocol": {"type": "string"}
@@ -344,29 +352,29 @@
344352
},
345353
"uniqueItems": true
346354
},
347-
"privileged": {"type": "boolean"},
355+
"privileged": {"type": ["boolean", "string"]},
348356
"profiles": {"$ref": "#/definitions/list_of_strings"},
349357
"pull_policy": {"type": "string", "enum": [
350358
"always", "never", "if_not_present", "build", "missing"
351359
]},
352-
"read_only": {"type": "boolean"},
360+
"read_only": {"type": ["boolean", "string"]},
353361
"restart": {"type": "string"},
354362
"runtime": {
355363
"type": "string"
356364
},
357365
"scale": {
358-
"type": "integer"
366+
"type": ["integer", "string"]
359367
},
360368
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
361369
"shm_size": {"type": ["number", "string"]},
362370
"secrets": {"$ref": "#/definitions/service_config_or_secret"},
363371
"sysctls": {"$ref": "#/definitions/list_or_dict"},
364-
"stdin_open": {"type": "boolean"},
365-
"stop_grace_period": {"type": "string", "format": "duration"},
372+
"stdin_open": {"type": ["boolean", "string"]},
373+
"stop_grace_period": {"type": "string"},
366374
"stop_signal": {"type": "string"},
367375
"storage_opt": {"type": "object"},
368376
"tmpfs": {"$ref": "#/definitions/string_or_list"},
369-
"tty": {"type": "boolean"},
377+
"tty": {"type": ["boolean", "string"]},
370378
"ulimits": {"$ref": "#/definitions/ulimits"},
371379
"user": {"type": "string"},
372380
"uts": {"type": "string"},
@@ -383,13 +391,13 @@
383391
"type": {"type": "string"},
384392
"source": {"type": "string"},
385393
"target": {"type": "string"},
386-
"read_only": {"type": "boolean"},
394+
"read_only": {"type": ["boolean", "string"]},
387395
"consistency": {"type": "string"},
388396
"bind": {
389397
"type": "object",
390398
"properties": {
391399
"propagation": {"type": "string"},
392-
"create_host_path": {"type": "boolean"},
400+
"create_host_path": {"type": ["boolean", "string"]},
393401
"selinux": {"type": "string", "enum": ["z", "Z"]}
394402
},
395403
"additionalProperties": false,
@@ -398,7 +406,7 @@
398406
"volume": {
399407
"type": "object",
400408
"properties": {
401-
"nocopy": {"type": "boolean"},
409+
"nocopy": {"type": ["boolean", "string"]},
402410
"subpath": {"type": "string"}
403411
},
404412
"additionalProperties": false,
@@ -413,7 +421,7 @@
413421
{"type": "string"}
414422
]
415423
},
416-
"mode": {"type": "number"}
424+
"mode": {"type": ["number", "string"]}
417425
},
418426
"additionalProperties": false,
419427
"patternProperties": {"^x-": {}}
@@ -441,18 +449,18 @@
441449
"id": "#/definitions/healthcheck",
442450
"type": "object",
443451
"properties": {
444-
"disable": {"type": "boolean"},
445-
"interval": {"type": "string", "format": "duration"},
446-
"retries": {"type": "number"},
452+
"disable": {"type": ["boolean", "string"]},
453+
"interval": {"type": "string"},
454+
"retries": {"type": ["number", "string"]},
447455
"test": {
448456
"oneOf": [
449457
{"type": "string"},
450458
{"type": "array", "items": {"type": "string"}}
451459
]
452460
},
453-
"timeout": {"type": "string", "format": "duration"},
454-
"start_period": {"type": "string", "format": "duration"},
455-
"start_interval": {"type": "string", "format": "duration"}
461+
"timeout": {"type": "string"},
462+
"start_period": {"type": "string"},
463+
"start_interval": {"type": "string"}
456464
},
457465
"additionalProperties": false,
458466
"patternProperties": {"^x-": {}}
@@ -484,16 +492,16 @@
484492
"properties": {
485493
"mode": {"type": "string"},
486494
"endpoint_mode": {"type": "string"},
487-
"replicas": {"type": "integer"},
495+
"replicas": {"type": ["integer", "string"]},
488496
"labels": {"$ref": "#/definitions/list_or_dict"},
489497
"rollback_config": {
490498
"type": "object",
491499
"properties": {
492-
"parallelism": {"type": "integer"},
493-
"delay": {"type": "string", "format": "duration"},
500+
"parallelism": {"type": ["integer", "string"]},
501+
"delay": {"type": "string"},
494502
"failure_action": {"type": "string"},
495-
"monitor": {"type": "string", "format": "duration"},
496-
"max_failure_ratio": {"type": "number"},
503+
"monitor": {"type": "string"},
504+
"max_failure_ratio": {"type": ["number", "string"]},
497505
"order": {"type": "string", "enum": [
498506
"start-first", "stop-first"
499507
]}
@@ -504,11 +512,11 @@
504512
"update_config": {
505513
"type": "object",
506514
"properties": {
507-
"parallelism": {"type": "integer"},
508-
"delay": {"type": "string", "format": "duration"},
515+
"parallelism": {"type": ["integer", "string"]},
516+
"delay": {"type": "string"},
509517
"failure_action": {"type": "string"},
510-
"monitor": {"type": "string", "format": "duration"},
511-
"max_failure_ratio": {"type": "number"},
518+
"monitor": {"type": "string"},
519+
"max_failure_ratio": {"type": ["number", "string"]},
512520
"order": {"type": "string", "enum": [
513521
"start-first", "stop-first"
514522
]}
@@ -524,7 +532,7 @@
524532
"properties": {
525533
"cpus": {"type": ["number", "string"]},
526534
"memory": {"type": "string"},
527-
"pids": {"type": "integer"}
535+
"pids": {"type": ["integer", "string"]}
528536
},
529537
"additionalProperties": false,
530538
"patternProperties": {"^x-": {}}
@@ -548,9 +556,9 @@
548556
"type": "object",
549557
"properties": {
550558
"condition": {"type": "string"},
551-
"delay": {"type": "string", "format": "duration"},
552-
"max_attempts": {"type": "integer"},
553-
"window": {"type": "string", "format": "duration"}
559+
"delay": {"type": "string"},
560+
"max_attempts": {"type": ["integer", "string"]},
561+
"window": {"type": "string"}
554562
},
555563
"additionalProperties": false,
556564
"patternProperties": {"^x-": {}}
@@ -570,7 +578,7 @@
570578
"patternProperties": {"^x-": {}}
571579
}
572580
},
573-
"max_replicas_per_node": {"type": "integer"}
581+
"max_replicas_per_node": {"type": ["integer", "string"]}
574582
},
575583
"additionalProperties": false,
576584
"patternProperties": {"^x-": {}}
@@ -590,7 +598,7 @@
590598
"type": "object",
591599
"properties": {
592600
"kind": {"type": "string"},
593-
"value": {"type": "number"}
601+
"value": {"type": ["number", "string"]}
594602
},
595603
"additionalProperties": false,
596604
"patternProperties": {"^x-": {}}
@@ -655,7 +663,7 @@
655663
"items": {
656664
"type": "object",
657665
"properties": {
658-
"subnet": {"type": "string", "format": "subnet_ip_address"},
666+
"subnet": {"type": "string"},
659667
"ip_range": {"type": "string"},
660668
"gateway": {"type": "string"},
661669
"aux_addresses": {
@@ -678,7 +686,7 @@
678686
"patternProperties": {"^x-": {}}
679687
},
680688
"external": {
681-
"type": ["boolean", "object"],
689+
"type": ["boolean", "string", "object"],
682690
"properties": {
683691
"name": {
684692
"deprecated": true,
@@ -688,9 +696,9 @@
688696
"additionalProperties": false,
689697
"patternProperties": {"^x-": {}}
690698
},
691-
"internal": {"type": "boolean"},
692-
"enable_ipv6": {"type": "boolean"},
693-
"attachable": {"type": "boolean"},
699+
"internal": {"type": ["boolean", "string"]},
700+
"enable_ipv6": {"type": ["boolean", "string"]},
701+
"attachable": {"type": ["boolean", "string"]},
694702
"labels": {"$ref": "#/definitions/list_or_dict"}
695703
},
696704
"additionalProperties": false,
@@ -710,7 +718,7 @@
710718
}
711719
},
712720
"external": {
713-
"type": ["boolean", "object"],
721+
"type": ["boolean", "string", "object"],
714722
"properties": {
715723
"name": {
716724
"deprecated": true,
@@ -734,7 +742,7 @@
734742
"environment": {"type": "string"},
735743
"file": {"type": "string"},
736744
"external": {
737-
"type": ["boolean", "object"],
745+
"type": ["boolean", "string", "object"],
738746
"properties": {
739747
"name": {"type": "string"}
740748
}
@@ -762,7 +770,7 @@
762770
"environment": {"type": "string"},
763771
"file": {"type": "string"},
764772
"external": {
765-
"type": ["boolean", "object"],
773+
"type": ["boolean", "string", "object"],
766774
"properties": {
767775
"name": {
768776
"deprecated": true,
@@ -801,7 +809,7 @@
801809
"type": "string"
802810
},
803811
"required": {
804-
"type": "boolean",
812+
"type": ["boolean", "string"],
805813
"default": true
806814
}
807815
},
@@ -855,7 +863,7 @@
855863
"type": "object",
856864
"properties": {
857865
"path": {"type": "string"},
858-
"weight": {"type": "integer"}
866+
"weight": {"type": ["integer", "string"]}
859867
},
860868
"additionalProperties": false
861869
},
@@ -871,7 +879,7 @@
871879
"target": {"type": "string"},
872880
"uid": {"type": "string"},
873881
"gid": {"type": "string"},
874-
"mode": {"type": "number"}
882+
"mode": {"type": ["number", "string"]}
875883
},
876884
"additionalProperties": false,
877885
"patternProperties": {"^x-": {}}
@@ -884,12 +892,12 @@
884892
"patternProperties": {
885893
"^[a-z]+$": {
886894
"oneOf": [
887-
{"type": "integer"},
895+
{"type": ["integer", "string"]},
888896
{
889897
"type": "object",
890898
"properties": {
891-
"hard": {"type": "integer"},
892-
"soft": {"type": "integer"}
899+
"hard": {"type": ["integer", "string"]},
900+
"soft": {"type": ["integer", "string"]}
893901
},
894902
"required": ["soft", "hard"],
895903
"additionalProperties": false,

0 commit comments

Comments
 (0)