2015-09-16 15:34:20 -04:00
|
|
|
from data.database import db, db_transaction
|
2015-07-15 17:25:41 -04:00
|
|
|
|
|
|
|
|
2015-07-06 15:00:07 -04:00
|
|
|
class DataModelException(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-07-18 18:20:00 -04:00
|
|
|
class InvalidLabelKeyException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidMediaTypeException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2015-07-15 17:25:41 -04:00
|
|
|
class BlobDoesNotExist(DataModelException):
|
|
|
|
pass
|
|
|
|
|
2016-07-18 18:20:00 -04:00
|
|
|
|
2015-12-31 14:09:50 -05:00
|
|
|
class TorrentInfoDoesNotExist(DataModelException):
|
|
|
|
pass
|
|
|
|
|
2015-07-15 17:25:41 -04:00
|
|
|
|
2015-08-12 16:39:32 -04:00
|
|
|
class InvalidBlobUpload(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2015-07-15 17:25:41 -04:00
|
|
|
class InvalidEmailAddressException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidOrganizationException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidPasswordException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidRobotException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidUsernameException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidRepositoryBuildException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidBuildTriggerException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidTokenException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidNotificationException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidImageException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class UserAlreadyInTeam(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidTeamException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidTeamMemberException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2015-08-12 16:39:32 -04:00
|
|
|
class InvalidManifestException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-03-16 15:49:25 -04:00
|
|
|
class ServiceKeyDoesNotExist(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-03-23 18:16:03 -04:00
|
|
|
class ServiceKeyAlreadyApproved(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-04-14 16:56:15 -04:00
|
|
|
class ServiceNameInvalid(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-08-29 11:58:18 -04:00
|
|
|
class TagAlreadyCreatedException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
2017-02-21 12:51:39 -05:00
|
|
|
class StaleTagException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
2016-08-29 11:58:18 -04:00
|
|
|
|
2015-07-15 17:25:41 -04:00
|
|
|
class TooManyLoginAttemptsException(Exception):
|
|
|
|
def __init__(self, message, retry_after):
|
|
|
|
super(TooManyLoginAttemptsException, self).__init__(message)
|
|
|
|
self.retry_after = retry_after
|
|
|
|
|
|
|
|
|
2015-07-06 15:00:07 -04:00
|
|
|
class Config(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.app_config = None
|
|
|
|
self.store = None
|
2016-12-22 14:27:42 -05:00
|
|
|
self.image_cleanup_callbacks = []
|
2017-04-12 15:47:24 -04:00
|
|
|
self.repo_cleanup_callbacks = []
|
2016-12-22 14:27:42 -05:00
|
|
|
|
|
|
|
def register_image_cleanup_callback(self, callback):
|
|
|
|
self.image_cleanup_callbacks.append(callback)
|
2017-04-12 15:47:24 -04:00
|
|
|
|
|
|
|
def register_repo_cleanup_callback(self, callback):
|
|
|
|
self.repo_cleanup_callbacks.append(callback)
|
2015-07-06 15:00:07 -04:00
|
|
|
|
|
|
|
|
|
|
|
config = Config()
|
|
|
|
|
|
|
|
|
2015-07-15 17:25:41 -04:00
|
|
|
# There MUST NOT be any circular dependencies between these subsections. If there are fix it by
|
|
|
|
# moving the minimal number of things to _basequery
|
2016-07-18 18:20:00 -04:00
|
|
|
from data.model import (
|
|
|
|
blob,
|
|
|
|
build,
|
|
|
|
image,
|
|
|
|
label,
|
|
|
|
log,
|
2016-10-07 15:56:58 -04:00
|
|
|
message,
|
2016-07-18 18:20:00 -04:00
|
|
|
modelutil,
|
|
|
|
notification,
|
|
|
|
oauth,
|
|
|
|
organization,
|
|
|
|
permission,
|
2017-03-17 13:51:45 -04:00
|
|
|
repositoryactioncount,
|
2016-07-18 18:20:00 -04:00
|
|
|
release,
|
|
|
|
repository,
|
|
|
|
service_keys,
|
|
|
|
storage,
|
|
|
|
tag,
|
|
|
|
team,
|
|
|
|
token,
|
|
|
|
user,
|
|
|
|
)
|