osbs: Config validation should accept a list

There can be multiple images listed for a single variant, the config
validation should not reject it.

The syntax with a single config object is still accepted. The price for
that is less descriptive error message when there are errors.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-06-23 12:36:25 +02:00
parent 079454c502
commit bfc1cebbc4
2 changed files with 29 additions and 17 deletions

View File

@ -509,6 +509,25 @@ def _make_schema():
"type": "object", "type": "object",
}, },
"osbs_config": {
"type": "object",
"properties": {
"url": {"type": "string"},
"target": {"type": "string"},
"name": {"type": "string"},
"version": {"type": "string"},
"scratch": {"type": "boolean"},
"priority": {"type": "number"},
"repo": {
"$ref": "#/definitions/repos",
"append": "repo_from",
},
"gpgkey": {"type": "string"},
"git_branch": {"type": "string"},
},
"required": ["url", "target", "git_branch"]
},
"string_tuples": { "string_tuples": {
"type": "array", "type": "array",
"items": { "items": {
@ -986,23 +1005,16 @@ def _make_schema():
# format does not let us validate it as there is no regular # format does not let us validate it as there is no regular
# expression to describe all regular expressions. # expression to describe all regular expressions.
".+": { ".+": {
"type": "object", "anyOf": [
"properties": { {"$ref": "#/definitions/osbs_config"},
"url": {"type": "string"}, {
"target": {"type": "string"}, "type": "array",
"name": {"type": "string"}, "items": {
"version": {"type": "string"}, "$ref": "#/definitions/osbs_config",
"scratch": {"type": "boolean"}, },
"priority": {"type": "number"},
"repo": {
"$ref": "#/definitions/repos",
"append": "repo_from",
}, },
"gpgkey": {"type": "string"}, ],
"git_branch": {"type": "string"}, },
},
"required": ["url", "target", "git_branch"]
}
}, },
"additionalProperties": False, "additionalProperties": False,
}, },

View File

@ -248,7 +248,7 @@ class OSBSThreadTest(helpers.PungiTestCase):
'^Server$': cfg '^Server$': cfg
} }
self.assertEqual( self.assertEqual(
(['Failed validation in osbs.^Server$: \'%s\' is a required property' % key], []), (['Failed validation in osbs.^Server$: %r is not valid under any of the given schemas' % cfg], []),
checks.validate(config)) checks.validate(config))
@mock.patch('pungi.util.resolve_git_url') @mock.patch('pungi.util.resolve_git_url')