Skip to content

Commit

Permalink
Merge pull request #45 from launchableinc/jar-base-url
Browse files Browse the repository at this point in the history
Pass LAUNCHABLE_BASE_URL to Ingester jar file
  • Loading branch information
ninjinkun authored Dec 1, 2020
2 parents d4aea32 + e459cb8 commit d8a3c03
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 7 additions & 4 deletions launchable/commands/record/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from ...utils.ingester_image import ingester_image
import subprocess
from ...utils.env_keys import REPORT_ERROR_KEY
from ...utils.http_client import get_base_url

jar_file_path = os.path.normpath(os.path.join(
os.path.dirname(__file__), "../../jar/exe_deploy.jar"))
Expand Down Expand Up @@ -45,14 +46,16 @@ def exec_jar(source):
if not java:
exit("You need to install Java or try --executable docker")

base_url = get_base_url()
os.system(
"{} -jar {} ingest:commit {}"
.format(java, jar_file_path, source))
"{} -jar {} ingest:commit -endpoint {} {}"
.format(java, jar_file_path, "{}/intake/".format(base_url), source))


def exec_docker(source):
base_url = get_base_url()
os.system(
"docker run -u $(id -u) -i --rm "
"-v {}:{} --env LAUNCHABLE_TOKEN {} ingest:commit {}"
.format(source, source, ingester_image, source)
"-v {}:{} --env LAUNCHABLE_TOKEN {} ingest:commit -endpoint {} {}"
.format(source, source, ingester_image, "{}/intake/".format(base_url), source)
)
6 changes: 5 additions & 1 deletion launchable/utils/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
DEFAULT_BASE_URL = "https://api.mercury.launchableinc.com"


def get_base_url():
return os.getenv(BASE_URL_KEY) or DEFAULT_BASE_URL


class LaunchableClient:
def __init__(self, token, base_url="", http=requests):
self.base_url = base_url or os.getenv(BASE_URL_KEY) or DEFAULT_BASE_URL
self.base_url = base_url or get_base_url()
self.http = http
self.token = token

Expand Down

0 comments on commit d8a3c03

Please sign in to comment.