From ddad957a5606e3b39614175aaa0fa55d4e49dbe5 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Wed, 22 Mar 2017 21:51:55 -0400 Subject: [PATCH] data.model.repository: add app methods --- data/model/repository.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/data/model/repository.py b/data/model/repository.py index fbd47aeef..ecf5a8d75 100644 --- a/data/model/repository.py +++ b/data/model/repository.py @@ -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