Merge branch 'tagview'
This commit is contained in:
commit
3c305beeea
160 changed files with 151133 additions and 497 deletions
|
@ -148,12 +148,17 @@ class RepositoryBuildList(RepositoryParamResource):
|
|||
@require_repo_read
|
||||
@parse_args
|
||||
@query_param('limit', 'The maximum number of builds to return', type=int, default=5)
|
||||
@query_param('since', 'Returns all builds since the given unix timecode', type=int, default=None)
|
||||
@nickname('getRepoBuilds')
|
||||
def get(self, args, namespace, repository):
|
||||
""" Get the list of repository builds. """
|
||||
limit = args['limit']
|
||||
builds = list(model.list_repository_builds(namespace, repository, limit))
|
||||
limit = args.get('limit', 5)
|
||||
since = args.get('since', None)
|
||||
|
||||
if since is not None:
|
||||
since = datetime.datetime.utcfromtimestamp(since)
|
||||
|
||||
builds = model.list_repository_builds(namespace, repository, limit, since=since)
|
||||
can_write = ModifyRepositoryPermission(namespace, repository).can()
|
||||
return {
|
||||
'builds': [build_status_view(build, can_write) for build in builds]
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import logging
|
||||
import json
|
||||
import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
from flask import request
|
||||
|
||||
|
@ -177,7 +179,9 @@ class Repository(RepositoryParamResource):
|
|||
def tag_view(tag):
|
||||
return {
|
||||
'name': tag.name,
|
||||
'image_id': tag.image.docker_image_id
|
||||
'image_id': tag.image.docker_image_id,
|
||||
'last_modified': format_date(datetime.datetime.fromtimestamp(tag.lifetime_start_ts)),
|
||||
'size': tag.image.storage.aggregate_size
|
||||
}
|
||||
|
||||
organization = None
|
||||
|
@ -196,6 +200,9 @@ class Repository(RepositoryParamResource):
|
|||
active_builds = model.list_repository_builds(namespace, repository, 1,
|
||||
include_inactive=False)
|
||||
|
||||
is_starred = (model.repository_is_starred(get_authenticated_user(), repo)
|
||||
if get_authenticated_user() else False)
|
||||
|
||||
return {
|
||||
'namespace': namespace,
|
||||
'name': repository,
|
||||
|
@ -206,7 +213,18 @@ class Repository(RepositoryParamResource):
|
|||
'is_public': is_public,
|
||||
'is_building': len(list(active_builds)) > 0,
|
||||
'is_organization': bool(organization),
|
||||
'status_token': repo.badge_token if not is_public else ''
|
||||
'is_starred': is_starred,
|
||||
'status_token': repo.badge_token if not is_public else '',
|
||||
'stats': {
|
||||
'pulls': {
|
||||
'today': model.get_repository_pulls(repo, timedelta(days=1)),
|
||||
'thirty_day': model.get_repository_pulls(repo, timedelta(days=30))
|
||||
},
|
||||
'pushes': {
|
||||
'today': model.get_repository_pushes(repo, timedelta(days=1)),
|
||||
'thirty_day': model.get_repository_pushes(repo, timedelta(days=30))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
raise NotFound()
|
||||
|
|
|
@ -247,6 +247,7 @@ def github_oauth_attach():
|
|||
|
||||
|
||||
@callback.route('/github/callback/trigger/<path:repository>', methods=['GET'])
|
||||
@callback.route('/github/callback/trigger/<path:repository>/__new', methods=['GET'])
|
||||
@route_show_if(features.GITHUB_BUILD)
|
||||
@require_session_login
|
||||
@parse_repository_name
|
||||
|
@ -260,9 +261,18 @@ def attach_github_build_trigger(namespace, repository):
|
|||
abort(404, message=msg)
|
||||
|
||||
trigger = model.create_build_trigger(repo, 'github', token, current_user.db_user())
|
||||
|
||||
# TODO(jschorr): Remove once the new layout is in place.
|
||||
admin_path = '%s/%s/%s' % (namespace, repository, 'admin')
|
||||
full_url = '%s%s%s' % (url_for('web.repository', path=admin_path), '?tab=trigger&new_trigger=',
|
||||
trigger.uuid)
|
||||
|
||||
if '__new' in request.url:
|
||||
repo_path = '%s/%s' % (namespace, repository)
|
||||
full_url = '%s%s%s' % (url_for('web.repository', path=repo_path), '?tab=builds&newtrigger=',
|
||||
trigger.uuid)
|
||||
|
||||
|
||||
logger.debug('Redirecting to full url: %s' % full_url)
|
||||
return redirect(full_url)
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ from app import app, oauth_apps, dockerfile_build_queue, LoginWrappedDBUser
|
|||
|
||||
from auth.permissions import QuayDeferredPermissionUser
|
||||
from auth import scopes
|
||||
from auth.auth_context import get_authenticated_user
|
||||
from endpoints.api.discovery import swagger_route_data
|
||||
from werkzeug.routing import BaseConverter
|
||||
from functools import wraps
|
||||
|
@ -225,7 +226,8 @@ def start_build(repository, dockerfile_id, tags, build_name, subdir, manual,
|
|||
'registry': host,
|
||||
'build_subdir': subdir,
|
||||
'trigger_metadata': trigger_metadata or {},
|
||||
'is_manual': manual
|
||||
'is_manual': manual,
|
||||
'manual_user': get_authenticated_user().username if get_authenticated_user() else None
|
||||
}
|
||||
|
||||
with app.config['DB_TRANSACTION_FACTORY'](db):
|
||||
|
@ -250,7 +252,8 @@ def start_build(repository, dockerfile_id, tags, build_name, subdir, manual,
|
|||
'repo': repository.name,
|
||||
'namespace': repository.namespace_user.username,
|
||||
'fileid': dockerfile_id,
|
||||
'manual': manual,
|
||||
'is_manual': manual,
|
||||
'manual_user': get_authenticated_user().username if get_authenticated_user() else None
|
||||
}
|
||||
|
||||
if trigger:
|
||||
|
@ -267,7 +270,8 @@ def start_build(repository, dockerfile_id, tags, build_name, subdir, manual,
|
|||
'build_id': build_request.uuid,
|
||||
'build_name': build_name,
|
||||
'docker_tags': tags,
|
||||
'is_manual': manual
|
||||
'is_manual': manual,
|
||||
'manual_user': get_authenticated_user().username if get_authenticated_user() else None
|
||||
}
|
||||
|
||||
if trigger:
|
||||
|
|
Reference in a new issue