Skip to content

Commit

Permalink
Merge pull request #404 from fsat/sandbox-image-generic-download
Browse files Browse the repository at this point in the history
Download sandbox image from Lightbend generic repo if Bintray credential is not supplied
  • Loading branch information
fsat authored Apr 26, 2017
2 parents f087163 + 45c57db commit 2663768
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 27 deletions.
3 changes: 2 additions & 1 deletion conductr_cli/resolvers/bintray_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
BINTRAY_CREDENTIAL_FILE_PATH = '{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~'))
BINTRAY_PROPERTIES_RE = re.compile('^(\S+)\s*=\s*([\S]+)$')
BINTRAY_LIGHTBEND_ORG = 'lightbend'
BINTRAY_CONDUCTR_REPO = 'commercial-releases'
BINTRAY_CONDUCTR_COMMERCIAL_REPO = 'commercial-releases'
BINTRAY_CONDUCTR_GENERIC_REPO = 'generic'
BINTRAY_CONDUCTR_CORE_PACKAGE_NAME = 'ConductR-Universal'
BINTRAY_CONDUCTR_AGENT_PACKAGE_NAME = 'ConductR-Agent-Universal'

Expand Down
12 changes: 9 additions & 3 deletions conductr_cli/sandbox_run_jvm.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from conductr_cli import conduct_main, host, license_validation, sandbox_stop, sandbox_common
from conductr_cli import conduct_main, host, license_validation, sandbox_stop, sandbox_common, sandbox_version
from conductr_cli.constants import DEFAULT_SCHEME, DEFAULT_PORT, DEFAULT_BASE_PATH, DEFAULT_API_VERSION, \
DEFAULT_LICENSE_FILE, DEFAULT_SERVICE_LOCATOR_PORT, FEATURE_PROVIDE_PROXYING, DEFAULT_SANDBOX_IMAGE_DIR
from conductr_cli.exceptions import BindAddressNotFound, BintrayUnreachableError, InstanceCountError, \
SandboxImageNotFoundError, SandboxImageNotAvailableOfflineError, SandboxUnsupportedOsArchError, \
SandboxUnsupportedOsError, JavaCallError, JavaUnsupportedVendorError, JavaUnsupportedVersionError, \
JavaVersionParseError, HostnameLookupError, LicenseValidationError
from conductr_cli.resolvers import bintray_resolver
from conductr_cli.resolvers.bintray_resolver import BINTRAY_LIGHTBEND_ORG, BINTRAY_CONDUCTR_REPO
from conductr_cli.resolvers.bintray_resolver import BINTRAY_LIGHTBEND_ORG, BINTRAY_CONDUCTR_COMMERCIAL_REPO, \
BINTRAY_CONDUCTR_GENERIC_REPO
from conductr_cli.sandbox_common import flatten
from conductr_cli.sandbox_version import is_conductr_on_private_bintray
from conductr_cli.screen_utils import h1, h2
Expand Down Expand Up @@ -473,6 +474,11 @@ def download_sandbox_image(image_dir, package_name, artefact_type, image_version
try:
bintray_auth = bintray_resolver.load_bintray_credentials(raise_error=False)

if sandbox_version.is_conductr_on_private_bintray(image_version):
bintray_repo = BINTRAY_CONDUCTR_COMMERCIAL_REPO
else:
bintray_repo = BINTRAY_CONDUCTR_COMMERCIAL_REPO if bintray_auth[0] else BINTRAY_CONDUCTR_GENERIC_REPO

if artefact_type == 'core':
file_prefix = 'conductr-{}-{}'.format(image_version, artefact_os_name())
else:
Expand All @@ -486,7 +492,7 @@ def is_matching_artefact(download_url):
artefact
for artefact in bintray_resolver.bintray_artefacts_by_version(bintray_auth,
BINTRAY_LIGHTBEND_ORG,
BINTRAY_CONDUCTR_REPO,
bintray_repo,
package_name,
image_version)
if is_matching_artefact(artefact['download_url'])
Expand Down
Loading

0 comments on commit 2663768

Please sign in to comment.