Skip to content

Commit

Permalink
Merge pull request #186 from mesosphere/newschema
Browse files Browse the repository at this point in the history
update app json-schema
  • Loading branch information
jsancio committed May 28, 2015
2 parents d5d99cb + 9974396 commit fdf143d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 26 deletions.
76 changes: 69 additions & 7 deletions cli/dcoscli/data/marathon-group-schema.json
Expand Up @@ -4,7 +4,33 @@
"definitions": {
"app": {
"additionalProperties": false,
"definitions": {
"pathType": {
"pattern": "^(\\/?((\\.{2})|([a-z0-9\\-]*))($|\\/))*$",
"type": "string"
}
},
"not": {
"allOf": [
{
"required": [
"cmd"
]
},
{
"required": [
"args"
]
}
]
},
"properties": {
"acceptedResourceRoles": {
"items": {
"type": "string"
},
"type": "array"
},
"args": {
"items": {
"type": "string"
Expand All @@ -20,6 +46,7 @@
"type": "integer"
},
"cmd": {
"minLength": 1,
"type": "string"
},
"constraints": {},
Expand All @@ -29,12 +56,27 @@
"docker": {
"additionalProperties": false,
"properties": {
"forcePullImage": {
"type": "boolean"
},
"image": {
"type": "string"
},
"network": {
"type": "string"
},
"parameters": {
"items": {
"additionalProperties": false,
"properties": {},
"required": [
"key",
"value"
],
"type": "object"
},
"type": "array"
},
"portMappings": {
"items": {
"additionalProperties": false,
Expand All @@ -61,6 +103,9 @@
"type": "object"
},
"type": "array"
},
"privileged": {
"type": "boolean"
}
},
"required": [
Expand Down Expand Up @@ -98,8 +143,7 @@
},
"dependencies": {
"items": {
"pattern": "^/?(([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])\\.)*([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])$",
"type": "string"
"$ref": "#/definitions/pathType"
},
"type": "array"
},
Expand All @@ -116,6 +160,7 @@
"type": "object"
},
"executor": {
"pattern": "^(|\\/\\/cmd|\\/?[^\\/]+(\\/[^\\/]+)*)$",
"type": "string"
},
"healthChecks": {
Expand All @@ -129,6 +174,9 @@
"minimum": 0,
"type": "integer"
},
"ignoreHttp1xx": {
"type": "boolean"
},
"intervalSeconds": {
"minimum": 0,
"type": "integer"
Expand Down Expand Up @@ -157,7 +205,7 @@
"type": "array"
},
"id": {
"pattern": "^/?(([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])\\.)*([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])$",
"pattern": "^(\\/?((\\.{2})|([a-z0-9][a-z0-9\\-]*[a-z0-9]+)|([a-z0-9]*))($|\\/))*$",
"type": "string"
},
"instances": {
Expand All @@ -170,6 +218,10 @@
},
"type": "object"
},
"maxLaunchDelaySeconds": {
"minimum": 0,
"type": "integer"
},
"mem": {
"minimum": 0,
"type": "number"
Expand All @@ -185,9 +237,6 @@
"requirePorts": {
"type": "boolean"
},
"required": [
"id"
],
"storeUrls": {
"items": {
"type": "string"
Expand All @@ -197,6 +246,11 @@
"upgradeStrategy": {
"additionalProperties": false,
"properties": {
"maximumOverCapacity": {
"maximum": 1.0,
"minimum": 0.0,
"type": "number"
},
"minimumHealthCapacity": {
"maximum": 1.0,
"minimum": 0.0,
Expand All @@ -213,8 +267,16 @@
},
"user": {
"type": "string"
},
"version": {
"format": "date-time",
"type": "string"
}
}
},
"required": [
"id"
],
"type": "object"
}
},
"properties": {
Expand Down
10 changes: 0 additions & 10 deletions cli/dcoscli/marathon/main.py
Expand Up @@ -472,8 +472,6 @@ def _start(app_id, instances, force):
desc['instances']))
return 1

schema = _app_schema()

# Need to add the 'id' because it is required
app_json = {'id': app_id}

Expand All @@ -490,10 +488,6 @@ def _start(app_id, instances, force):

app_json['instances'] = instances

errs = util.validate_json(app_json, schema)
if errs:
raise DCOSException(util.list_to_err(errs))

deployment = client.update_app(app_id, app_json, force)

emitter.publish('Created deployment {}'.format(deployment))
Expand Down Expand Up @@ -575,10 +569,6 @@ def _update(app_id, json_items, force):
else:
app_json[key] = value

errs = util.validate_json(app_json, schema)
if errs:
raise DCOSException(util.list_to_err(errs))

deployment = client.update_app(app_id, app_json, force)

emitter.publish('Created deployment {}'.format(deployment))
Expand Down
10 changes: 1 addition & 9 deletions cli/tests/integrations/cli/test_marathon_groups.py
Expand Up @@ -94,18 +94,10 @@ def test_add_bad_complicated_group():
['dcos', 'marathon', 'group', 'add'],
stdin=fd)

# id for group in test-group/more-groups
err = "Property missing which is mandatory"
# missing id in apps in appingroups
err2 = "identifier / is not child of /test-group/appingroups"
# missing cmd in appingroups
err3 = "AppDefinition must either contain one of 'cmd' or 'args', " + \
"and/or a 'container'"
err = "Error: missing required property 'id'"
assert returncode == 1
assert stdout == b''
assert err in stderr.decode('utf-8')
assert err2 in stderr.decode('utf-8')
assert err3 in stderr.decode('utf-8')


def _list_groups(group_id=None):
Expand Down

0 comments on commit fdf143d

Please sign in to comment.