Skip to content

Commit

Permalink
Allow use of x- extension fields everywhere
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed May 14, 2020
1 parent 67e9192 commit d4eea0f
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 36 deletions.
103 changes: 68 additions & 35 deletions schema/config_schema_v3.9.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
"target": {"type": "string"},
"shm_size": {"type": ["integer", "string"]}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
]
},
Expand All @@ -119,7 +120,9 @@
"uid": {"type": "string"},
"gid": {"type": "string"},
"mode": {"type": "number"}
}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
]
}
Expand All @@ -132,7 +135,8 @@
"file": {"type": "string"},
"registry": {"type": "string"}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"depends_on": {"$ref": "#/definitions/list_of_strings"},
"devices": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
Expand Down Expand Up @@ -180,7 +184,8 @@
}
}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},

"mac_address": {"type": "string"},
Expand All @@ -201,7 +206,8 @@
"ipv4_address": {"type": "string"},
"ipv6_address": {"type": "string"}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
{"type": "null"}
]
Expand All @@ -227,7 +233,8 @@
"published": {"type": "integer"},
"protocol": {"type": "string"}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
]
},
Expand All @@ -252,7 +259,9 @@
"uid": {"type": "string"},
"gid": {"type": "string"},
"mode": {"type": "number"}
}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
]
}
Expand All @@ -276,7 +285,8 @@
"soft": {"type": "integer"}
},
"required": ["soft", "hard"],
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
]
}
Expand All @@ -302,13 +312,17 @@
"type": "object",
"properties": {
"propagation": {"type": "string"}
}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"volume": {
"type": "object",
"properties": {
"nocopy": {"type": "boolean"}
}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"tmpfs": {
"type": "object",
Expand All @@ -317,10 +331,13 @@
"type": "integer",
"minimum": 0
}
}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
],
"uniqueItems": true
Expand All @@ -335,7 +352,6 @@
"healthcheck": {
"id": "#/definitions/healthcheck",
"type": "object",
"additionalProperties": false,
"properties": {
"disable": {"type": "boolean"},
"interval": {"type": "string", "format": "duration"},
Expand All @@ -348,7 +364,9 @@
},
"timeout": {"type": "string", "format": "duration"},
"start_period": {"type": "string", "format": "duration"}
}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"deployment": {
"id": "#/definitions/deployment",
Expand All @@ -370,7 +388,8 @@
"start-first", "stop-first"
]}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"update_config": {
"type": "object",
Expand All @@ -384,7 +403,8 @@
"start-first", "stop-first"
]}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"resources": {
"type": "object",
Expand All @@ -395,7 +415,8 @@
"cpus": {"type": "string"},
"memory": {"type": "string"}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"reservations": {
"type": "object",
Expand All @@ -404,10 +425,12 @@
"memory": {"type": "string"},
"generic_resources": {"$ref": "#/definitions/generic_resources"}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"restart_policy": {
"type": "object",
Expand All @@ -417,7 +440,8 @@
"max_attempts": {"type": "integer"},
"window": {"type": "string", "format": "duration"}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"placement": {
"type": "object",
Expand All @@ -430,15 +454,18 @@
"properties": {
"spread": {"type": "string"}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
},
"max_replicas_per_node": {"type": "integer"}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},

"generic_resources": {
Expand All @@ -453,10 +480,12 @@
"kind": {"type": "string"},
"value": {"type": "number"}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
},

Expand All @@ -483,11 +512,13 @@
"properties": {
"subnet": {"type": "string"}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"external": {
"type": ["boolean", "object"],
Expand All @@ -497,14 +528,15 @@
"type": "string"
}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"internal": {"type": "boolean"},
"attachable": {"type": "boolean"},
"labels": {"$ref": "#/definitions/list_or_dict"}
},
"patternProperties": {"^x-": {}},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},

"volume": {
Expand All @@ -527,7 +559,8 @@
"type": "string"
}
},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"labels": {"$ref": "#/definitions/list_or_dict"}
},
Expand Down Expand Up @@ -557,8 +590,8 @@
},
"template_driver": {"type": "string"}
},
"patternProperties": {"^x-": {}},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},

"config": {
Expand All @@ -579,8 +612,8 @@
"labels": {"$ref": "#/definitions/list_or_dict"},
"template_driver": {"type": "string"}
},
"patternProperties": {"^x-": {}},
"additionalProperties": false
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},

"string_or_list": {
Expand Down
8 changes: 7 additions & 1 deletion spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1672,14 +1672,20 @@ volumes:

## Extension

Special extensions fields can be of any format as long as they are located at the root of your Compose file, or first level element, and their name starts with the `x-` character sequence.
Special extension fields can be of any format as long as their name starts with the `x-` character sequence. They can be used
within any structure in a Compose file. This is the sole exception for Compose implementations to silently ignore unrecognized field.

```yml
version: "3"
x-custom:
foo:
- bar
- zot
services:
webapp:
image: awesome/webapp
x-foo: bar
```

The contents of such fields are unspecified by Compose specification, and can be used to enable custom features. Compose implementation to encounter an unknown extension field MUST NOT fail, but COULD warn about unknown field.
Expand Down

0 comments on commit d4eea0f

Please sign in to comment.