Esempio n. 1
0
    def _get_valid_config(cls, config, *fields) -> ConfigType:
        config = to_list(config)
        web_hooks = []
        for web_hook in config:
            if not web_hook.get('url'):
                logger.warning("Settings contains a non compatible web hook: `%s`", web_hook)
                continue

            url = web_hook['url']
            if not validate_url(url):
                raise PolyaxonActionException('{} received invalid URL `{}`.'.format(cls.name, url))

            method = web_hook.get('method', 'POST')
            if not isinstance(method, str):
                raise PolyaxonActionException(
                    '{} received invalid method `{}`.'.format(cls.name, method))

            _method = method.upper()
            if _method not in ['GET', 'POST']:
                raise PolyaxonActionException(
                    '{} received non compatible method `{}`.'.format(cls.name, method))

            result_web_hook = {'url': url, 'method': _method}
            for field in fields:
                if field in web_hook:
                    result_web_hook[field] = web_hook[field]
            web_hooks.append(result_web_hook)

        return web_hooks
Esempio n. 2
0
def get_private_clone_url(git_url: str) -> str:
    # We make sure that the project has the credentials to use for the private repo
    access_token = conf.get('REPOS_ACCESS_TOKEN')
    if not access_token or not validate_url(git_url):
        raise GitCloneException

    # Add user:pass to the git url
    url = git_url.split('https://')[1]
    return 'https://{}:{}@{}'.format(access_token.user, access_token.password,
                                     url)
Esempio n. 3
0
def get_private_clone_url(git_url: str) -> str:
    # We make sure that the project has the credentials to use for the private repo
    access_token = conf.get(REPOS_ACCESS_TOKEN)
    if not access_token:
        credentials = conf.get(REPOS_CREDENTIALS)
    else:
        credentials = AuthSpec('polyaxon', access_token)
    if not credentials or not validate_url(git_url):
        raise GitCloneException

    # Add user:pass to the git url
    url = git_url.split('https://')[1]
    return 'https://{}:{}@{}'.format(credentials.user, credentials.password,
                                     url)