Add datastore emulator to gcloud asset
Bug: skia: Change-Id: I2f0986e0ae3057e0a7fca479c0f3e062f10c3eba Reviewed-on: https://skia-review.googlesource.com/126205 Commit-Queue: Stephan Altmueller <stephana@google.com> Reviewed-by: Ben Wagner <benjaminwagner@google.com>
This commit is contained in:
parent
0ca7a88e64
commit
beca172554
@ -1 +1 @@
|
||||
6
|
||||
10
|
@ -19,18 +19,31 @@ import subprocess
|
||||
# scripting gcloud and also for updates.
|
||||
BASE_URL = 'https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/%s'
|
||||
GCLOUD_BASE_NAME='google-cloud-sdk'
|
||||
GCLOUD_ARCHIVE = '%s-191.0.0-linux-x86_64.tar.gz' % GCLOUD_BASE_NAME
|
||||
GCLOUD_ARCHIVE = '%s-200.0.0-linux-x86_64.tar.gz' % GCLOUD_BASE_NAME
|
||||
GCLOUD_URL = BASE_URL % GCLOUD_ARCHIVE
|
||||
|
||||
def create_asset(target_dir):
|
||||
"""Create the asset."""
|
||||
target_dir = os.path.abspath(target_dir)
|
||||
subprocess.check_call(['curl', GCLOUD_URL, '-o', GCLOUD_ARCHIVE])
|
||||
|
||||
# Extract the arcive to the target directory and remove it.
|
||||
subprocess.check_call(['tar', '-xzf', GCLOUD_ARCHIVE,
|
||||
'--strip-components=1',
|
||||
'-C', target_dir])
|
||||
subprocess.check_call(['rm', GCLOUD_ARCHIVE])
|
||||
|
||||
# Substitute the HOME directory in the environment so we don't overwrite
|
||||
# an existing gcloud configuration in $HOME/.config/gcloud
|
||||
env = os.environ.copy()
|
||||
env["HOME"] = target_dir
|
||||
gcloud_exe = os.path.join(target_dir, 'bin', 'gcloud')
|
||||
subprocess.check_call([gcloud_exe, 'components',
|
||||
'install', 'beta', 'cloud-datastore-emulator',
|
||||
'--quiet'], env=env)
|
||||
subprocess.check_call([gcloud_exe, 'components','update', '--quiet'], env=env)
|
||||
|
||||
# Remove the tarball.
|
||||
os.remove(GCLOUD_ARCHIVE)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
import argparse
|
||||
import common
|
||||
import shutil
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
@ -24,12 +25,14 @@ def main():
|
||||
|
||||
with utils.tmp_dir():
|
||||
cwd = os.getcwd()
|
||||
workdir = os.path.join(cwd, "workdir")
|
||||
create_script = os.path.join(common.FILE_DIR, 'create.py')
|
||||
upload_script = os.path.join(common.FILE_DIR, 'upload.py')
|
||||
|
||||
try:
|
||||
subprocess.check_call(['python', create_script, '-t', cwd])
|
||||
cmd = ['python', upload_script, '-t', cwd]
|
||||
os.mkdir(workdir)
|
||||
subprocess.check_call(['python', create_script, '-t', workdir])
|
||||
cmd = ['python', upload_script, '-t', workdir]
|
||||
if args.gsutil:
|
||||
cmd.extend(['--gsutil', args.gsutil])
|
||||
subprocess.check_call(cmd)
|
||||
|
Loading…
Reference in New Issue
Block a user