# Path: dockci/server.py
# CONFIG = Config()
# 
# DB = WrappedSQLAlchemy()
# 
# OAUTH_APPS = {}
# 
# Path: dockci/util.py
# def ext_url_for(endpoint, **values):
#     """ Use ``external_url`` from config to build a full URL """
#     from dockci.server import CONFIG
# 
#     if not CONFIG.external_url:
#         return None
# 
#     ext_url = urlparse(CONFIG.external_url)
#     method = values.pop('_method', None)
#     return current_app.url_map.bind(
#         ext_url.netloc,
#         script_name=ext_url.path,
#         url_scheme=values.pop('_scheme', ext_url.scheme),
#     ).build(
#         endpoint,
#         values,
#         method=method,
#         force_external=True,
#     )


import logging
import re
import py.error  # pylint:disable=import-error
import sqlalchemy
from urllib.parse import quote_plus, urlparse, urlunparse
from uuid import uuid4
from flask import url_for
from .base import RepoFsMixin
from .db_types import RegexType
from dockci.server import CONFIG, DB, OAUTH_APPS
from dockci.util import ext_url_for
        from .job import Job
        from .job import Job
        from .job import Job
    id = DB.Column(DB.Integer(), primary_key=True)
    slug = DB.Column(DB.String(255), unique=True, nullable=False, index=True)
    repo = DB.Column(DB.String(255), nullable=False)
    name = DB.Column(DB.String(255), nullable=False)
    branch_pattern = DB.Column(RegexType(), nullable=True)

    utility = DB.Column(DB.Boolean(), nullable=False, index=True)
    public = DB.Column(DB.Boolean(),
                       default=False,
                       server_default=sqlalchemy.sql.expression.false(),
                       nullable=False,
                       index=True)

    # TODO repo ID from repo
    github_repo_id = DB.Column(DB.String(255))
    github_hook_id = DB.Column(DB.Integer())
    github_secret = DB.Column(DB.String(255))

    gitlab_repo_id = DB.Column(DB.String(255))

    external_auth_token_id = DB.Column(
        DB.Integer, DB.ForeignKey('o_auth_token.id'),
    )
    external_auth_token = DB.relationship(
        'OAuthToken',
        foreign_keys="Project.external_auth_token_id",
        backref=DB.backref('projects', lazy='dynamic'),
    )

    target_registry_id = DB.Column(

# Path: dockci/server.py
# CONFIG = Config()
# 
# DB = WrappedSQLAlchemy()
# 
# OAUTH_APPS = {}
# 
# Path: dockci/util.py
# def ext_url_for(endpoint, **values):
#     """ Use ``external_url`` from config to build a full URL """
#     from dockci.server import CONFIG
# 
#     if not CONFIG.external_url:
#         return None
# 
#     ext_url = urlparse(CONFIG.external_url)
#     method = values.pop('_method', None)
#     return current_app.url_map.bind(
#         ext_url.netloc,
#         script_name=ext_url.path,
#         url_scheme=values.pop('_scheme', ext_url.scheme),
#     ).build(
#         endpoint,
#         values,
#         method=method,
#         force_external=True,
#     )


# Path: dockci/models/project.py
import logging
import re
import py.error  # pylint:disable=import-error
import sqlalchemy
from urllib.parse import quote_plus, urlparse, urlunparse
from uuid import uuid4
from flask import url_for
from .base import RepoFsMixin
from .db_types import RegexType
from dockci.server import CONFIG, DB, OAUTH_APPS
from dockci.util import ext_url_for
        from .job import Job
        from .job import Job
        from .job import Job

    id = DB.Column(DB.Integer(), primary_key=True)
    slug = DB.Column(DB.String(255), unique=True, nullable=False, index=True)
    repo = DB.Column(DB.String(255), nullable=False)
    name = DB.Column(DB.String(255), nullable=False)
    branch_pattern = DB.Column(RegexType(), nullable=True)

    utility = DB.Column(DB.Boolean(), nullable=False, index=True)
    public = DB.Column(DB.Boolean(),
                       default=False,
                       server_default=sqlalchemy.sql.expression.false(),
                       nullable=False,
                       index=True)

    # TODO repo ID from repo
    github_repo_id = DB.Column(DB.String(255))
    github_hook_id = DB.Column(DB.Integer())
    github_secret = DB.Column(DB.String(255))

    gitlab_repo_id = DB.Column(DB.String(255))

    external_auth_token_id = DB.Column(
        DB.Integer, DB.ForeignKey('o_auth_token.id'),
    )
    external_auth_token = DB.relationship(
        'OAuthToken',
        foreign_keys="Project.external_auth_token_id",
        backref=DB.backref('projects', lazy='dynamic'),
    )

    target_registry_id = DB.Column(

        DB.Integer, DB.ForeignKey('authenticated_registry.id'),