cbuildbot: Add GERRIT instance constants to SiteConfig
SiteConfig objects now have the GERRIT instance constants
defined in their SiteParameters. All accesses of these constants
are now done through a SiteConfig object.
The constants themselves have not yet been deleted from the
constants.py module due to other constants depending on them
within the module. This removal will be the subject of a
future bug.
BUG=chromium:492927
TEST=Unittests.
Change-Id: I88aaf4c58aafbc7c3ddb3ff8686e148951b1e639
Reviewed-on: https://chromium-review.googlesource.com/287789
Tested-by: Matthew Sartori <msartori@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Matthew Sartori <msartori@chromium.org>
diff --git a/scripts/gerrit.py b/scripts/gerrit.py
index ae97e49..d5f1f0d 100644
--- a/scripts/gerrit.py
+++ b/scripts/gerrit.py
@@ -15,6 +15,7 @@
import pprint
import re
+from chromite.cbuildbot import config_lib
from chromite.cbuildbot import constants
from chromite.lib import commandline
from chromite.lib import cros_build_lib
@@ -25,6 +26,9 @@
from chromite.lib import terminal
+site_config = config_lib.GetConfig()
+
+
COLOR = None
# Map the internal names to the ones we normally show on the web ui.
@@ -82,7 +86,7 @@
gob = opts.gob
if cl is not None:
if cl.startswith('*'):
- gob = constants.INTERNAL_GOB_INSTANCE
+ gob = site_config.params.INTERNAL_GOB_INSTANCE
cl = cl[1:]
elif ':' in cl:
gob, cl = cl.split(':', 1)
@@ -121,7 +125,7 @@
if opts.raw:
# Special case internal Chrome GoB as that is what most devs use.
# They can always redirect the list elsewhere via the -g option.
- if opts.gob == constants.INTERNAL_GOB_INSTANCE:
+ if opts.gob == site_config.params.INTERNAL_GOB_INSTANCE:
print(constants.INTERNAL_CHANGE_PREFIX, end='')
print(cls['number'])
return
@@ -461,13 +465,13 @@
parser = commandline.ArgumentParser(usage=usage)
parser.add_argument('-i', '--internal', dest='gob', action='store_const',
- default=constants.EXTERNAL_GOB_INSTANCE,
- const=constants.INTERNAL_GOB_INSTANCE,
+ default=site_config.params.EXTERNAL_GOB_INSTANCE,
+ const=site_config.params.INTERNAL_GOB_INSTANCE,
help='Query internal Chromium Gerrit instance')
parser.add_argument('-g', '--gob',
- default=constants.EXTERNAL_GOB_INSTANCE,
+ default=site_config.params.EXTERNAL_GOB_INSTANCE,
help=('Gerrit (on borg) instance to query (default: %s)' %
- (constants.EXTERNAL_GOB_INSTANCE)))
+ (site_config.params.EXTERNAL_GOB_INSTANCE)))
parser.add_argument('--sort', default='number',
help='Key to sort on (number, project)')
parser.add_argument('--raw', default=False, action='store_true',