2014-02-18 23:09:14 +00:00
|
|
|
import requests
|
2014-03-05 19:35:11 +00:00
|
|
|
import os.path
|
2013-10-01 03:54:12 +00:00
|
|
|
|
2014-02-04 00:08:37 +00:00
|
|
|
from data.buildlogs import BuildLogs
|
2014-02-07 01:58:26 +00:00
|
|
|
from data.userevent import UserEventBuilder
|
2013-11-07 04:21:12 +00:00
|
|
|
|
2013-10-01 03:54:12 +00:00
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
def build_requests_session():
|
|
|
|
sess = requests.Session()
|
|
|
|
adapter = requests.adapters.HTTPAdapter(pool_connections=100,
|
|
|
|
pool_maxsize=100)
|
|
|
|
sess.mount('http://', adapter)
|
|
|
|
sess.mount('https://', adapter)
|
|
|
|
return sess
|
2014-02-18 23:09:14 +00:00
|
|
|
|
2014-01-27 22:46:21 +00:00
|
|
|
|
2014-04-08 23:14:24 +00:00
|
|
|
# The set of configuration key names that will be accessible in the client. Since these
|
|
|
|
# values are set to the frontend, DO NOT PLACE ANY SECRETS OR KEYS in this list.
|
2014-04-11 15:17:45 +00:00
|
|
|
CLIENT_WHITELIST = ['SERVER_HOSTNAME', 'PREFERRED_URL_SCHEME', 'GITHUB_CLIENT_ID',
|
2014-04-08 23:14:24 +00:00
|
|
|
'GITHUB_LOGIN_CLIENT_ID', 'MIXPANEL_KEY', 'STRIPE_PUBLISHABLE_KEY',
|
2014-08-08 17:50:04 +00:00
|
|
|
'ENTERPRISE_LOGO_URL', 'SENTRY_PUBLIC_DSN', 'AUTHENTICATION_TYPE',
|
2014-08-11 19:47:44 +00:00
|
|
|
'REGISTRY_TITLE', 'REGISTRY_TITLE_SHORT', 'GOOGLE_LOGIN_CLIENT_ID']
|
2014-04-08 23:14:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
def getFrontendVisibleConfig(config_dict):
|
|
|
|
visible_dict = {}
|
|
|
|
for name in CLIENT_WHITELIST:
|
|
|
|
if name.lower().find('secret') >= 0:
|
|
|
|
raise Exception('Cannot whitelist secrets: %s' % name)
|
|
|
|
|
|
|
|
if name in config_dict:
|
|
|
|
visible_dict[name] = config_dict.get(name, None)
|
|
|
|
|
|
|
|
return visible_dict
|
|
|
|
|
2013-09-28 00:03:07 +00:00
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
class DefaultConfig(object):
|
|
|
|
# Flask config
|
|
|
|
SECRET_KEY = 'a36c9d7d-25a9-4d3f-a586-3d2f8dc40a83'
|
|
|
|
JSONIFY_PRETTYPRINT_REGULAR = False
|
|
|
|
SESSION_COOKIE_SECURE = False
|
2014-02-16 23:59:24 +00:00
|
|
|
|
2014-05-01 23:44:28 +00:00
|
|
|
LOGGING_LEVEL = 'DEBUG'
|
2014-04-03 21:31:46 +00:00
|
|
|
SEND_FILE_MAX_AGE_DEFAULT = 0
|
|
|
|
POPULATE_DB_TEST_DATA = True
|
|
|
|
PREFERRED_URL_SCHEME = 'http'
|
2014-04-11 15:17:45 +00:00
|
|
|
SERVER_HOSTNAME = 'localhost:5000'
|
2014-02-16 23:59:24 +00:00
|
|
|
|
2014-08-08 17:50:04 +00:00
|
|
|
REGISTRY_TITLE = 'Quay.io'
|
|
|
|
REGISTRY_TITLE_SHORT = 'Quay.io'
|
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
# Mail config
|
|
|
|
MAIL_SERVER = ''
|
|
|
|
MAIL_USE_TLS = True
|
|
|
|
MAIL_PORT = 587
|
|
|
|
MAIL_USERNAME = ''
|
|
|
|
MAIL_PASSWORD = ''
|
|
|
|
DEFAULT_MAIL_SENDER = ''
|
|
|
|
MAIL_FAIL_SILENTLY = False
|
|
|
|
TESTING = True
|
2014-02-16 23:59:24 +00:00
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
# DB config
|
2014-04-09 23:11:33 +00:00
|
|
|
DB_URI = 'sqlite:///test/data/test.db'
|
2013-09-30 23:10:27 +00:00
|
|
|
DB_CONNECTION_ARGS = {
|
2014-03-06 19:47:02 +00:00
|
|
|
'threadlocals': True,
|
|
|
|
'autorollback': True,
|
2013-09-30 23:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-02-16 23:59:24 +00:00
|
|
|
@staticmethod
|
|
|
|
def create_transaction(db):
|
2014-04-03 21:31:46 +00:00
|
|
|
return db.transaction()
|
2014-02-16 23:59:24 +00:00
|
|
|
|
|
|
|
DB_TRANSACTION_FACTORY = create_transaction
|
|
|
|
|
2014-05-09 22:49:33 +00:00
|
|
|
# If true, CDN URLs will be used for our external dependencies, rather than the local
|
|
|
|
# copies.
|
|
|
|
USE_CDN = True
|
|
|
|
|
2014-05-09 21:39:43 +00:00
|
|
|
# Authentication
|
|
|
|
AUTHENTICATION_TYPE = 'Database'
|
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
# Build logs
|
2014-10-01 18:16:42 +00:00
|
|
|
BUILDLOGS_REDIS = {'host': 'logs.quay.io'}
|
2014-05-30 18:25:29 +00:00
|
|
|
BUILDLOGS_OPTIONS = []
|
2013-11-07 04:21:12 +00:00
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
# Real-time user events
|
2014-10-01 18:16:42 +00:00
|
|
|
USER_EVENTS_REDIS = {'host': 'logs.quay.io'}
|
2014-02-07 01:58:26 +00:00
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
# Stripe config
|
2014-04-10 19:20:16 +00:00
|
|
|
BILLING_TYPE = 'FakeStripe'
|
2014-02-07 01:58:26 +00:00
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
# Analytics
|
2014-05-21 23:50:37 +00:00
|
|
|
ANALYTICS_TYPE = 'FakeAnalytics'
|
|
|
|
|
|
|
|
# Build Queue Metrics
|
|
|
|
QUEUE_METRICS_TYPE = 'Null'
|
2013-11-07 04:21:12 +00:00
|
|
|
|
2014-04-28 22:59:22 +00:00
|
|
|
# Exception logging
|
|
|
|
EXCEPTION_LOG_TYPE = 'FakeSentry'
|
|
|
|
SENTRY_DSN = None
|
|
|
|
SENTRY_PUBLIC_DSN = None
|
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
# Github Config
|
2013-10-10 03:00:34 +00:00
|
|
|
GITHUB_TOKEN_URL = 'https://github.com/login/oauth/access_token'
|
|
|
|
GITHUB_USER_URL = 'https://api.github.com/user'
|
|
|
|
GITHUB_USER_EMAILS = GITHUB_USER_URL + '/emails'
|
|
|
|
|
2014-04-07 20:59:22 +00:00
|
|
|
GITHUB_CLIENT_ID = ''
|
|
|
|
GITHUB_CLIENT_SECRET = ''
|
2013-10-10 03:00:34 +00:00
|
|
|
|
2014-04-08 23:14:24 +00:00
|
|
|
GITHUB_LOGIN_CLIENT_ID = ''
|
|
|
|
GITHUB_LOGIN_CLIENT_SECRET = ''
|
|
|
|
|
2014-08-11 19:47:44 +00:00
|
|
|
# Google Config.
|
|
|
|
GOOGLE_TOKEN_URL = 'https://accounts.google.com/o/oauth2/token'
|
|
|
|
GOOGLE_USER_URL = 'https://www.googleapis.com/oauth2/v1/userinfo'
|
|
|
|
|
|
|
|
GOOGLE_LOGIN_CLIENT_ID = ''
|
|
|
|
GOOGLE_LOGIN_CLIENT_SECRET = ''
|
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
# Requests based HTTP client with a large request pool
|
2014-02-18 23:09:14 +00:00
|
|
|
HTTPCLIENT = build_requests_session()
|
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
# Status tag config
|
2014-03-05 19:35:11 +00:00
|
|
|
STATUS_TAGS = {}
|
|
|
|
for tag_name in ['building', 'failed', 'none', 'ready']:
|
|
|
|
tag_path = os.path.join('buildstatus', tag_name + '.svg')
|
|
|
|
with open(tag_path) as tag_svg:
|
|
|
|
STATUS_TAGS[tag_name] = tag_svg.read()
|
|
|
|
|
2014-07-18 02:51:58 +00:00
|
|
|
NOTIFICATION_QUEUE_NAME = 'notification'
|
2014-04-11 23:23:57 +00:00
|
|
|
DIFFS_QUEUE_NAME = 'imagediff'
|
|
|
|
DOCKERFILE_BUILD_QUEUE_NAME = 'dockerfilebuild'
|
2014-03-05 19:35:11 +00:00
|
|
|
|
2014-07-31 17:30:54 +00:00
|
|
|
# TODO: Remove this in the prod push following the notifications change.
|
|
|
|
WEBHOOK_QUEUE_NAME = 'webhook'
|
|
|
|
|
2014-04-10 19:51:39 +00:00
|
|
|
# Super user config. Note: This MUST BE an empty list for the default config.
|
|
|
|
SUPER_USERS = []
|
2014-04-10 04:26:55 +00:00
|
|
|
|
2014-04-05 03:26:10 +00:00
|
|
|
# Feature Flag: Whether billing is required.
|
2014-05-30 18:25:29 +00:00
|
|
|
FEATURE_BILLING = False
|
2014-04-03 22:47:17 +00:00
|
|
|
|
2014-04-05 03:26:10 +00:00
|
|
|
# Feature Flag: Whether user accounts automatically have usage log access.
|
2014-04-07 20:59:22 +00:00
|
|
|
FEATURE_USER_LOG_ACCESS = False
|
2014-04-05 03:26:10 +00:00
|
|
|
|
|
|
|
# Feature Flag: Whether GitHub login is supported.
|
2014-04-17 02:51:56 +00:00
|
|
|
FEATURE_GITHUB_LOGIN = False
|
2014-04-09 03:05:45 +00:00
|
|
|
|
2014-08-11 19:47:44 +00:00
|
|
|
# Feature Flag: Whether Google login is supported.
|
|
|
|
FEATURE_GOOGLE_LOGIN = False
|
|
|
|
|
2014-04-09 03:05:45 +00:00
|
|
|
# Feature flag, whether to enable olark chat
|
2014-04-10 19:51:39 +00:00
|
|
|
FEATURE_OLARK_CHAT = False
|
2014-04-10 04:26:55 +00:00
|
|
|
|
|
|
|
# Feature Flag: Whether super users are supported.
|
|
|
|
FEATURE_SUPER_USERS = False
|
2014-05-30 22:28:18 +00:00
|
|
|
|
|
|
|
# Feature Flag: Whether to support GitHub build triggers.
|
|
|
|
FEATURE_GITHUB_BUILD = False
|
2014-06-17 20:03:43 +00:00
|
|
|
|
2014-08-22 22:03:22 +00:00
|
|
|
# Feature Flag: Dockerfile build support.
|
|
|
|
FEATURE_BUILD_SUPPORT = True
|
|
|
|
|
2014-09-22 23:11:48 +00:00
|
|
|
# Feature Flag: Whether emails are enabled.
|
|
|
|
FEATURE_MAILING = True
|
|
|
|
|
2014-10-02 18:49:18 +00:00
|
|
|
# Feature Flag: Whether users can be created (by non-super users).
|
|
|
|
FEATURE_USER_CREATION = True
|
|
|
|
|
2014-06-17 20:03:43 +00:00
|
|
|
DISTRIBUTED_STORAGE_CONFIG = {
|
2014-08-07 17:45:15 +00:00
|
|
|
'local_eu': ['LocalStorage', {'storage_path': 'test/data/registry/eu'}],
|
|
|
|
'local_us': ['LocalStorage', {'storage_path': 'test/data/registry/us'}],
|
2014-06-17 20:03:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DISTRIBUTED_STORAGE_PREFERENCE = ['local_us']
|
2014-09-09 22:30:14 +00:00
|
|
|
|
|
|
|
# Userfiles
|
|
|
|
USERFILES_LOCATION = 'local_us'
|
|
|
|
USERFILES_PATH = 'userfiles/'
|
2014-09-11 15:18:28 +00:00
|
|
|
|
|
|
|
# Build logs archive
|
|
|
|
LOG_ARCHIVE_LOCATION = 'local_us'
|
|
|
|
LOG_ARCHIVE_PATH = 'logarchive/'
|