This repository has been archived by the owner on Sep 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #423 from kysect/fix/use-org-client
Use service organization client instead of app client
- Loading branch information
Showing
6 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ation/Kysect.Shreks.Integration.Github/Client/IServiceOrganizationGithubClientProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Octokit; | ||
|
||
namespace Kysect.Shreks.Integration.Github.Client; | ||
|
||
public interface IServiceOrganizationGithubClientProvider | ||
{ | ||
Task<GitHubClient> GetClient(); | ||
} |
27 changes: 27 additions & 0 deletions
27
...ration/Kysect.Shreks.Integration.Github/Client/ServiceOrganizationGithubClientProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Octokit; | ||
|
||
namespace Kysect.Shreks.Integration.Github.Client; | ||
|
||
public class ServiceOrganizationGithubClientProvider : IServiceOrganizationGithubClientProvider | ||
{ | ||
private readonly IGitHubClient _appClient; | ||
private readonly IInstallationClientFactory _clientFactory; | ||
private readonly string _serviceOrganization; | ||
|
||
public ServiceOrganizationGithubClientProvider(IGitHubClient appClient, IInstallationClientFactory clientFactory, string serviceOrganization) | ||
{ | ||
ArgumentNullException.ThrowIfNull(appClient); | ||
ArgumentNullException.ThrowIfNull(clientFactory); | ||
ArgumentNullException.ThrowIfNull(serviceOrganization); | ||
|
||
_appClient = appClient; | ||
_clientFactory = clientFactory; | ||
_serviceOrganization = serviceOrganization; | ||
} | ||
|
||
public async Task<GitHubClient> GetClient() | ||
{ | ||
Installation installation = await _appClient.GitHubApps.GetOrganizationInstallationForCurrent(_serviceOrganization); | ||
return _clientFactory.GetClient(installation.Id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 7 additions & 4 deletions
11
...frastructure/Integration/Kysect.Shreks.Integration.Github/Providers/GithubUserProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters