Fix url_for for api endpoints.
This commit is contained in:
parent
535947a06d
commit
bb2767ff16
4 changed files with 14 additions and 15 deletions
|
@ -21,7 +21,8 @@ from auth.auth import process_oauth
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
api_bp = Blueprint('api', __name__)
|
||||
api = Api(api_bp)
|
||||
api = Api()
|
||||
api.init_app(api_bp)
|
||||
api.decorators = [process_oauth,
|
||||
crossdomain(origin='*', headers=['Authorization', 'Content-Type'])]
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import logging
|
||||
import json
|
||||
|
||||
from flask import request, url_for
|
||||
from flask import request
|
||||
from flask.ext.restful import abort
|
||||
|
||||
from app import app
|
||||
from endpoints.api import (RepositoryParamResource, parse_args, query_param, nickname, resource,
|
||||
require_repo_read, require_repo_write, validate_json_request,
|
||||
ApiResource, internal_only, format_date)
|
||||
ApiResource, internal_only, format_date, api)
|
||||
from endpoints.common import start_build
|
||||
from endpoints.trigger import BuildTrigger
|
||||
from data import model
|
||||
|
@ -117,14 +117,13 @@ class RepositoryBuildList(RepositoryParamResource):
|
|||
repo = model.get_repository(namespace, repository)
|
||||
display_name = user_files.get_file_checksum(dockerfile_id)
|
||||
|
||||
build_request = start_build(repo, dockerfile_id, ['latest'], display_name,
|
||||
subdir, True)
|
||||
build_request = start_build(repo, dockerfile_id, ['latest'], display_name, subdir, True)
|
||||
|
||||
resp = build_status_view(build_request, True)
|
||||
repo_string = '%s/%s' % (namespace, repository)
|
||||
headers = {
|
||||
'Location': url_for('api_bp.get_repo_build_status', repository=repo_string,
|
||||
build_uuid=build_request.uuid),
|
||||
'Location': api.url_for(RepositoryBuildStatus, repository=repo_string,
|
||||
build_uuid=build_request.uuid),
|
||||
}
|
||||
return resp, 201, headers
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ from urlparse import urlunparse
|
|||
from app import app
|
||||
from endpoints.api import (RepositoryParamResource, nickname, resource, require_repo_admin,
|
||||
log_action, request_error, query_param, parse_args,
|
||||
validate_json_request)
|
||||
from endpoints.api.build import build_status_view, trigger_view
|
||||
validate_json_request, api)
|
||||
from endpoints.api.build import build_status_view, trigger_view, RepositoryBuildStatus
|
||||
from endpoints.common import start_build
|
||||
from endpoints.trigger import (BuildTrigger, TriggerDeactivationException,
|
||||
TriggerActivationException, EmptyRepositoryException)
|
||||
|
@ -220,8 +220,8 @@ class ActivateBuildTrigger(RepositoryParamResource):
|
|||
resp = build_status_view(build_request, True)
|
||||
repo_string = '%s/%s' % (namespace, repository)
|
||||
headers = {
|
||||
'Location': url_for('api_bp.get_repo_build_status', repository=repo_string,
|
||||
build_uuid=build_request.uuid),
|
||||
'Location': api.url_for(RepositoryBuildStatus, repository=repo_string,
|
||||
build_uuid=build_request.uuid),
|
||||
}
|
||||
return resp, 201, headers
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import json
|
||||
|
||||
from flask import request, url_for
|
||||
from flask import request
|
||||
from flask.ext.restful import abort
|
||||
|
||||
from endpoints.api import (RepositoryParamResource, nickname, resource, require_repo_admin,
|
||||
log_action, validate_json_request)
|
||||
log_action, validate_json_request, api)
|
||||
from data import model
|
||||
|
||||
|
||||
|
@ -36,8 +36,7 @@ class WebhookList(RepositoryParamResource):
|
|||
resp = webhook_view(webhook)
|
||||
repo_string = '%s/%s' % (namespace, repository)
|
||||
headers = {
|
||||
'Location': url_for('api_bp.get_webhook', repository=repo_string,
|
||||
public_id=webhook.public_id),
|
||||
'Location': api.url_for(Webhook, repository=repo_string, public_id=webhook.public_id),
|
||||
}
|
||||
log_action('add_repo_webhook', namespace,
|
||||
{'repo': repository, 'webhook_id': webhook.public_id},
|
||||
|
|
Reference in a new issue