commitcloud: improve naming and clean up unused code

Reviewed By: singhsrb

Differential Revision: D8154257

fbshipit-source-id: ee3f8652831a450c61c1eb1cdda184d80e24307d
This commit is contained in:
Liubov Dmitrieva 2018-05-24 17:37:40 -07:00 committed by Facebook Github Bot
parent 12796cbac0
commit 76e4306d8b
3 changed files with 11 additions and 17 deletions

View File

@ -8,7 +8,7 @@
[commitcloud]
# type of commit cloud service to connect to
# local or interngraph
# local or remote
servicetype = local
# location of the commit cloud service to connect to
@ -17,15 +17,8 @@
# hostname to use for the system
hostname = myhost
# host of commitcloud proxy
host = interngraph.intern.facebook.com
# user token
# private user token to access the commit cloud service
user_token = *****************************
# application id that identifies commit cloud in interngraph
app_id = 361121054385388
# Http endpoint host serving Commit Cloud requests
remote_host = example.commitcloud.com
# SSL certificates
certs = /etc/pki/tls/certs/fb_certs.pem
@ -43,7 +36,8 @@
# update to a new revision if the current revision has been moved
updateonmove = true
# option to print requests to Commit Cloud web endpoint (in debug level)
# option to print incoming and outgoing requests to
# Commit Cloud http endpoint in json format (with --debug option only)
debugrequests = true
"""

View File

@ -43,7 +43,7 @@ DEFAULT_TIMEOUT = 60
MAX_CONNECT_RETRIES = 2
class HttpsCommitCloudService(baseservice.BaseService):
"""Commit Cloud Client uses interngraph proxy to communicate with
"""Commit Cloud Client uses http endpoint to communicate with
Commit Cloud Service
"""
@ -54,7 +54,7 @@ class HttpsCommitCloudService(baseservice.BaseService):
raise commitcloudcommon.RegistrationError(
ui, _('valid user token is required'))
self.host = ui.config('commitcloud', 'host')
self.remote_host = ui.config('commitcloud', 'remote_host')
# optional, but needed for using a sandbox
self.certs = ui.config('commitcloud', 'certs')
@ -72,15 +72,15 @@ class HttpsCommitCloudService(baseservice.BaseService):
'Authorization': 'OAuth %s' % token,
}
self.connection = httplib.HTTPSConnection(
self.host,
self.remote_host,
context=ssl.create_default_context(cafile=self.certs)
if self.certs else ssl.create_default_context(),
timeout=DEFAULT_TIMEOUT
)
if not self.host:
if not self.remote_host:
raise commitcloudcommon.ConfigurationError(
self.ui, _('host is required'))
self.ui, _('remote_host is required'))
def requiresauthentication(self):
return True

View File

@ -17,7 +17,7 @@ def get(ui, token=None):
servicetype = ui.config('commitcloud', 'servicetype')
if servicetype == 'local':
return localservice.LocalService(ui)
elif servicetype == 'interngraph':
elif servicetype == 'remote':
return httpsservice.HttpsCommitCloudService(ui, token)
else:
msg = 'Unrecognized commitcloud.servicetype: %s' % servicetype