Commit ae280428 authored by joedow's avatar joedow Committed by Commit bot

Updating App Remoting build files to include an OAuth2 client ID and manifest...

Updating App Remoting build files to include an OAuth2 client ID and manifest key which we will set in the manifest at build time.  This removes the need to run any scripts before uploading to the webstore.

Chromoting updates will be handled in a subsequent change (TODO added).

Also made a few changes to handle the new prod_testing environment.

BUG=

Review URL: https://codereview.chromium.org/1062963002

Cr-Commit-Position: refs/heads/master@{#324067}
parent f1becdc3
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
'app_name': 'App Remoting Client', 'app_name': 'App Remoting Client',
'app_description': 'App Remoting client', 'app_description': 'App Remoting client',
'app_capabilities': ['GOOGLE_DRIVE'], 'app_capabilities': ['GOOGLE_DRIVE'],
'manifest_key': 'remotingdevbuild',
}, },
], # end of targets ], # end of targets
} }
...@@ -131,6 +131,10 @@ ...@@ -131,6 +131,10 @@
'>@(_app_capabilities)', '>@(_app_capabilities)',
'--service_environment', '--service_environment',
'<@(ar_service_environment)', '<@(ar_service_environment)',
'--manifest_key',
'>@(_manifest_key)',
'--app_client_id',
'>@(_app_client_id)',
], ],
}, },
{ {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# Set this to enable cast mode on the android client. # Set this to enable cast mode on the android client.
'enable_cast%': 0, 'enable_cast%': 0,
# Set this to use GCD instead of the remoting directory service. # Set this to use GCD instead of the remoting directory service.
'remoting_use_gcd%': 0, 'remoting_use_gcd%': 0,
...@@ -33,13 +33,13 @@ ...@@ -33,13 +33,13 @@
# The ar_service_environment variable is used to define the target # The ar_service_environment variable is used to define the target
# environment for the app being built. # environment for the app being built.
# The allowed values are dev, test, staging, and prod. # The allowed values are dev, test, staging, prod, and prod-testing.
'conditions': [ 'conditions': [
['buildtype == "Dev"', { ['buildtype == "Dev"', {
'ar_service_environment%': 'dev', 'ar_service_environment%': 'dev',
}, { # buildtype != 'Dev' }, { # buildtype != 'Dev'
# Non-dev build must have this set to 'prod'. # Non-dev builds should default to 'prod'.
'ar_service_environment': 'prod', 'ar_service_environment%': 'prod',
}], }],
], # conditions ], # conditions
......
...@@ -107,9 +107,9 @@ def processJinjaTemplate(input_file, include_paths, output_file, context): ...@@ -107,9 +107,9 @@ def processJinjaTemplate(input_file, include_paths, output_file, context):
io.open(output_file, 'w', encoding='utf-8').write(rendered) io.open(output_file, 'w', encoding='utf-8').write(rendered)
def buildWebApp(buildtype, version, destination, zip_path, def buildWebApp(buildtype, version, destination, zip_path,
manifest_template, webapp_type, appid, app_name, manifest_template, webapp_type, appid, app_client_id, app_name,
app_description, app_capabilities, files, locales_listfile, app_description, app_capabilities, manifest_key, files,
jinja_paths, service_environment, use_gcd): locales_listfile, jinja_paths, service_environment, use_gcd):
"""Does the main work of building the webapp directory and zipfile. """Does the main work of building the webapp directory and zipfile.
Args: Args:
...@@ -123,10 +123,12 @@ def buildWebApp(buildtype, version, destination, zip_path, ...@@ -123,10 +123,12 @@ def buildWebApp(buildtype, version, destination, zip_path,
appid: A string with the Remoting Application Id (only used for app appid: A string with the Remoting Application Id (only used for app
remoting webapps). If supplied, it defaults to using the remoting webapps). If supplied, it defaults to using the
test API server. test API server.
app_client_id: The OAuth2 client ID for the webapp.
app_name: A string with the name of the application. app_name: A string with the name of the application.
app_description: A string with the description of the application. app_description: A string with the description of the application.
app_capabilities: A set of strings naming the capabilities that should be app_capabilities: A set of strings naming the capabilities that should be
enabled for this application. enabled for this application.
manifest_key: The manifest key for the webapp.
files: An array of strings listing the paths for resources to include files: An array of strings listing the paths for resources to include
in this webapp. in this webapp.
locales_listfile: The name of a file containing a list of locales, one per locales_listfile: The name of a file containing a list of locales, one per
...@@ -134,8 +136,8 @@ def buildWebApp(buildtype, version, destination, zip_path, ...@@ -134,8 +136,8 @@ def buildWebApp(buildtype, version, destination, zip_path,
the _locales directory down. the _locales directory down.
jinja_paths: An array of paths to search for {%include} directives in jinja_paths: An array of paths to search for {%include} directives in
addition to the directory containing the manifest template. addition to the directory containing the manifest template.
service_environment: Used to point the webApp to one of the service_environment: Used to point the webapp to one of the
dev/test/staging/prod environments dev/test/staging/prod/prod-testing environments
use_gcd: True if GCD support should be enabled. use_gcd: True if GCD support should be enabled.
""" """
...@@ -212,7 +214,10 @@ def buildWebApp(buildtype, version, destination, zip_path, ...@@ -212,7 +214,10 @@ def buildWebApp(buildtype, version, destination, zip_path,
directoryApiHost = os.environ.get( directoryApiHost = os.environ.get(
'DIRECTORY_API_HOST', 'https://www.googleapis.com') 'DIRECTORY_API_HOST', 'https://www.googleapis.com')
if webapp_type == 'app_remoting': is_app_remoting_webapp = webapp_type == 'app_remoting'
is_prod_service_environment = service_environment == 'prod' or \
service_environment == 'prod-testing'
if is_app_remoting_webapp:
appRemotingApiHost = os.environ.get( appRemotingApiHost = os.environ.get(
'APP_REMOTING_API_HOST', None) 'APP_REMOTING_API_HOST', None)
appRemotingApplicationId = os.environ.get( appRemotingApplicationId = os.environ.get(
...@@ -223,11 +228,11 @@ def buildWebApp(buildtype, version, destination, zip_path, ...@@ -223,11 +228,11 @@ def buildWebApp(buildtype, version, destination, zip_path,
# being generated correctly (no overrides) and with the correct buildtype. # being generated correctly (no overrides) and with the correct buildtype.
# They also verify that folks are not accidentally building dev/test/staging # They also verify that folks are not accidentally building dev/test/staging
# apps for release (no impersonation) instead of dev. # apps for release (no impersonation) instead of dev.
if service_environment == 'prod' and buildtype == 'Dev': if is_prod_service_environment and buildtype == 'Dev':
raise Exception("Prod environment cannot be built for 'dev' builds") raise Exception("Prod environment cannot be built for 'dev' builds")
if buildtype != 'Dev': if buildtype != 'Dev':
if service_environment != 'prod': if not is_prod_service_environment:
raise Exception('Invalid service_environment targeted for ' raise Exception('Invalid service_environment targeted for '
+ buildtype + ': ' + service_environment) + buildtype + ': ' + service_environment)
if 'out/Release' not in destination and 'out\Release' not in destination: if 'out/Release' not in destination and 'out\Release' not in destination:
...@@ -256,10 +261,10 @@ def buildWebApp(buildtype, version, destination, zip_path, ...@@ -256,10 +261,10 @@ def buildWebApp(buildtype, version, destination, zip_path,
oauth2ApiBaseUrl = oauth2ApiHost + '/oauth2' oauth2ApiBaseUrl = oauth2ApiHost + '/oauth2'
directoryApiBaseUrl = directoryApiHost + '/chromoting/v1' directoryApiBaseUrl = directoryApiHost + '/chromoting/v1'
if webapp_type == 'app_remoting': if is_app_remoting_webapp:
# Set the apiary endpoint and then set the endpoint version # Set the apiary endpoint and then set the endpoint version
if not appRemotingApiHost: if not appRemotingApiHost:
if service_environment == 'prod': if is_prod_service_environment:
appRemotingApiHost = 'https://www.googleapis.com' appRemotingApiHost = 'https://www.googleapis.com'
else: else:
appRemotingApiHost = 'https://www-googleapis-test.sandbox.google.com' appRemotingApiHost = 'https://www-googleapis-test.sandbox.google.com'
...@@ -272,6 +277,8 @@ def buildWebApp(buildtype, version, destination, zip_path, ...@@ -272,6 +277,8 @@ def buildWebApp(buildtype, version, destination, zip_path,
appRemotingServicePath = '/appremoting/v1beta1_staging' appRemotingServicePath = '/appremoting/v1beta1_staging'
elif service_environment == 'prod': elif service_environment == 'prod':
appRemotingServicePath = '/appremoting/v1beta1' appRemotingServicePath = '/appremoting/v1beta1'
elif service_environment == 'prod-testing':
appRemotingServicePath = '/appremoting/v1beta1_prod_testing'
else: else:
raise Exception('Unknown service environment: ' + service_environment) raise Exception('Unknown service environment: ' + service_environment)
appRemotingApiBaseUrl = appRemotingApiHost + appRemotingServicePath appRemotingApiBaseUrl = appRemotingApiHost + appRemotingServicePath
...@@ -282,7 +289,7 @@ def buildWebApp(buildtype, version, destination, zip_path, ...@@ -282,7 +289,7 @@ def buildWebApp(buildtype, version, destination, zip_path,
replaceString(destination, 'OAUTH2_BASE_URL', oauth2BaseUrl) replaceString(destination, 'OAUTH2_BASE_URL', oauth2BaseUrl)
replaceString(destination, 'OAUTH2_API_BASE_URL', oauth2ApiBaseUrl) replaceString(destination, 'OAUTH2_API_BASE_URL', oauth2ApiBaseUrl)
replaceString(destination, 'DIRECTORY_API_BASE_URL', directoryApiBaseUrl) replaceString(destination, 'DIRECTORY_API_BASE_URL', directoryApiBaseUrl)
if webapp_type == 'app_remoting': if is_app_remoting_webapp:
replaceString(destination, 'APP_REMOTING_API_BASE_URL', replaceString(destination, 'APP_REMOTING_API_BASE_URL',
appRemotingApiBaseUrl) appRemotingApiBaseUrl)
...@@ -343,7 +350,14 @@ def buildWebApp(buildtype, version, destination, zip_path, ...@@ -343,7 +350,14 @@ def buildWebApp(buildtype, version, destination, zip_path,
# For overriding the client ID/secret via env vars, see google_api_keys.py. # For overriding the client ID/secret via env vars, see google_api_keys.py.
apiClientId = google_api_keys.GetClientID('REMOTING') apiClientId = google_api_keys.GetClientID('REMOTING')
apiClientSecret = google_api_keys.GetClientSecret('REMOTING') apiClientSecret = google_api_keys.GetClientSecret('REMOTING')
apiClientIdV2 = google_api_keys.GetClientID('REMOTING_IDENTITY_API')
if is_app_remoting_webapp and buildtype != 'Dev':
if not app_client_id:
raise Exception('Invalid app_client_id passed in: "' +
app_client_id + '"')
apiClientIdV2 = app_client_id
else:
apiClientIdV2 = google_api_keys.GetClientID('REMOTING_IDENTITY_API')
replaceString(destination, 'API_CLIENT_ID', apiClientId) replaceString(destination, 'API_CLIENT_ID', apiClientId)
replaceString(destination, 'API_CLIENT_SECRET', apiClientSecret) replaceString(destination, 'API_CLIENT_SECRET', apiClientSecret)
...@@ -357,7 +371,16 @@ def buildWebApp(buildtype, version, destination, zip_path, ...@@ -357,7 +371,16 @@ def buildWebApp(buildtype, version, destination, zip_path,
# Use a consistent extension id for dev builds. # Use a consistent extension id for dev builds.
# AppRemoting builds always use the dev app id - the correct app id gets # AppRemoting builds always use the dev app id - the correct app id gets
# written into the manifest later. # written into the manifest later.
if buildtype != 'Official' or webapp_type == 'app_remoting': if is_app_remoting_webapp:
if buildtype != 'Dev':
if not manifest_key:
raise Exception('Invalid manifest_key passed in: "' +
manifest_key + '"')
manifestKey = '"key": "' + manifest_key + '",'
else:
manifestKey = '"key": "remotingdevbuild",'
elif buildtype != 'Official':
# TODO(joedow): Update the chromoting webapp GYP entries to include keys.
manifestKey = '"key": "remotingdevbuild",' manifestKey = '"key": "remotingdevbuild",'
else: else:
manifestKey = '' manifestKey = ''
...@@ -412,6 +435,8 @@ def main(): ...@@ -412,6 +435,8 @@ def main():
parser.add_argument('--app_capabilities', parser.add_argument('--app_capabilities',
nargs='*', default=[], metavar='CAPABILITY') nargs='*', default=[], metavar='CAPABILITY')
parser.add_argument('--appid') parser.add_argument('--appid')
parser.add_argument('--app_client_id', default='')
parser.add_argument('--manifest_key', default='')
parser.add_argument('--locales_listfile', default='', metavar='PATH') parser.add_argument('--locales_listfile', default='', metavar='PATH')
parser.add_argument('--jinja_paths', nargs='*', default=[], metavar='PATH') parser.add_argument('--jinja_paths', nargs='*', default=[], metavar='PATH')
parser.add_argument('--service_environment', default='', metavar='ENV') parser.add_argument('--service_environment', default='', metavar='ENV')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment