diff --git a/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs b/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs
index 00a99c6330..88922870f8 100644
--- a/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs
+++ b/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs
@@ -50,16 +50,16 @@ namespace Tgstation.Server.Host.Utils.GitHub
///
readonly IHttpMessageHandlerFactory httpMessageHandlerFactory;
+ ///
+ /// The of for the .
+ ///
+ readonly IOptionsMonitor generalConfigurationOptions;
+
///
/// The for the .
///
readonly ILogger logger;
- ///
- /// The for the .
- ///
- readonly GeneralConfiguration generalConfiguration;
-
///
/// Cache of created s and last used/expiry times, keyed by access token.
///
@@ -76,17 +76,17 @@ namespace Tgstation.Server.Host.Utils.GitHub
/// The value of .
/// The value of .
/// The value of .
- /// The containing the value of .
+ /// The containing the value of .
public GitHubClientFactory(
IAssemblyInformationProvider assemblyInformationProvider,
IHttpMessageHandlerFactory httpMessageHandlerFactory,
- ILogger logger,
- IOptions generalConfigurationOptions)
+ IOptionsMonitor generalConfigurationOptions,
+ ILogger logger)
{
this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
this.httpMessageHandlerFactory = httpMessageHandlerFactory ?? throw new ArgumentNullException(nameof(httpMessageHandlerFactory));
+ this.generalConfigurationOptions = generalConfigurationOptions ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
- generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
clientCache = new Dictionary();
clientCacheSemaphore = new SemaphoreSlim(1, 1);
@@ -98,7 +98,7 @@ namespace Tgstation.Server.Host.Utils.GitHub
///
public async ValueTask CreateClient(CancellationToken cancellationToken)
=> (await GetOrCreateClient(
- generalConfiguration.GitHubAccessToken,
+ generalConfigurationOptions.CurrentValue.GitHubAccessToken,
null,
cancellationToken))!;
diff --git a/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs b/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs
index 1d5fb5ef31..f7c1c43d9f 100644
--- a/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs
+++ b/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs
@@ -27,22 +27,22 @@ namespace Tgstation.Server.Host.Utils.GitHub
///
/// The for the .
///
- readonly UpdatesConfiguration updatesConfiguration;
+ readonly IOptionsMonitor updatesConfigurationOptions;
///
/// Initializes a new instance of the class.
///
/// The value of .
/// The value of .
- /// The containing value of .
+ /// The value of .
public GitHubServiceFactory(
IGitHubClientFactory gitHubClientFactory,
ILoggerFactory loggerFactory,
- IOptions updatesConfigurationOptions)
+ IOptionsMonitor updatesConfigurationOptions)
{
this.gitHubClientFactory = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory));
this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
- updatesConfiguration = updatesConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(updatesConfigurationOptions));
+ this.updatesConfigurationOptions = updatesConfigurationOptions ?? throw new ArgumentNullException(nameof(updatesConfigurationOptions));
}
///
@@ -79,6 +79,6 @@ namespace Tgstation.Server.Host.Utils.GitHub
=> new(
gitHubClient,
loggerFactory.CreateLogger(),
- updatesConfiguration);
+ updatesConfigurationOptions.CurrentValue);
}
}
diff --git a/src/Tgstation.Server.Host/Utils/PortAllocator.cs b/src/Tgstation.Server.Host/Utils/PortAllocator.cs
index 235889d281..70c5a89d5e 100644
--- a/src/Tgstation.Server.Host/Utils/PortAllocator.cs
+++ b/src/Tgstation.Server.Host/Utils/PortAllocator.cs
@@ -34,16 +34,16 @@ namespace Tgstation.Server.Host.Utils
///
readonly IPlatformIdentifier platformIdentifier;
+ ///
+ /// The of for the .
+ ///
+ readonly IOptions swarmConfigurationOptions;
+
///
/// The for the .
///
readonly ILogger logger;
- ///
- /// The for the .
- ///
- readonly SwarmConfiguration swarmConfiguration;
-
///
/// The used to serialized port requisition requests.
///
@@ -55,7 +55,7 @@ namespace Tgstation.Server.Host.Utils
/// The value of .
/// The value of .
/// The value of .
- /// The containing the value of .
+ /// The value of .
/// The value of .
public PortAllocator(
IServerPortProvider serverPortProvider,
@@ -67,7 +67,7 @@ namespace Tgstation.Server.Host.Utils
this.serverPortProvider = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider));
this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
- swarmConfiguration = swarmConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(swarmConfigurationOptions));
+ this.swarmConfigurationOptions = swarmConfigurationOptions ?? throw new ArgumentNullException(nameof(swarmConfigurationOptions));
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
allocatorLock = new SemaphoreSlim(1);
@@ -99,7 +99,7 @@ namespace Tgstation.Server.Host.Utils
logger.LogTrace("Port allocation >= {basePort} requested...", basePort);
var ddPorts = await databaseContext
.DreamDaemonSettings
- .Where(x => x.Instance!.SwarmIdentifer == swarmConfiguration.Identifier)
+ .Where(x => x.Instance!.SwarmIdentifer == swarmConfigurationOptions.Value.Identifier)
.Select(x => new
{
Port = x.Port!.Value,
@@ -109,7 +109,7 @@ namespace Tgstation.Server.Host.Utils
var dmPorts = await databaseContext
.DreamMakerSettings
- .Where(x => x.Instance!.SwarmIdentifer == swarmConfiguration.Identifier)
+ .Where(x => x.Instance!.SwarmIdentifer == swarmConfigurationOptions.Value.Identifier)
.Select(x => new
{
ApiValidationPort = x.ApiValidationPort!.Value,
diff --git a/tests/Tgstation.Server.Host.Tests/Utils/GitHub/TestGitHubClientFactory.cs b/tests/Tgstation.Server.Host.Tests/Utils/GitHub/TestGitHubClientFactory.cs
index 56126a1df7..046c1b061f 100644
--- a/tests/Tgstation.Server.Host.Tests/Utils/GitHub/TestGitHubClientFactory.cs
+++ b/tests/Tgstation.Server.Host.Tests/Utils/GitHub/TestGitHubClientFactory.cs
@@ -47,7 +47,7 @@ namespace Tgstation.Server.Host.Utils.GitHub.Tests
Assert.ThrowsExactly(() => new GitHubClientFactory(null, null, null, null));
Assert.ThrowsExactly(() => new GitHubClientFactory(Mock.Of(), null, null, null));
Assert.ThrowsExactly(() => new GitHubClientFactory(Mock.Of(), Mock.Of(), null, null));
- Assert.ThrowsExactly(() => new GitHubClientFactory(Mock.Of(), Mock.Of(), Mock.Of>(), null));
+ Assert.ThrowsExactly(() => new GitHubClientFactory(Mock.Of(), Mock.Of(), Mock.Of>(), null));
}
[TestMethod]
@@ -56,12 +56,12 @@ namespace Tgstation.Server.Host.Utils.GitHub.Tests
var mockApp = new Mock();
mockApp.SetupGet(x => x.ProductInfoHeaderValue).Returns(new ProductInfoHeaderValue("TGSTests", "1.2.3")).Verifiable();
- var mockOptions = new Mock>();
+ var mockOptions = new Mock>();
var gc = new GeneralConfiguration();
Assert.IsNull(gc.GitHubAccessToken);
- mockOptions.SetupGet(x => x.Value).Returns(gc);
- var factory = new GitHubClientFactory(mockApp.Object, new BasicHttpMessageHandlerFactory(), loggerFactory.CreateLogger(), mockOptions.Object);
+ mockOptions.SetupGet(x => x.CurrentValue).Returns(gc);
+ var factory = new GitHubClientFactory(mockApp.Object, new BasicHttpMessageHandlerFactory(), mockOptions.Object, loggerFactory.CreateLogger());
var client = await factory.CreateClient(CancellationToken.None);
Assert.IsNotNull(client);
@@ -85,9 +85,9 @@ namespace Tgstation.Server.Host.Utils.GitHub.Tests
var mockApp = new Mock();
mockApp.SetupGet(x => x.ProductInfoHeaderValue).Returns(new ProductInfoHeaderValue("TGSTests", "1.2.3")).Verifiable();
- var mockOptions = new Mock>();
- mockOptions.SetupGet(x => x.Value).Returns(new GeneralConfiguration());
- var factory = new GitHubClientFactory(mockApp.Object, new BasicHttpMessageHandlerFactory(), loggerFactory.CreateLogger(), mockOptions.Object);
+ var mockOptions = new Mock>();
+ mockOptions.SetupGet(x => x.CurrentValue).Returns(new GeneralConfiguration());
+ var factory = new GitHubClientFactory(mockApp.Object, new BasicHttpMessageHandlerFactory(), mockOptions.Object, loggerFactory.CreateLogger());
await Assert.ThrowsExactlyAsync(() => factory.CreateClient(null, CancellationToken.None).AsTask());
@@ -107,9 +107,9 @@ namespace Tgstation.Server.Host.Utils.GitHub.Tests
var mockApp = new Mock();
mockApp.SetupGet(x => x.ProductInfoHeaderValue).Returns(new ProductInfoHeaderValue("TGSTests", "1.2.3")).Verifiable();
- var mockOptions = new Mock>();
- mockOptions.SetupGet(x => x.Value).Returns(new GeneralConfiguration());
- var factory = new GitHubClientFactory(mockApp.Object, new BasicHttpMessageHandlerFactory(), loggerFactory.CreateLogger(), mockOptions.Object);
+ var mockOptions = new Mock>();
+ mockOptions.SetupGet(x => x.CurrentValue).Returns(new GeneralConfiguration());
+ var factory = new GitHubClientFactory(mockApp.Object, new BasicHttpMessageHandlerFactory(), mockOptions.Object, loggerFactory.CreateLogger());
var appID = Environment.GetEnvironmentVariable("TGS_TEST_APP_ID");
var privateKey = Environment.GetEnvironmentVariable("TGS_TEST_APP_PRIVATE_KEY");
@@ -145,9 +145,9 @@ namespace Tgstation.Server.Host.Utils.GitHub.Tests
var mockApp = new Mock();
mockApp.SetupGet(x => x.ProductInfoHeaderValue).Returns(new ProductInfoHeaderValue("TGSTests", "1.2.3")).Verifiable();
- var mockOptions = new Mock>();
- mockOptions.SetupGet(x => x.Value).Returns(new GeneralConfiguration());
- var factory = new GitHubClientFactory(mockApp.Object, new BasicHttpMessageHandlerFactory(), loggerFactory.CreateLogger(), mockOptions.Object);
+ var mockOptions = new Mock>();
+ mockOptions.SetupGet(x => x.CurrentValue).Returns(new GeneralConfiguration());
+ var factory = new GitHubClientFactory(mockApp.Object, new BasicHttpMessageHandlerFactory(), mockOptions.Object, loggerFactory.CreateLogger());
await Assert.ThrowsExactlyAsync(() => factory.CreateClient(null, CancellationToken.None).AsTask());
@@ -193,9 +193,9 @@ vTdVAoGBAI/jjUMdjkY43zhe3w2piwT0fhGfqm9ikdAB9IcgcptuS0ML0ZaWV/eO
var mockApp = new Mock();
mockApp.SetupGet(x => x.ProductInfoHeaderValue).Returns(new ProductInfoHeaderValue("TGSTests", "1.2.3")).Verifiable();
- var mockOptions = new Mock>();
- mockOptions.SetupGet(x => x.Value).Returns(new GeneralConfiguration());
- var factory = new GitHubClientFactory(mockApp.Object, new BasicHttpMessageHandlerFactory(), loggerFactory.CreateLogger(), mockOptions.Object);
+ var mockOptions = new Mock>();
+ mockOptions.SetupGet(x => x.CurrentValue).Returns(new GeneralConfiguration());
+ var factory = new GitHubClientFactory(mockApp.Object, new BasicHttpMessageHandlerFactory(), mockOptions.Object, loggerFactory.CreateLogger());
var client1 = await factory.CreateClient(CancellationToken.None);
var client2 = await factory.CreateClient("asdf", CancellationToken.None);
diff --git a/tests/Tgstation.Server.Host.Tests/Utils/GitHub/TestGitHubServiceFactory.cs b/tests/Tgstation.Server.Host.Tests/Utils/GitHub/TestGitHubServiceFactory.cs
index cef5f6c738..0bef83a84a 100644
--- a/tests/Tgstation.Server.Host.Tests/Utils/GitHub/TestGitHubServiceFactory.cs
+++ b/tests/Tgstation.Server.Host.Tests/Utils/GitHub/TestGitHubServiceFactory.cs
@@ -23,8 +23,8 @@ namespace Tgstation.Server.Host.Utils.GitHub.Tests
Assert.ThrowsExactly(() => new GitHubServiceFactory(null, null, null));
Assert.ThrowsExactly(() => new GitHubServiceFactory(Mock.Of(), null, null));
Assert.ThrowsExactly(() => new GitHubServiceFactory(Mock.Of(), Mock.Of(), null));
- var mockOptions = new Mock>();
- mockOptions.SetupGet(x => x.Value).Returns(new UpdatesConfiguration());
+ var mockOptions = new Mock>();
+ mockOptions.SetupGet(x => x.CurrentValue).Returns(new UpdatesConfiguration());
_ = new GitHubServiceFactory(Mock.Of(), Mock.Of(), mockOptions.Object);
}
@@ -41,8 +41,8 @@ namespace Tgstation.Server.Host.Utils.GitHub.Tests
mockFactory.Setup(x => x.CreateClient(mockToken, It.IsAny())).Returns(ValueTask.FromResult(Mock.Of())).Verifiable();
#pragma warning restore CA2012 // Use ValueTasks correctly
- var mockOptions = new Mock>();
- mockOptions.SetupGet(x => x.Value).Returns(new UpdatesConfiguration());
+ var mockOptions = new Mock>();
+ mockOptions.SetupGet(x => x.CurrentValue).Returns(new UpdatesConfiguration());
var factory = new GitHubServiceFactory(mockFactory.Object, Mock.Of(), mockOptions.Object);
diff --git a/tests/Tgstation.Server.Tests/Live/TestingGitHubService.cs b/tests/Tgstation.Server.Tests/Live/TestingGitHubService.cs
index 731e653a4c..d420bea426 100644
--- a/tests/Tgstation.Server.Tests/Live/TestingGitHubService.cs
+++ b/tests/Tgstation.Server.Tests/Live/TestingGitHubService.cs
@@ -34,13 +34,13 @@ namespace Tgstation.Server.Tests.Live
static TestingGitHubService()
{
- var mockOptions = new Mock>();
- mockOptions.SetupGet(x => x.Value).Returns(new GeneralConfiguration
+ var mockOptions = new Mock>();
+ mockOptions.SetupGet(x => x.CurrentValue).Returns(new GeneralConfiguration
{
GitHubAccessToken = Environment.GetEnvironmentVariable("TGS_TEST_GITHUB_TOKEN")
});
- var gitHubClientFactory = new GitHubClientFactory(new AssemblyInformationProvider(), new BasicHttpMessageHandlerFactory(), Mock.Of>(), mockOptions.Object);
+ var gitHubClientFactory = new GitHubClientFactory(new AssemblyInformationProvider(), new BasicHttpMessageHandlerFactory(), mockOptions.Object, Mock.Of>());
RealClient = gitHubClientFactory.CreateClient(CancellationToken.None).GetAwaiter().GetResult();
}