From a95081a6e58eaa424448ae631f473caa268b8f5f Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Tue, 22 Oct 2019 22:28:20 -0500 Subject: [PATCH] Added api_base_path option for GitHub Enterprise compatibility. #issue-972 --- binderhub/repoproviders.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/binderhub/repoproviders.py b/binderhub/repoproviders.py index 3f7b2bfc5..4e5943745 100644 --- a/binderhub/repoproviders.py +++ b/binderhub/repoproviders.py @@ -434,6 +434,17 @@ class GitHubRepoProvider(RepoProvider): e.g. GitHub Enterprise. """) + api_base_path = Unicode('https://api.{hostname}', + config=True, + help="""The base path of the GitHub API + + Only necessary if not github.com, + e.g. GitHub Enterprise. + + Can use {hostname} for substitution, + e.g. 'https://{hostname}/api/v3' + """) + client_id = Unicode(config=True, help="""GitHub client id for authentication with the GitHub API @@ -580,9 +591,9 @@ def get_resolved_ref(self): if hasattr(self, 'resolved_ref'): return self.resolved_ref - api_url = "https://api.{hostname}/repos/{user}/{repo}/commits/{ref}".format( - user=self.user, repo=self.repo, ref=self.unresolved_ref, - hostname=self.hostname, + api_url = "{api_base_path}/repos/{user}/{repo}/commits/{ref}".format( + api_base_path=self.api_base_path.format(hostname=self.hostname), + user=self.user, repo=self.repo, ref=self.unresolved_ref ) self.log.debug("Fetching %s", api_url) cached = self.cache.get(api_url)