image-build: Accept formats in lists

If the config is loaded from JSON, we will get list instead of tuple.

The validation rule does not really care whether it's a list or tuple,
it only enforces there are two strings. The definition is renamed to be
a bit more descriptive.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-03-01 13:28:28 +01:00
parent 6bd1e9da2a
commit 357f556d69
2 changed files with 4 additions and 4 deletions

View File

@ -516,7 +516,7 @@ def make_schema():
"required": ["url", "target", "git_branch"] "required": ["url", "target", "git_branch"]
}, },
"string_tuples": { "string_pairs": {
"type": "array", "type": "array",
"items": { "items": {
"type": "array", "type": "array",
@ -940,7 +940,7 @@ def make_schema():
}, },
"translate_paths": { "translate_paths": {
"$ref": "#/definitions/string_tuples", "$ref": "#/definitions/string_pairs",
"default": [], "default": [],
}, },
@ -1145,7 +1145,7 @@ def make_schema():
"format": { "format": {
"anyOf": [ "anyOf": [
# The variant with explicit extension is deprecated. # The variant with explicit extension is deprecated.
{"$ref": "#/definitions/string_tuples"}, {"$ref": "#/definitions/string_pairs"},
{"$ref": "#/definitions/strings"} {"$ref": "#/definitions/strings"}
] ]
}, },

View File

@ -136,7 +136,7 @@ class ImageBuildPhase(base.PhaseLoggerMixin, base.ImageConfigMixin, base.ConfigG
# just list of formats, or a single format. # just list of formats, or a single format.
formats = [] formats = []
for format in force_list(image_conf["image-build"]["format"]): for format in force_list(image_conf["image-build"]["format"]):
formats.append(format[0] if isinstance(format, tuple) else format) formats.append(format[0] if isinstance(format, (tuple, list)) else format)
image_conf["image-build"]["format"] = formats image_conf["image-build"]["format"] = formats
image_conf["image-build"]['repo'] = self._get_repo(image_conf['image-build'], variant) image_conf["image-build"]['repo'] = self._get_repo(image_conf['image-build'], variant)