Coverage for appr/api/builder.py: 0%

# Coverage for appr/api/builder.py : 0%

## 32 statements 0 run 32 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | from flask import jsonify, Blueprint, current_app import appr.api.impl.builder from appr.api.app import getvalues from appr.api.app import repo_name builder_app = Blueprint('builder', __name__) # pylint: disable=C0103 def _build(package, version, media_type='kpm'): values = getvalues() namespace = values.get('namespace', None) variables = values.get('variables', {}) shards = values.get('shards', None) variables['namespace'] = namespace k = appr.api.impl.builder.build(package, version_query=version, namespace=namespace, variables=variables, shards=shards, endpoint=current_app.config['APPR_REGISTRY_HOST']) return k @builder_app.route( "/api/v1/packages/<string:namespace>/<string:package_name>/file/<path:filepath>") def show_file(namespace, package_name, filepath): reponame = repo_name(namespace, package_name) return appr.api.impl.builder.show_file(reponame, filepath, endpoint=current_app.config['APPR_REGISTRY_HOST']) @builder_app.route( "/api/v1/packages/<string:namespace>/<string:package_name>/<string:release>/<string:media_type>/tree" ) def tree(namespace, package_name, release, media_type): reponame = repo_name(namespace, package_name) response = appr.api.impl.builder.tree(reponame, endpoint=current_app.config['APPR_REGISTRY_HOST']) return jsonify(response) @builder_app.route( "/api/v1/packages/<string:namespace>/<string:package_name>/<string:release>/<string:media_type>/generate", methods=['POST', 'GET']) def build(namespace, package_name, release, media_type): reponame = repo_name(namespace, package_name) current_app.logger.info("generate %s", namespace, package_name) k = _build(reponame, release, media_type) return jsonify(k.build()) @builder_app.route( "/api/v1/packages/<string:namespace>/<string:package_name>/<string:release>/<string:media_type>/generate-tar", methods=['POST', 'GET']) def build_tar(namespace, package_name, release, media_type): reponame = repo_name(namespace, package_name) k = _build(reponame, release, media_type) resp = current_app.make_response(k.build_tar()) resp.mimetype = 'application/tar' resp.headers['Content-Disposition'] = 'filename="%s_%s.tar.gz"' % (k.name.replace("/", "_"), k.version) return resp