From bfc1cebbc402bb5ec97f443c8f2c3cb9ccdc7abd Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Jun 23 2017 10:39:48 +0000 Subject: 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ář --- diff --git a/pungi/checks.py b/pungi/checks.py index 60a496f..190779f 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -509,6 +509,25 @@ def _make_schema(): "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": { "type": "array", "items": { @@ -986,23 +1005,16 @@ def _make_schema(): # format does not let us validate it as there is no regular # expression to describe all regular expressions. ".+": { - "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", + "anyOf": [ + {"$ref": "#/definitions/osbs_config"}, + { + "type": "array", + "items": { + "$ref": "#/definitions/osbs_config", + }, }, - "gpgkey": {"type": "string"}, - "git_branch": {"type": "string"}, - }, - "required": ["url", "target", "git_branch"] - } + ], + }, }, "additionalProperties": False, }, diff --git a/tests/test_osbs_phase.py b/tests/test_osbs_phase.py index 3e59dca..4d16cc0 100644 --- a/tests/test_osbs_phase.py +++ b/tests/test_osbs_phase.py @@ -248,7 +248,7 @@ class OSBSThreadTest(helpers.PungiTestCase): '^Server$': cfg } 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)) @mock.patch('pungi.util.resolve_git_url')