From 2fb43196c69e348da59bf097c41367229f7737bf Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 12 Sep 2016 17:33:08 -0400 Subject: [PATCH] Add well-known endpoint for Quay Fixes #1790 --- endpoints/wellknown.py | 31 +++++++++++++++++++++++++++++++ web.py | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 endpoints/wellknown.py diff --git a/endpoints/wellknown.py b/endpoints/wellknown.py new file mode 100644 index 000000000..c1a86d18d --- /dev/null +++ b/endpoints/wellknown.py @@ -0,0 +1,31 @@ +import json +import logging + +from app import get_app_url +from flask import Blueprint, make_response + +logger = logging.getLogger(__name__) +wellknown = Blueprint('wellknown', __name__) + +@wellknown.route('/app-capabilities', methods=['GET']) +def app_capabilities(): + view_image_tmpl = '%s/{namespace}/{reponame}:{tag}' % get_app_url() + image_security_tmpl = ('%s/api/v1/repository/{namespace}/{reponame}/image/{imageid}/security' % + get_app_url()) + + metadata = { + 'appName': 'io.quay', + 'capabilities': { + 'io.quay.view-image': { + 'url-template': view_image_tmpl, + }, + + 'io.quay.image-security': { + 'rest-api-template': image_security_tmpl, + }, + }, + } + + resp = make_response(json.dumps(metadata)) + resp.headers['Content-Type'] = 'application/json' + return resp diff --git a/web.py b/web.py index 3d9b007da..b33c76383 100644 --- a/web.py +++ b/web.py @@ -12,6 +12,7 @@ from endpoints.oauthlogin import oauthlogin from endpoints.realtime import realtime from endpoints.web import web from endpoints.webhooks import webhooks +from endpoints.wellknown import wellknown if os.environ.get('DEBUGLOG') == 'true': logging.config.fileConfig('conf/logging_debug.conf', disable_existing_loggers=False) @@ -25,3 +26,4 @@ application.register_blueprint(api_bp, url_prefix='/api') application.register_blueprint(webhooks, url_prefix='/webhooks') application.register_blueprint(realtime, url_prefix='/realtime') application.register_blueprint(key_server, url_prefix='/keys') +application.register_blueprint(wellknown, url_prefix='/.well-known')