refactor(endpoints/api/repoemail): added in pre_oci model
### Description of Changes this is so we can abstract away the data interface [TESTING->locally with docker compose] Issue: https://coreosdev.atlassian.net/browse/QUAY-626 ## Reviewer Checklist - [ ] It works! - [ ] Comments provide sufficient explanations for the next contributor - [ ] Tests cover changes and corner cases - [ ] Follows Quay syntax patterns and format
This commit is contained in:
parent
82488c9102
commit
d01b55f27d
5 changed files with 158 additions and 16 deletions
26
endpoints/api/repoemail_models_pre_oci.py
Normal file
26
endpoints/api/repoemail_models_pre_oci.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
from data import model
|
||||
from endpoints.api.repoemail_models_interface import RepoEmailDataInterface, RepositoryAuthorizedEmail
|
||||
|
||||
|
||||
def _return_none_or_data(func, namespace_name, repository_name, email):
|
||||
data = func(namespace_name, repository_name, email)
|
||||
if data is None:
|
||||
return data
|
||||
return RepositoryAuthorizedEmail(email, repository_name, namespace_name, data.confirmed, data.code)
|
||||
|
||||
|
||||
class PreOCIModel(RepoEmailDataInterface):
|
||||
"""
|
||||
PreOCIModel implements the data model for the Repo Email using a database schema
|
||||
before it was changed to support the OCI specification.
|
||||
"""
|
||||
|
||||
def get_email_authorized_for_repo(self, namespace_name, repository_name, email):
|
||||
return _return_none_or_data(model.repository.get_email_authorized_for_repo, namespace_name, repository_name, email)
|
||||
|
||||
def create_email_authorization_for_repo(self, namespace_name, repository_name, email):
|
||||
return _return_none_or_data(model.repository.create_email_authorization_for_repo, namespace_name, repository_name,
|
||||
email)
|
||||
|
||||
|
||||
pre_oci_model = PreOCIModel()
|
Reference in a new issue