Add ?format=toml support to /recipes/info/

This will return the recipe in TOML format. Note that this does not
include any extra information about errors. Just the recipes, any
unrecognized recipe names will be skipped.
This commit is contained in:
Brian C. Lane 2018-03-08 14:24:37 -08:00
parent b0d91204a4
commit 413964b92f

View File

@ -959,6 +959,7 @@ def v0_api(api):
def v0_recipes_info(recipe_names):
"""Return the contents of the recipe, or a list of recipes"""
branch = request.args.get("branch", "master")
out_fmt = request.args.get("format", "json")
recipes = []
changes = []
errors = []
@ -1003,6 +1004,10 @@ def v0_api(api):
recipes = sorted(recipes, key=lambda r: r["name"].lower())
errors = sorted(errors, key=lambda e: e["recipe"].lower())
if out_fmt == "toml":
# With TOML output we just want to dump the raw recipe, skipping the rest.
return "\n\n".join([r.toml() for r in recipes])
else:
return jsonify(changes=changes, recipes=recipes, errors=errors)
@api.route("/api/v0/recipes/changes/<recipe_names>")