in tools/genconfig/genconfig.py [0:0]
def get_location_flag(location, url, collection):
"""Location flag for gcloud command based on location in URL."""
# Location will typically be 'global', 'zones/<zone>', or regions/<region>.
# We will assume the presence of a slash denotes one of the latter two.
parts = location.split('/')
if len(parts) > 1:
if parts[0] == 'zones':
return ' '.join(['--zone', parts[1]])
elif parts[0] == 'regions':
return ' '.join(['--region', parts[1]])
raise Exception('Invalid location "' + location + '" in URL: ' + url)
if collection in ['backendServices','forwardingRules']:
return ' --global'
# No slash, assume global and so no location flag is needed.
return ''