diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs
index d327a84db2..17ec7111a1 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs
@@ -73,9 +73,18 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
.FirstAsync(cancellationToken));
var instanceAuthenticated = repositorySettings.AccessToken != null;
- var gitHubService = !instanceAuthenticated
- ? gitHubServiceFactory.CreateService()
- : gitHubServiceFactory.CreateService(repositorySettings.AccessToken);
+ IAuthenticatedGitHubService authenticatedGitHubService;
+ IGitHubService gitHubService;
+ if (instanceAuthenticated)
+ {
+ authenticatedGitHubService = gitHubServiceFactory.CreateService(repositorySettings.AccessToken);
+ gitHubService = authenticatedGitHubService;
+ }
+ else
+ {
+ authenticatedGitHubService = null;
+ gitHubService = gitHubServiceFactory.CreateService();
+ }
var repositoryIdTask = gitHubService.GetRepositoryId(
remoteInformation.RemoteRepositoryOwner,
@@ -91,7 +100,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
Logger.LogTrace("Creating deployment...");
try
{
- compileJob.GitHubDeploymentId = await gitHubService.CreateDeployment(
+ compileJob.GitHubDeploymentId = await authenticatedGitHubService.CreateDeployment(
new NewDeployment(compileJob.RevisionInformation.CommitSha)
{
AutoMerge = false,
@@ -106,7 +115,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
Logger.LogDebug("Created deployment ID {deploymentId}", compileJob.GitHubDeploymentId);
- await gitHubService.CreateDeploymentStatus(
+ await authenticatedGitHubService.CreateDeploymentStatus(
new NewDeploymentStatus(DeploymentState.InProgress)
{
Description = "The project is being deployed",
diff --git a/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs b/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs
index 2000647d73..ba89b52842 100644
--- a/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs
+++ b/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs
@@ -13,8 +13,10 @@ using Tgstation.Server.Host.Extensions;
namespace Tgstation.Server.Host.Utils.GitHub
{
- ///
- sealed class GitHubService : IGitHubService
+ ///
+ /// Service for interacting with GitHub. Authenticated or otherwise.
+ ///
+ sealed class GitHubService : IAuthenticatedGitHubService
{
///
/// The for the .
diff --git a/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs b/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs
index 3873188659..8ff53440a6 100644
--- a/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs
+++ b/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs
@@ -47,7 +47,7 @@ namespace Tgstation.Server.Host.Utils.GitHub
public IGitHubService CreateService() => CreateServiceImpl(gitHubClientFactory.CreateClient());
///
- public IGitHubService CreateService(string accessToken)
+ public IAuthenticatedGitHubService CreateService(string accessToken)
=> CreateServiceImpl(
gitHubClientFactory.CreateClient(
accessToken ?? throw new ArgumentNullException(nameof(accessToken))));
diff --git a/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs b/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs
new file mode 100644
index 0000000000..f920f25912
--- /dev/null
+++ b/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs
@@ -0,0 +1,55 @@
+using System.Threading;
+using System.Threading.Tasks;
+
+using Octokit;
+
+namespace Tgstation.Server.Host.Utils.GitHub
+{
+ ///
+ /// that exposes functions that require authentication.
+ ///
+ public interface IAuthenticatedGitHubService : IGitHubService
+ {
+ ///
+ /// Create a comment on a given .
+ ///
+ /// The owner of the target repository.
+ /// The name of the target repository.
+ /// The text of the comment.
+ /// The number of the issue to comment on.
+ /// The for the operation.
+ /// A representing the running operation.
+ Task CommentOnIssue(string repoOwner, string repoName, string comment, int issueNumber, CancellationToken cancellationToken);
+
+ ///
+ /// Create a on a target repostiory.
+ ///
+ /// The .
+ /// The owner of the target repository.
+ /// The name of the target repository.
+ /// The for the operation.
+ /// A resulting in the new deployment's ID.
+ Task CreateDeployment(NewDeployment newDeployment, string repoOwner, string repoName, CancellationToken cancellationToken);
+
+ ///
+ /// Create a on a target deployment.
+ ///
+ /// The .
+ /// The owner of the target repository.
+ /// The name of the target repository.
+ /// The ID of the parent deployment.
+ /// The for the operation.
+ /// A representing the running operation.
+ Task CreateDeploymentStatus(NewDeploymentStatus newDeploymentStatus, string repoOwner, string repoName, int deploymentId, CancellationToken cancellationToken);
+
+ ///
+ /// Create a on a target deployment.
+ ///
+ /// The .
+ /// The ID of the target repository.
+ /// The ID of the parent deployment.
+ /// The for the operation.
+ /// A representing the running operation.
+ Task CreateDeploymentStatus(NewDeploymentStatus newDeploymentStatus, long repoId, int deploymentId, CancellationToken cancellationToken);
+ }
+}
diff --git a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs
index 221b5538bc..6c8d479535 100644
--- a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs
+++ b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs
@@ -38,13 +38,6 @@ namespace Tgstation.Server.Host.Utils.GitHub
/// A resulting in a representing the returned OAuth code from GitHub on success, otherwise.
Task CreateOAuthAccessToken(OAuthConfiguration oAuthConfiguration, string code, CancellationToken cancellationToken);
- ///
- /// Get the current user's ID.
- ///
- /// The for the operation.
- /// A resulting in the current user's ID.
- Task GetCurrentUserId(CancellationToken cancellationToken);
-
///
/// Get a target repostiory's ID.
///
@@ -55,46 +48,11 @@ namespace Tgstation.Server.Host.Utils.GitHub
Task GetRepositoryId(string repoOwner, string repoName, CancellationToken cancellationToken);
///
- /// Create a comment on a given .
+ /// Get the current user's ID.
///
- /// The owner of the target repository.
- /// The name of the target repository.
- /// The text of the comment.
- /// The number of the issue to comment on.
/// The for the operation.
- /// A representing the running operation.
- Task CommentOnIssue(string repoOwner, string repoName, string comment, int issueNumber, CancellationToken cancellationToken);
-
- ///
- /// Create a on a target repostiory.
- ///
- /// The .
- /// The owner of the target repository.
- /// The name of the target repository.
- /// The for the operation.
- /// A resulting in the new deployment's ID.
- Task CreateDeployment(NewDeployment newDeployment, string repoOwner, string repoName, CancellationToken cancellationToken);
-
- ///
- /// Create a on a target deployment.
- ///
- /// The .
- /// The owner of the target repository.
- /// The name of the target repository.
- /// The ID of the parent deployment.
- /// The for the operation.
- /// A representing the running operation.
- Task CreateDeploymentStatus(NewDeploymentStatus newDeploymentStatus, string repoOwner, string repoName, int deploymentId, CancellationToken cancellationToken);
-
- ///
- /// Create a on a target deployment.
- ///
- /// The .
- /// The ID of the target repository.
- /// The ID of the parent deployment.
- /// The for the operation.
- /// A representing the running operation.
- Task CreateDeploymentStatus(NewDeploymentStatus newDeploymentStatus, long repoId, int deploymentId, CancellationToken cancellationToken);
+ /// A resulting in the current user's ID.
+ Task GetCurrentUserId(CancellationToken cancellationToken);
///
/// Get a given .
diff --git a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubServiceFactory.cs b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubServiceFactory.cs
index 1bf1f1b850..f4e7be70f5 100644
--- a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubServiceFactory.cs
+++ b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubServiceFactory.cs
@@ -12,10 +12,10 @@
public IGitHubService CreateService();
///
- /// Create a .
+ /// Create an .
///
/// The access token to use for communication with GitHub.
- /// A new .
- public IGitHubService CreateService(string accessToken);
+ /// A new .
+ public IAuthenticatedGitHubService CreateService(string accessToken);
}
}