Skip to content

Commit

Permalink
Merge pull request #22 from joshwget/modify-schema
Browse files Browse the repository at this point in the history
Modify libcompose schema to support Rancher Compose specific fields
  • Loading branch information
ibuildthecloud authored Oct 11, 2016
2 parents fade001 + e21e6f3 commit 48aa7f3
Show file tree
Hide file tree
Showing 7 changed files with 592 additions and 2 deletions.
3 changes: 3 additions & 0 deletions generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

//go:generate go run scripts/inline_schema.go
1 change: 1 addition & 0 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ OS_ARCH_ARG[linux]="amd64 arm"
OS_ARCH_ARG[windows]="386 amd64"
OS_ARCH_ARG[darwin]="amd64"

go generate
go build -ldflags="-w -s -X main.VERSION=$VERSION" -o bin/rancher

if [ -n "$CROSS" ]; then
Expand Down
205 changes: 205 additions & 0 deletions scripts/config_schema_v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "config_schema_v1.json",

"type": "object",

"patternProperties": {
"^[a-zA-Z0-9._-]+$": {
"$ref": "#/definitions/service"
}
},

"additionalProperties": false,

"definitions": {
"service": {
"id": "#/definitions/service",
"type": "object",

"properties": {
"build": {"type": "string"},
"cap_add": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"cap_drop": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"certs": {"$ref": "#/definitions/list_of_strings"},
"cgroup_parent": {"type": "string"},
"command": {
"oneOf": [
{"type": "string"},
{"type": "array", "items": {"type": "string"}}
]
},
"container_name": {"type": "string"},
"cpu_shares": {"type": ["number", "string"]},
"cpu_quota": {"type": ["number", "string"]},
"cpuset": {"type": "string"},
"device_read_iops": {"$ref": "#/definitions/list_or_dict"},
"devices": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"device_write_iops": {"$ref": "#/definitions/list_or_dict"},
"default_cert": {"type": "string"},
"disks": {"type": "array"},
"dns": {"$ref": "#/definitions/string_or_list"},
"dns_search": {"$ref": "#/definitions/string_or_list"},
"dockerfile": {"type": "string"},
"domainname": {"type": "string"},
"entrypoint": {
"oneOf": [
{"type": "string"},
{"type": "array", "items": {"type": "string"}}
]
},
"env_file": {"$ref": "#/definitions/string_or_list"},
"environment": {"$ref": "#/definitions/list_or_dict"},

"expose": {
"type": "array",
"items": {
"type": ["string", "number"],
"format": "expose"
},
"uniqueItems": true
},

"extends": {
"oneOf": [
{
"type": "string"
},
{
"type": "object",

"properties": {
"service": {"type": "string"},
"file": {"type": "string"}
},
"required": ["service"],
"additionalProperties": false
}
]
},

"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"external_ips": {"$ref": "#/definitions/list_of_strings"},
"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"health_check": {"type": "object"},
"hostname": {"type": "string"},
"image": {"type": "string"},
"ipc": {"type": "string"},
"labels": {"$ref": "#/definitions/list_or_dict"},
"links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"load_balancer_config": {"type": "object"},
"log_driver": {"type": "string"},
"log_opt": {"type": "object"},
"mac_address": {"type": "string"},
"memory": {"type": ["number", "string"]},
"mem_limit": {"type": ["number", "string"]},
"memswap_limit": {"type": ["number", "string"]},
"mem_swappiness": {"type": "integer"},
"metadata": {"type": "object"},
"net": {"type": "string"},
"pid": {"type": ["string", "null"]},

"ports": {
"type": "array",
"items": {
"type": ["string", "number"],
"format": "ports"
},
"uniqueItems": true
},

"privileged": {"type": "boolean"},
"read_only": {"type": "boolean"},
"restart": {"type": "string"},
"retain_ip": {"type": "boolean"},
"scale": {"type": ["number", "string"]},
"scale_policy": {"type": "object"},
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"shm_size": {"type": ["number", "string"]},
"stdin_open": {"type": "boolean"},
"stop_signal": {"type": "string"},
"tty": {"type": "boolean"},
"type": {"type": "string"},
"update_strategy": {"type": "object"},
"ulimits": {
"type": "object",
"patternProperties": {
"^[a-z]+$": {
"oneOf": [
{"type": "integer"},
{
"type":"object",
"properties": {
"hard": {"type": "integer"},
"soft": {"type": "integer"}
},
"required": ["soft", "hard"],
"additionalProperties": false
}
]
}
}
},
"user": {"type": "string"},
"userdata": {"type": "string"},
"vcpu": {"type": ["number", "string"]},
"volumes": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"volume_driver": {"type": "string"},
"volumes_from": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"working_dir": {"type": "string"}
},

"dependencies": {
"memswap_limit": ["mem_limit"]
},
"additionalProperties": false
},

"string_or_list": {
"oneOf": [
{"type": "string"},
{"$ref": "#/definitions/list_of_strings"}
]
},

"list_of_strings": {
"type": "array",
"items": {"type": "string"},
"uniqueItems": true
},

"list_or_dict": {
"oneOf": [
{
"type": "object",
"patternProperties": {
".+": {
"type": ["string", "number", "null", "boolean"]
}
},
"additionalProperties": false
},
{"type": "array", "items": {"type": "string"}, "uniqueItems": true}
]
},

"constraints": {
"service": {
"id": "#/definitions/constraints/service",
"anyOf": [
{
"required": ["build"],
"not": {"required": ["image"]}
},
{
"required": ["image"],
"not": {"anyOf": [
{"required": ["build"]},
{"required": ["dockerfile"]}
]}
}
]
}
}
}
}
Loading

0 comments on commit 48aa7f3

Please sign in to comment.