data.model.repository: add app methods

This commit is contained in:
Jimmy Zelinskie 2017-03-22 21:51:55 -04:00
parent 650723430b
commit ddad957a56

View file

@ -58,6 +58,14 @@ def get_repository(namespace_name, repository_name, kind_filter=None):
return None
def get_or_create_repository(namespace, name, creating_user, visibility='private',
repo_kind='image'):
repo = get_repository(namespace, name, repo_kind)
if repo is None:
repo = create_repository(namespace, name, creating_user, visibility, repo_kind)
return repo
def purge_repository(namespace_name, repository_name):
""" Completely delete all traces of the repository. Will return True upon
complete success, and False upon partial or total failure. Garbage
@ -339,6 +347,20 @@ def get_visible_repositories(username, namespace=None, repo_kind='image', includ
return query
def get_app_repository(namespace_name, repository_name):
""" Find an application repository. """
try:
return _basequery.get_existing_repository(namespace_name, repository_name,
kind_filter='application')
except Repository.DoesNotExist:
return None
def get_app_search(lookup, username=None, limit=50):
return get_filtered_matching_repositories(lookup, filter_username=username,
repo_kind='application', offset=0, limit=limit)
def get_filtered_matching_repositories(lookup_value, filter_username=None, repo_kind='image',
offset=0, limit=25):
""" Returns an iterator of all repositories matching the given lookup value, with optional