def test_no_org(self):
     uri = 'bundle-configuration/conductr-haproxy-dev-mode:1.0.0-023f9da22'
     expected_result = ('urn:x-bundle:',
                        'typesafe', 'bundle-configuration', 'conductr-haproxy-dev-mode',
                        '1.0.0', '023f9da22')
     result = bundle_shorthand.parse_bundle_configuration(uri)
     self.assertEqual(expected_result, result)
Esempio n. 2
0
def load_bundle_configuration_from_cache(cache_dir, uri):
    # When the supplied uri points to a local file, don't load from cache so file can be used as is.
    if is_local_file(uri):
        return False, None, None
    else:
        log = logging.getLogger(__name__)
        try:
            urn, org, repo, package_name, tag, digest = bundle_shorthand.parse_bundle_configuration(
                uri)
            log.info(
                log_message('Loading bundle configuration from cache', org,
                            repo, package_name, tag, digest))
            bintray_auth = load_bintray_credentials(raise_error=False)
            resolved_version = bintray_resolve_version(bintray_auth, org, repo,
                                                       package_name, tag,
                                                       digest)
            if resolved_version:
                return uri_resolver.load_bundle_from_cache(
                    cache_dir, resolved_version['download_url'])
            else:
                return False, None, None
        except MalformedBundleUriError:
            return False, None, None
        except HTTPError as http_error:
            return handle_http_error(http_error, org, repo)
        except ConnectionError:
            return False, None, None
Esempio n. 3
0
 def test_no_repos(self):
     uri = 'conductr-haproxy-dev-mode:v1-023f9da22'
     expected_result = ('urn:x-bundle:',
                        'typesafe', 'bundle-configuration', 'conductr-haproxy-dev-mode',
                        'v1', '023f9da22')
     result = bundle_shorthand.parse_bundle_configuration(uri)
     self.assertEqual(expected_result, result)
Esempio n. 4
0
def resolve_bundle_configuration(cache_dir, uri):
    log = logging.getLogger(__name__)
    try:
        urn, org, repo, package_name, compatibility_version, digest = bundle_shorthand.parse_bundle_configuration(uri)
        log.info(log_message('Resolving bundle configuration', org, repo, package_name, compatibility_version, digest))
        return bintray_download(cache_dir, org, repo, package_name, compatibility_version, digest)
    except MalformedBundleUriError:
        return False, None, None
    except HTTPError:
        return False, None, None
Esempio n. 5
0
def load_bundle_configuration_from_cache(cache_dir, uri):
    # When the supplied uri points to a local file, don't load from cache so file can be used as is.
    if is_local_file(uri):
        return False, None, None
    else:
        log = logging.getLogger(__name__)
        try:
            urn, org, repo, package_name, compatibility_version, digest = bundle_shorthand.parse_bundle_configuration(uri)
            log.info(log_message('Loading bundle configuration from cache',
                                 org, repo, package_name, compatibility_version, digest))
            bundle_download_url, auth = bintray_download_details(org, repo, package_name, compatibility_version, digest)
            if bundle_download_url:
                return uri_resolver.load_bundle_from_cache(cache_dir, bundle_download_url)
            else:
                return False, None, None
        except MalformedBundleUriError:
            return False, None, None
        except HTTPError:
            return False, None, None
Esempio n. 6
0
def resolve_bundle_configuration(cache_dir, uri):
    log = logging.getLogger(__name__)
    try:
        urn, org, repo, package_name, tag, digest = bundle_shorthand.parse_bundle_configuration(
            uri)
        log.info(
            log_message('Resolving bundle configuration', org, repo,
                        package_name, tag, digest))
        bintray_auth = load_bintray_credentials(raise_error=False)
        resolved_version = bintray_resolve_version(bintray_auth, org, repo,
                                                   package_name, tag, digest)
        return bintray_download_artefact(cache_dir, resolved_version,
                                         bintray_auth)
    except MalformedBundleUriError:
        return False, None, None
    except HTTPError as http_error:
        return handle_http_error(http_error, org, repo)
    except ConnectionError:
        return False, None, None
 def test_bundle_name_only(self):
     uri = 'conductr-haproxy-dev-mode'
     expected_result = ('urn:x-bundle:', 'typesafe', 'bundle-configuration', 'conductr-haproxy-dev-mode', None, None)
     result = bundle_shorthand.parse_bundle_configuration(uri)
     self.assertEqual(expected_result, result)
 def test_full_address(self):
     uri = 'urn:x-bundle:typesafe/bundle-configuration/conductr-haproxy-dev-mode:v1-023f9da22'
     expected_result = ('urn:x-bundle:', 'typesafe', 'bundle-configuration',
                        'conductr-haproxy-dev-mode', 'v1', '023f9da22')
     result = bundle_shorthand.parse_bundle_configuration(uri)
     self.assertEqual(expected_result, result)
Esempio n. 9
0
 def test_bundle_name_only(self):
     uri = 'conductr-haproxy-dev-mode'
     expected_result = ('urn:x-bundle:', 'typesafe', 'bundle-configuration', 'conductr-haproxy-dev-mode', None, None)
     result = bundle_shorthand.parse_bundle_configuration(uri)
     self.assertEqual(expected_result, result)