Add a feature flag to advertise v2 endpoints
This commit is contained in:
parent
fee95bc096
commit
fc55730db8
2 changed files with 19 additions and 2 deletions
|
@ -189,6 +189,9 @@ class DefaultConfig(object):
|
|||
# Feature Flag: Whether users can directly login to the UI.
|
||||
FEATURE_DIRECT_LOGIN = True
|
||||
|
||||
# Feature Flag: Whether the v2/ endpoint is visible
|
||||
FEATURE_ADVERTISE_V2 = True
|
||||
|
||||
BUILD_MANAGER = ('enterprise', {})
|
||||
|
||||
DISTRIBUTED_STORAGE_CONFIG = {
|
||||
|
|
|
@ -6,7 +6,8 @@ import logging
|
|||
from flask import Blueprint, make_response, url_for, request, jsonify
|
||||
from functools import wraps
|
||||
from urlparse import urlparse
|
||||
from util import get_app_url
|
||||
|
||||
import features
|
||||
|
||||
from app import metric_queue
|
||||
from endpoints.decorators import anon_protect, anon_allowed
|
||||
|
@ -18,6 +19,7 @@ from auth.permissions import (ReadRepositoryPermission, ModifyRepositoryPermissi
|
|||
from data import model
|
||||
from util.http import abort
|
||||
from util.saas.metricqueue import time_blueprint
|
||||
from util import get_app_url
|
||||
from app import app
|
||||
|
||||
|
||||
|
@ -62,7 +64,20 @@ def get_input_stream(flask_request):
|
|||
return flask_request.stream
|
||||
|
||||
|
||||
# TODO remove when v2 is deployed everywhere
|
||||
def route_show_if(value):
|
||||
def decorator(f):
|
||||
@wraps(f)
|
||||
def decorated_function(*args, **kwargs):
|
||||
if not value:
|
||||
abort(404)
|
||||
|
||||
return f(*args, **kwargs)
|
||||
return decorated_function
|
||||
return decorator
|
||||
|
||||
@v2_bp.route('/')
|
||||
@route_show_if(features.ADVERTISE_V2)
|
||||
@process_jwt_auth
|
||||
@anon_allowed
|
||||
def v2_support_enabled():
|
||||
|
@ -86,4 +101,3 @@ from endpoints.v2 import manifest
|
|||
from endpoints.v2 import blob
|
||||
from endpoints.v2 import tag
|
||||
from endpoints.v2 import catalog
|
||||
|
||||
|
|
Reference in a new issue