diff --git a/application.py b/application.py index d8d29a177..2244902c1 100644 --- a/application.py +++ b/application.py @@ -2,16 +2,25 @@ import logging from app import app as application + +logging.basicConfig(**application.config['LOGGING_CONFIG']) + + import endpoints.index import endpoints.api import endpoints.web import endpoints.tags import endpoints.registry + +logger = logging.getLogger(__name__) + +if application.config.get('INCLUDE_TEST_ENDPOINTS', False): + logger.debug('Loading test endpoints.') + import endpoints.test + # Remove this for prod config application.debug = True -logging.basicConfig(**application.config['LOGGING_CONFIG']) - if __name__ == '__main__': application.run(port=5000, debug=True, host='0.0.0.0') diff --git a/config.py b/config.py index 1aab5b5fe..a51e2700f 100644 --- a/config.py +++ b/config.py @@ -105,6 +105,7 @@ class DebugConfig(FlaskConfig, MailConfig, LocalStorage, SQLiteDB, } SEND_FILE_MAX_AGE_DEFAULT = 0 POPULATE_DB_TEST_DATA = True + INCLUDE_TEST_ENDPOINTS = True class LocalHostedConfig(FlaskConfig, MailConfig, S3Storage, RDSMySQL, diff --git a/endpoints/api.py b/endpoints/api.py index a8b3c59c9..d56cd12f4 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -397,6 +397,8 @@ def get_repo_builds(namespace, repository): 'builds': [build_view(build) for build in builds] }) + abort(403) # Permissions denied + def role_view(repo_perm_obj): return { diff --git a/initdb.py b/initdb.py index 562a29e16..79519ee7f 100644 --- a/initdb.py +++ b/initdb.py @@ -5,6 +5,7 @@ import os import hashlib from datetime import datetime, timedelta +from flask import url_for import storage @@ -95,6 +96,8 @@ def __generate_repository(user, name, description, is_public, permissions, create_subtree(repo, structure, None) + return repo + if __name__ == '__main__': initialize_db() @@ -141,6 +144,12 @@ if __name__ == '__main__': 'Shared repository, another user can write.', False, [(new_user_2, 'write')], (5, [], 'latest')) - __generate_repository(new_user_1, 'empty', - 'Empty repository with no images or tags.', False, - [], (0, [], None)) \ No newline at end of file + building = __generate_repository(new_user_1, 'building', + 'Empty repository which is building.', + False, [], (0, [], None)) + + build = model.create_repository_build(building, '123-45-6789') + build.build_node_id = 1 + build.phase = 'building' + build.status_url = 'http://localhost:5000/test/build/status' + build.save() diff --git a/test/data/test.db b/test/data/test.db index 48de7babe..32075f2bd 100644 Binary files a/test/data/test.db and b/test/data/test.db differ diff --git a/workers/dockerfilebuild.py b/workers/dockerfilebuild.py index 4fbc48cac..d04f98ced 100644 --- a/workers/dockerfilebuild.py +++ b/workers/dockerfilebuild.py @@ -115,12 +115,13 @@ def babysit_builder(request): # wait for the job to be complete status_url = start_build.headers['Location'] + repository_build.phase = 'building' repository_build.status_url = status_url repository_build.save() logger.debug('Waiting for job to be complete') status = get_status(status_url) - while status != 'error' and status != 'completed': + while status != 'error' and status != 'complete': logger.debug('Job status is: %s' % status) time.sleep(5) status = get_status(status_url) @@ -129,7 +130,7 @@ def babysit_builder(request): if status == 'error': repository_build.phase = 'error' else: - repository_build.phase = 'completed' + repository_build.phase = 'complete' # clean up the DO node logger.debug('Cleaning up DO node.')