From 2467fcf545bbf377e7b440396a81e25fe35afe98 Mon Sep 17 00:00:00 2001 From: Reid Orsten Date: Sun, 9 Aug 2020 11:52:34 -0400 Subject: [PATCH 1/2] support github enterprise source config --- README.org | 2 ++ lib/github-status/support/github.rb | 2 ++ lib/github-status/support/source.rb | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/README.org b/README.org index e5507bf..6d85a78 100644 --- a/README.org +++ b/README.org @@ -25,6 +25,8 @@ Add the resource to your pipeline's ~resource_types~ (requires Concourse 0.74.0+ |--------------+----------+-------------------------------------------------------------| | repo | Yes | The GitHub repository in ~user/repo~ format | | access_token | Yes | The access token to use with the GitHub API | +| api_endpoint | No | API endpoint of a GitHub Enterprise installation | +| web_endpoint | No | Base web URL of a GitHub Enterprise Installation | |--------------+----------+-------------------------------------------------------------| * Behaviour diff --git a/lib/github-status/support/github.rb b/lib/github-status/support/github.rb index 94d96b1..302aec8 100644 --- a/lib/github-status/support/github.rb +++ b/lib/github-status/support/github.rb @@ -10,6 +10,8 @@ module GitHub Contract None => Octokit::Client def github + Octokit.api_endpoint = api_endpoint + Octokit.web_endpoint = web_endpoint @github ||= Octokit::Client.new access_token: access_token end diff --git a/lib/github-status/support/source.rb b/lib/github-status/support/source.rb index 6b05aaa..615f8e9 100644 --- a/lib/github-status/support/source.rb +++ b/lib/github-status/support/source.rb @@ -26,6 +26,16 @@ def repo def branch @branch ||= source.fetch('branch') { 'master' } end + + Contract None => String + def api_endpoint + @api_endpoint ||= source.fetch('api_endpoint') { nil } + end + + Contract None => String + def web_endpoint + @web_endpoint ||= source.fetch('web_endpoint') { nil } + end end end end From faa219e358079111a9e724e2b368266b1e5f5494 Mon Sep 17 00:00:00 2001 From: Reid Orsten Date: Sun, 9 Aug 2020 12:10:08 -0400 Subject: [PATCH 2/2] conditional assignment to not break normal github --- README.org | 2 +- lib/github-status/support/github.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 6d85a78..b4befde 100644 --- a/README.org +++ b/README.org @@ -25,7 +25,7 @@ Add the resource to your pipeline's ~resource_types~ (requires Concourse 0.74.0+ |--------------+----------+-------------------------------------------------------------| | repo | Yes | The GitHub repository in ~user/repo~ format | | access_token | Yes | The access token to use with the GitHub API | -| api_endpoint | No | API endpoint of a GitHub Enterprise installation | +| api_endpoint | No | Base API URL of a GitHub Enterprise installation | | web_endpoint | No | Base web URL of a GitHub Enterprise Installation | |--------------+----------+-------------------------------------------------------------| diff --git a/lib/github-status/support/github.rb b/lib/github-status/support/github.rb index 302aec8..bace214 100644 --- a/lib/github-status/support/github.rb +++ b/lib/github-status/support/github.rb @@ -10,8 +10,8 @@ module GitHub Contract None => Octokit::Client def github - Octokit.api_endpoint = api_endpoint - Octokit.web_endpoint = web_endpoint + Octokit.api_endpoint = api_endpoint if api_endpoint + Octokit.web_endpoint = web_endpoint if web_endpoint @github ||= Octokit::Client.new access_token: access_token end