Skip to content

Commit

Permalink
Added api_base_path option for GitHub Enterprise compatibility (#983)
Browse files Browse the repository at this point in the history
Added api_base_path option for GitHub Enterprise compatibility
  • Loading branch information
betatim authored Oct 25, 2019
2 parents 95e023e + a95081a commit 29e7546
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions binderhub/repoproviders.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,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
Expand Down Expand Up @@ -649,9 +660,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)
Expand Down

0 comments on commit 29e7546

Please sign in to comment.