mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 06:27:19 +01:00
Merge branch 'IOptionsSnapshot' into MoreWork
This commit is contained in:
@@ -14,6 +14,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
fail-on-bad-milestone:
|
||||
if: github.event.pull_request.draft != true
|
||||
name: Fail if Pull Request has no Associated Version Milestone
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
@@ -24,7 +24,7 @@ concurrency:
|
||||
jobs:
|
||||
security-checkpoint:
|
||||
name: Check CI Clearance
|
||||
if: github.event_name == 'pull_request_target' && (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id || github.event.pull_request.user.id == 49699333) && github.event.pull_request.state == 'open'
|
||||
if: github.event_name == 'pull_request_target' && (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id || github.event.pull_request.user.id == 49699333) && github.event.pull_request.state == 'open' && github.event.pull_request.draft != true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Generate App Token
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
ci-pipline-workflow-call:
|
||||
name: CI Pipeline
|
||||
needs: security-checkpoint
|
||||
if: (!(cancelled() || failure()) && (needs.security-checkpoint.result == 'success' || (github.event_name != 'pull_request_target' && github.event.pull_request.head.repo.id == github.event.pull_request.base.repo.id && github.event.pull_request.user.id != 49699333)))
|
||||
if: (!(cancelled() || failure()) && (needs.security-checkpoint.result == 'success' || (github.event_name != 'pull_request_target' && github.event.pull_request.head.repo.id == github.event.pull_request.base.repo.id && github.event.pull_request.user.id != 49699333)) && github.event.pull_request.draft != true)
|
||||
uses: ./.github/workflows/ci-pipeline.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using Remora.Discord.API.Abstractions.Gateway.Commands;
|
||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||
@@ -72,9 +73,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
readonly IAssemblyInformationProvider assemblyInformationProvider;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GeneralConfiguration"/> for the <see cref="DiscordProvider"/>.
|
||||
/// The <see cref="GeneralConfiguration"/> <see cref="IOptionsMonitor{TOptions}"/> for the <see cref="DiscordProvider"/>.
|
||||
/// </summary>
|
||||
readonly GeneralConfiguration generalConfiguration;
|
||||
readonly IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ServiceProvider"/> containing Discord services.
|
||||
@@ -141,18 +142,18 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
/// <param name="logger">The <see cref="ILogger"/> for the <see cref="Provider"/>.</param>
|
||||
/// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param>
|
||||
/// <param name="chatBot">The <see cref="ChatBot"/> for the <see cref="Provider"/>.</param>
|
||||
/// <param name="generalConfiguration">The value of <see cref="generalConfiguration"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The value of <see cref="generalConfigurationOptions"/>.</param>
|
||||
public DiscordProvider(
|
||||
IJobManager jobManager,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
ILogger<DiscordProvider> logger,
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
ChatBot chatBot,
|
||||
GeneralConfiguration generalConfiguration)
|
||||
IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions,
|
||||
ChatBot chatBot)
|
||||
: base(jobManager, asyncDelayer, logger, chatBot)
|
||||
{
|
||||
this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
|
||||
this.generalConfiguration = generalConfiguration ?? throw new ArgumentNullException(nameof(generalConfiguration));
|
||||
this.generalConfigurationOptions = generalConfigurationOptions ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
|
||||
mappedChannels = new List<ulong>();
|
||||
connectDisconnectLock = new object();
|
||||
@@ -924,7 +925,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
true),
|
||||
EngineType.OpenDream => new EmbedField(
|
||||
"OpenDream Version",
|
||||
$"[{engineVersion.SourceSHA![..7]}]({generalConfiguration.OpenDreamGitUrl}/commit/{engineVersion.SourceSHA})",
|
||||
$"[{engineVersion.SourceSHA![..7]}]({generalConfigurationOptions.CurrentValue.OpenDreamGitUrl}/commit/{engineVersion.SourceSHA})",
|
||||
true),
|
||||
_ => throw new InvalidOperationException($"Invaild EngineType: {engineVersion.Engine.Value}"),
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
using Meebey.SmartIrc4net;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -92,7 +93,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
/// <summary>
|
||||
/// The <see cref="FileLoggingConfiguration"/> for the <see cref="IrcProvider"/>.
|
||||
/// </summary>
|
||||
readonly FileLoggingConfiguration loggingConfiguration;
|
||||
readonly IOptionsMonitor<FileLoggingConfiguration> loggingConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IrcFeatures"/> client.
|
||||
@@ -117,18 +118,18 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
/// <param name="logger">The <see cref="ILogger"/> for the <see cref="Provider"/>.</param>
|
||||
/// <param name="assemblyInformationProvider">The <see cref="IAssemblyInformationProvider"/> to get the <see cref="IAssemblyInformationProvider.VersionString"/> from.</param>
|
||||
/// <param name="chatBot">The <see cref="Models.ChatBot"/> for the <see cref="Provider"/>.</param>
|
||||
/// <param name="loggingConfiguration">The <see cref="FileLoggingConfiguration"/> for the <see cref="Provider"/>.</param>
|
||||
/// <param name="loggingConfigurationOptions">The value of <see cref="loggingConfigurationOptions"/>.</param>
|
||||
public IrcProvider(
|
||||
IJobManager jobManager,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
ILogger<IrcProvider> logger,
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
Models.ChatBot chatBot,
|
||||
FileLoggingConfiguration loggingConfiguration)
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
IOptionsMonitor<FileLoggingConfiguration> loggingConfigurationOptions)
|
||||
: base(jobManager, asyncDelayer, logger, chatBot)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(assemblyInformationProvider);
|
||||
ArgumentNullException.ThrowIfNull(loggingConfiguration);
|
||||
ArgumentNullException.ThrowIfNull(loggingConfigurationOptions);
|
||||
|
||||
var builder = chatBot.CreateConnectionStringBuilder();
|
||||
if (builder == null || !builder.Valid || builder is not IrcConnectionStringBuilder ircBuilder)
|
||||
@@ -143,7 +144,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
passwordType = ircBuilder.PasswordType;
|
||||
|
||||
assemblyInfo = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
|
||||
this.loggingConfiguration = loggingConfiguration ?? throw new ArgumentNullException(nameof(loggingConfiguration));
|
||||
this.loggingConfigurationOptions = loggingConfigurationOptions ?? throw new ArgumentNullException(nameof(loggingConfigurationOptions));
|
||||
|
||||
client = InstantiateClient();
|
||||
|
||||
@@ -758,7 +759,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
newClient.OnChannelMessage += Client_OnChannelMessage;
|
||||
newClient.OnQueryMessage += Client_OnQueryMessage;
|
||||
|
||||
if (loggingConfiguration.ProviderNetworkDebug)
|
||||
if (loggingConfigurationOptions.CurrentValue.ProviderNetworkDebug)
|
||||
{
|
||||
newClient.OnReadLine += (sender, e) => Logger.LogTrace("READ: {line}", e.Line);
|
||||
newClient.OnWriteLine += (sender, e) => Logger.LogTrace("WRITE: {line}", e.Line);
|
||||
|
||||
@@ -36,14 +36,14 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
readonly ILoggerFactory loggerFactory;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GeneralConfiguration"/> for the <see cref="ProviderFactory"/>.
|
||||
/// The <see cref="GeneralConfiguration"/> <see cref="IOptionsMonitor{TOptions}"/> for the <see cref="ProviderFactory"/>.
|
||||
/// </summary>
|
||||
readonly GeneralConfiguration generalConfiguration;
|
||||
readonly IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FileLoggingConfiguration"/> for the <see cref="ProviderFactory"/>.
|
||||
/// The <see cref="FileLoggingConfiguration"/> <see cref="IOptionsMonitor{TOptions}"/> for the <see cref="ProviderFactory"/>.
|
||||
/// </summary>
|
||||
readonly FileLoggingConfiguration loggingConfiguration;
|
||||
readonly IOptionsMonitor<FileLoggingConfiguration> loggingConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ProviderFactory"/> class.
|
||||
@@ -52,22 +52,22 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
/// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param>
|
||||
/// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/>.</param>
|
||||
/// <param name="loggerFactory">The value of <see cref="loggerFactory"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
|
||||
/// <param name="loggingConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="loggingConfiguration"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The value of <see cref="generalConfigurationOptions"/>.</param>
|
||||
/// <param name="loggingConfigurationOptions">The value of <see cref="loggingConfigurationOptions"/>.</param>
|
||||
public ProviderFactory(
|
||||
IJobManager jobManager,
|
||||
IAssemblyInformationProvider assemblyInformationProvider,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptions<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptions<FileLoggingConfiguration> loggingConfigurationOptions)
|
||||
IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptionsMonitor<FileLoggingConfiguration> loggingConfigurationOptions)
|
||||
{
|
||||
this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
|
||||
this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
|
||||
this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
|
||||
this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
|
||||
generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
loggingConfiguration = loggingConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(loggingConfigurationOptions));
|
||||
this.generalConfigurationOptions = generalConfigurationOptions ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
this.loggingConfigurationOptions = loggingConfigurationOptions ?? throw new ArgumentNullException(nameof(loggingConfigurationOptions));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -80,16 +80,16 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
jobManager,
|
||||
asyncDelayer,
|
||||
loggerFactory.CreateLogger<IrcProvider>(),
|
||||
assemblyInformationProvider,
|
||||
settings,
|
||||
loggingConfiguration),
|
||||
assemblyInformationProvider,
|
||||
loggingConfigurationOptions),
|
||||
ChatProvider.Discord => new DiscordProvider(
|
||||
jobManager,
|
||||
asyncDelayer,
|
||||
loggerFactory.CreateLogger<DiscordProvider>(),
|
||||
assemblyInformationProvider,
|
||||
settings,
|
||||
generalConfiguration),
|
||||
generalConfigurationOptions,
|
||||
settings),
|
||||
_ => throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Invalid ChatProvider: {0}", settings.Provider)),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// <summary>
|
||||
/// The <see cref="GeneralConfiguration"/> for the <see cref="OpenDreamInstaller"/>.
|
||||
/// </summary>
|
||||
protected GeneralConfiguration GeneralConfiguration { get; }
|
||||
protected IOptionsMonitor<GeneralConfiguration> GeneralConfiguration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Configuration.SessionConfiguration"/> for the <see cref="OpenDreamInstaller"/>.
|
||||
/// </summary>
|
||||
protected SessionConfiguration SessionConfiguration { get; }
|
||||
protected IOptionsMonitor<SessionConfiguration> SessionConfiguration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IPlatformIdentifier"/> for the <see cref="OpenDreamInstaller"/>.
|
||||
@@ -101,8 +101,8 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
IRepositoryManager repositoryManager,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
IHttpClientFactory httpClientFactory,
|
||||
IOptions<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptions<SessionConfiguration> sessionConfigurationOptions)
|
||||
IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions)
|
||||
: base(ioManager, logger)
|
||||
{
|
||||
this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
|
||||
@@ -110,8 +110,8 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
this.repositoryManager = repositoryManager ?? throw new ArgumentNullException(nameof(repositoryManager));
|
||||
this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer));
|
||||
this.httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
|
||||
GeneralConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
SessionConfiguration = sessionConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
GeneralConfiguration = generalConfigurationOptions ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
SessionConfiguration = sessionConfigurationOptions ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -147,10 +147,11 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
|
||||
var progressSection1 = jobProgressReporter.CreateSection("Updating OpenDream git repository", 0.5f);
|
||||
IRepository? repo;
|
||||
var generalConfig = GeneralConfiguration.CurrentValue;
|
||||
try
|
||||
{
|
||||
repo = await repositoryManager.CloneRepository(
|
||||
GeneralConfiguration.OpenDreamGitUrl,
|
||||
generalConfig.OpenDreamGitUrl,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@@ -187,7 +188,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
using (var progressSection2 = jobProgressReporter.CreateSection("Checking out OpenDream version", 0.5f))
|
||||
{
|
||||
var committish = version.SourceSHA
|
||||
?? $"{GeneralConfiguration.OpenDreamGitTagPrefix}{version.Version!.Semver()}";
|
||||
?? $"{generalConfig.OpenDreamGitTagPrefix}{version.Version!.Semver()}";
|
||||
|
||||
await repo.CheckoutObject(
|
||||
committish,
|
||||
@@ -279,6 +280,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
async shortenedPath =>
|
||||
{
|
||||
var shortenedDeployPath = IOManager.ConcatPath(shortenedPath, DeployDir);
|
||||
var generalConfig = GeneralConfiguration.CurrentValue;
|
||||
await using var buildProcess = await ProcessExecutor.LaunchProcess(
|
||||
dotnetPath,
|
||||
shortenedPath,
|
||||
@@ -286,17 +288,17 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
cancellationToken,
|
||||
null,
|
||||
null,
|
||||
!GeneralConfiguration.OpenDreamSuppressInstallOutput,
|
||||
!GeneralConfiguration.OpenDreamSuppressInstallOutput);
|
||||
!generalConfig.OpenDreamSuppressInstallOutput,
|
||||
!generalConfig.OpenDreamSuppressInstallOutput);
|
||||
|
||||
if (deploymentPipelineProcesses && SessionConfiguration.LowPriorityDeploymentProcesses)
|
||||
if (deploymentPipelineProcesses && SessionConfiguration.CurrentValue.LowPriorityDeploymentProcesses)
|
||||
buildProcess.AdjustPriority(false);
|
||||
|
||||
using (cancellationToken.Register(() => buildProcess.Terminate()))
|
||||
buildExitCode = await buildProcess.Lifetime;
|
||||
|
||||
string? output;
|
||||
if (!GeneralConfiguration.OpenDreamSuppressInstallOutput)
|
||||
if (!GeneralConfiguration.CurrentValue.OpenDreamSuppressInstallOutput)
|
||||
{
|
||||
var buildOutputTask = buildProcess.GetCombinedOutput(cancellationToken);
|
||||
if (!buildOutputTask.IsCompleted)
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// <summary>
|
||||
/// The <see cref="SessionConfiguration"/> for the <see cref="WindowsByondInstaller"/>.
|
||||
/// </summary>
|
||||
readonly SessionConfiguration sessionConfiguration;
|
||||
readonly IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SemaphoreSlim"/> for the <see cref="WindowsByondInstaller"/>.
|
||||
@@ -96,7 +96,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// </summary>
|
||||
/// <param name="processExecutor">The value of <see cref="processExecutor"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptionsMonitor{TOptions}"/> containing the <see cref="GeneralConfiguration"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="sessionConfiguration"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The <see cref="IOptionsMonitor{TOptions}"/> containing the value of <see cref="sessionConfigurationOptions"/>.</param>
|
||||
/// <param name="ioManager">The <see cref="IIOManager"/> for the <see cref="ByondInstallerBase"/>.</param>
|
||||
/// <param name="fileDownloader">The <see cref="IFileDownloader"/> for the <see cref="ByondInstallerBase"/>.</param>
|
||||
/// <param name="logger">The <see cref="ILogger"/> for the <see cref="ByondInstallerBase"/>.</param>
|
||||
@@ -105,12 +105,12 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
IIOManager ioManager,
|
||||
IFileDownloader fileDownloader,
|
||||
IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptions<SessionConfiguration> sessionConfigurationOptions,
|
||||
IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions,
|
||||
ILogger<WindowsByondInstaller> logger)
|
||||
: base(ioManager, logger, fileDownloader, generalConfigurationOptions)
|
||||
{
|
||||
this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
|
||||
sessionConfiguration = sessionConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
this.sessionConfigurationOptions = sessionConfigurationOptions ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions));
|
||||
|
||||
var useServiceSpecialTactics = Environment.Is64BitProcess && Environment.UserName == $"{Environment.MachineName}$";
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// <inheritdoc />
|
||||
protected override string GetDreamDaemonName(Version byondVersion, out bool supportsCli)
|
||||
{
|
||||
supportsCli = byondVersion >= DDExeVersion && !sessionConfiguration.ForceUseDreamDaemonExe;
|
||||
supportsCli = byondVersion >= DDExeVersion && !sessionConfigurationOptions.CurrentValue.ForceUseDreamDaemonExe;
|
||||
return supportsCli ? "dd.exe" : "dreamdaemon.exe";
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
Logger,
|
||||
ruleName,
|
||||
dreamDaemonPath,
|
||||
deploymentPipelineProcesses && sessionConfiguration.LowPriorityDeploymentProcesses,
|
||||
deploymentPipelineProcesses && sessionConfigurationOptions.CurrentValue.LowPriorityDeploymentProcesses,
|
||||
cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// <param name="repositoryManager">The <see cref="IRepositoryManager"/> for the <see cref="OpenDreamInstaller"/>.</param>
|
||||
/// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="OpenDreamInstaller"/>.</param>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/> for the <see cref="OpenDreamInstaller"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> of <see cref="GeneralConfiguration"/> for the <see cref="OpenDreamInstaller"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The <see cref="IOptions{TOptions}"/> of <see cref="SessionConfiguration"/> for the <see cref="OpenDreamInstaller"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptionsMonitor{TOptions}"/> of <see cref="GeneralConfiguration"/> for the <see cref="OpenDreamInstaller"/>.</param>
|
||||
/// <param name="sessionConfigurationOptions">The <see cref="IOptionsMonitor{TOptions}"/> of <see cref="SessionConfiguration"/> for the <see cref="OpenDreamInstaller"/>.</param>
|
||||
/// <param name="linkFactory">The value of <see cref="linkFactory"/>.</param>
|
||||
public WindowsOpenDreamInstaller(
|
||||
IIOManager ioManager,
|
||||
@@ -48,8 +48,8 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
IRepositoryManager repositoryManager,
|
||||
IAsyncDelayer asyncDelayer,
|
||||
IHttpClientFactory httpClientFactory,
|
||||
IOptions<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptions<SessionConfiguration> sessionConfigurationOptions,
|
||||
IOptionsMonitor<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptionsMonitor<SessionConfiguration> sessionConfigurationOptions,
|
||||
IFilesystemLinkFactory linkFactory)
|
||||
: base(
|
||||
ioManager,
|
||||
@@ -108,7 +108,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
/// <returns>A <see cref="ValueTask"/> representing the running operation.</returns>
|
||||
async ValueTask AddServerFirewallException(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
|
||||
{
|
||||
if (GeneralConfiguration.SkipAddingByondFirewallException)
|
||||
if (GeneralConfiguration.CurrentValue.SkipAddingByondFirewallException)
|
||||
return;
|
||||
|
||||
GetExecutablePaths(path, out var serverExePath, out _);
|
||||
@@ -126,7 +126,7 @@ namespace Tgstation.Server.Host.Components.Engine
|
||||
Logger,
|
||||
ruleName,
|
||||
serverExePath,
|
||||
deploymentPipelineProcesses && SessionConfiguration.LowPriorityDeploymentProcesses,
|
||||
deploymentPipelineProcesses && SessionConfiguration.CurrentValue.LowPriorityDeploymentProcesses,
|
||||
cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Moq;
|
||||
@@ -64,9 +65,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new DiscordProvider(mockJobManager, mockDel, mockLogger, null, null, null));
|
||||
var mockAss = Mock.Of<IAssemblyInformationProvider>();
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new DiscordProvider(mockJobManager, mockDel, mockLogger, mockAss, null, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new DiscordProvider(mockJobManager, mockDel, mockLogger, mockAss, bot, null));
|
||||
var mockGen = new GeneralConfiguration();
|
||||
await new DiscordProvider(mockJobManager, mockDel, mockLogger, mockAss, bot, mockGen).DisposeAsync();
|
||||
var mockGen = Mock.Of<IOptionsMonitor<GeneralConfiguration>>();
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new DiscordProvider(mockJobManager, mockDel, mockLogger, mockAss, mockGen, null));
|
||||
await new DiscordProvider(mockJobManager, mockDel, mockLogger, mockAss, mockGen, bot).DisposeAsync();
|
||||
}
|
||||
|
||||
static ValueTask InvokeConnect(IProvider provider, CancellationToken cancellationToken = default) => (ValueTask)provider.GetType().GetMethod("Connect", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(provider, new object[] { cancellationToken });
|
||||
@@ -75,12 +76,12 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests
|
||||
public async Task TestConnectWithFakeTokenFails()
|
||||
{
|
||||
var mockLogger = new Mock<ILogger<DiscordProvider>>();
|
||||
await using var provider = new DiscordProvider(mockJobManager, Mock.Of<IAsyncDelayer>(), mockLogger.Object, Mock.Of<IAssemblyInformationProvider>(), new ChatBot
|
||||
await using var provider = new DiscordProvider(mockJobManager, Mock.Of<IAsyncDelayer>(), mockLogger.Object, Mock.Of<IAssemblyInformationProvider>(), Mock.Of<IOptionsMonitor<GeneralConfiguration>>(), new ChatBot
|
||||
{
|
||||
ReconnectionInterval = 1,
|
||||
ConnectionString = "asdf",
|
||||
Instance = new Models.Instance(),
|
||||
}, new GeneralConfiguration());
|
||||
});
|
||||
await Assert.ThrowsExactlyAsync<JobException>(async () => await InvokeConnect(provider));
|
||||
Assert.IsFalse(provider.Connected);
|
||||
}
|
||||
@@ -95,7 +96,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests
|
||||
Assert.Fail("TGS_TEST_DISCORD_TOKEN is not a valid Discord connection string!");
|
||||
|
||||
var mockLogger = new Mock<ILogger<DiscordProvider>>();
|
||||
await using var provider = new DiscordProvider(mockJobManager, Mock.Of<IAsyncDelayer>(), mockLogger.Object, Mock.Of<IAssemblyInformationProvider>(), testToken1, new GeneralConfiguration());
|
||||
await using var provider = new DiscordProvider(mockJobManager, Mock.Of<IAsyncDelayer>(), mockLogger.Object, Mock.Of<IAssemblyInformationProvider>(), Mock.Of<IOptionsMonitor<GeneralConfiguration>>(), testToken1);
|
||||
Assert.IsFalse(provider.Connected);
|
||||
await InvokeConnect(provider);
|
||||
Assert.IsTrue(provider.Connected);
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Moq;
|
||||
@@ -30,8 +31,6 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new IrcProvider(mockJobManager.Object, mockAsyncDelayer.Object, null, null, null, null));
|
||||
var mockLogger = new Mock<ILogger<IrcProvider>>();
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new IrcProvider(mockJobManager.Object, mockAsyncDelayer.Object, mockLogger.Object, null, null, null));
|
||||
var mockAss = new Mock<IAssemblyInformationProvider>();
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new IrcProvider(mockJobManager.Object, mockAsyncDelayer.Object, mockLogger.Object, mockAss.Object, null, null));
|
||||
|
||||
var mockBot = new ChatBot
|
||||
{
|
||||
@@ -39,10 +38,14 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests
|
||||
Instance = new Models.Instance(),
|
||||
Provider = ChatProvider.Irc
|
||||
};
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new IrcProvider(mockJobManager.Object, mockAsyncDelayer.Object, mockLogger.Object, mockAss.Object, mockBot, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new IrcProvider(mockJobManager.Object, mockAsyncDelayer.Object, mockLogger.Object, mockBot, null, null));
|
||||
|
||||
var mockLogConf = new FileLoggingConfiguration();
|
||||
Assert.ThrowsExactly<InvalidOperationException>(() => new IrcProvider(mockJobManager.Object, mockAsyncDelayer.Object, mockLogger.Object, mockAss.Object, mockBot, mockLogConf));
|
||||
var mockAss = new Mock<IAssemblyInformationProvider>();
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new IrcProvider(mockJobManager.Object, mockAsyncDelayer.Object, mockLogger.Object, mockBot, mockAss.Object, null));
|
||||
|
||||
var mockLogConf = new Mock<IOptionsMonitor<FileLoggingConfiguration>>();
|
||||
mockLogConf.SetupGet(x => x.CurrentValue).Returns(new FileLoggingConfiguration());
|
||||
Assert.ThrowsExactly<InvalidOperationException>(() => new IrcProvider(mockJobManager.Object, mockAsyncDelayer.Object, mockLogger.Object, mockBot, mockAss.Object, mockLogConf.Object));
|
||||
|
||||
mockBot.ConnectionString = new IrcConnectionStringBuilder
|
||||
{
|
||||
@@ -52,7 +55,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests
|
||||
Port = 6667
|
||||
}.ToString();
|
||||
|
||||
await new IrcProvider(mockJobManager.Object, mockAsyncDelayer.Object, mockLogger.Object, mockAss.Object, mockBot, mockLogConf).DisposeAsync();
|
||||
await new IrcProvider(mockJobManager.Object, mockAsyncDelayer.Object, mockLogger.Object, mockBot, mockAss.Object, mockLogConf.Object).DisposeAsync();
|
||||
}
|
||||
|
||||
static ValueTask InvokeConnect(IProvider provider, CancellationToken cancellationToken = default) => (ValueTask)provider.GetType().GetMethod("Connect", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(provider, new object[] { cancellationToken });
|
||||
@@ -89,7 +92,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests
|
||||
Instance = new Models.Instance(),
|
||||
};
|
||||
|
||||
await using var provider = new IrcProvider(mockJobManager, new AsyncDelayer(loggerFactory.CreateLogger<AsyncDelayer>()), loggerFactory.CreateLogger<IrcProvider>(), Mock.Of<IAssemblyInformationProvider>(), chatBot, new FileLoggingConfiguration());
|
||||
var mockLogConf = new Mock<IOptionsMonitor<FileLoggingConfiguration>>();
|
||||
mockLogConf.SetupGet(x => x.CurrentValue).Returns(new FileLoggingConfiguration());
|
||||
await using var provider = new IrcProvider(mockJobManager, new AsyncDelayer(loggerFactory.CreateLogger<AsyncDelayer>()), loggerFactory.CreateLogger<IrcProvider>(), chatBot, Mock.Of<IAssemblyInformationProvider>(), mockLogConf.Object);
|
||||
Assert.IsFalse(provider.Connected);
|
||||
await InvokeConnect(provider);
|
||||
Assert.IsTrue(provider.Connected);
|
||||
|
||||
@@ -35,13 +35,13 @@ namespace Tgstation.Server.Host.Components.Engine.Tests
|
||||
|
||||
static async Task RepoDownloadTest(bool needsClone)
|
||||
{
|
||||
var mockGeneralConfigOptions = new Mock<IOptions<GeneralConfiguration>>();
|
||||
var mockGeneralConfigOptions = new Mock<IOptionsMonitor<GeneralConfiguration>>();
|
||||
var generalConfig = new GeneralConfiguration();
|
||||
var mockSessionConfigOptions = new Mock<IOptions<SessionConfiguration>>();
|
||||
var mockSessionConfigOptions = new Mock<IOptionsMonitor<SessionConfiguration>>();
|
||||
var sessionConfig = new SessionConfiguration();
|
||||
Assert.IsNotNull(generalConfig.OpenDreamGitUrl);
|
||||
mockGeneralConfigOptions.SetupGet(x => x.Value).Returns(generalConfig);
|
||||
mockSessionConfigOptions.SetupGet(x => x.Value).Returns(sessionConfig);
|
||||
mockGeneralConfigOptions.SetupGet(x => x.CurrentValue).Returns(generalConfig);
|
||||
mockSessionConfigOptions.SetupGet(x => x.CurrentValue).Returns(sessionConfig);
|
||||
|
||||
var cloneAttempts = 0;
|
||||
var mockRepository = new Mock<IRepository>();
|
||||
|
||||
@@ -270,8 +270,8 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
{
|
||||
ByondZipDownloadTemplate = TestingUtils.ByondZipDownloadTemplate,
|
||||
});
|
||||
var sessionConfigOptionsMock = new Mock<IOptions<SessionConfiguration>>();
|
||||
sessionConfigOptionsMock.SetupGet(x => x.Value).Returns(new SessionConfiguration());
|
||||
var sessionConfigOptionsMock = new Mock<IOptionsMonitor<SessionConfiguration>>();
|
||||
sessionConfigOptionsMock.SetupGet(x => x.CurrentValue).Returns(new SessionConfiguration());
|
||||
|
||||
var assemblyInformationProvider = new AssemblyInformationProvider();
|
||||
|
||||
|
||||
@@ -127,15 +127,15 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
genConfig),
|
||||
Mock.Of<IAsyncDelayer>(),
|
||||
Mock.Of<IHttpClientFactory>(),
|
||||
Options.Create(genConfig),
|
||||
Options.Create(new SessionConfiguration()))
|
||||
mockOptionsMonitor.Object,
|
||||
Mock.Of<IOptionsMonitor<SessionConfiguration>>())
|
||||
: new PlatformIdentifier().IsWindows
|
||||
? new WindowsByondInstaller(
|
||||
Mock.Of<IProcessExecutor>(),
|
||||
Mock.Of<IIOManager>(),
|
||||
fileDownloader,
|
||||
mockOptionsMonitor.Object,
|
||||
Options.Create(new SessionConfiguration()),
|
||||
Mock.Of<IOptionsMonitor<SessionConfiguration>>(),
|
||||
Mock.Of<ILogger<WindowsByondInstaller>>())
|
||||
: new PosixByondInstaller(
|
||||
Mock.Of<IPostWriteHandler>(),
|
||||
|
||||
@@ -112,8 +112,8 @@ namespace Tgstation.Server.Tests
|
||||
{
|
||||
ByondZipDownloadTemplate = TestingUtils.ByondZipDownloadTemplate,
|
||||
});
|
||||
var mockSessionConfigurationOptions = new Mock<IOptions<SessionConfiguration>>();
|
||||
mockSessionConfigurationOptions.SetupGet(x => x.Value).Returns(new SessionConfiguration());
|
||||
var mockSessionConfigurationOptions = new Mock<IOptionsMonitor<SessionConfiguration>>();
|
||||
mockSessionConfigurationOptions.SetupGet(x => x.CurrentValue).Returns(new SessionConfiguration());
|
||||
|
||||
using var loggerFactory = LoggerFactory.Create(builder =>
|
||||
{
|
||||
@@ -179,8 +179,8 @@ namespace Tgstation.Server.Tests
|
||||
SkipAddingByondFirewallException = true,
|
||||
ByondZipDownloadTemplate = TestingUtils.ByondZipDownloadTemplate,
|
||||
});
|
||||
var mockSessionConfigurationOptions = new Mock<IOptions<SessionConfiguration>>();
|
||||
mockSessionConfigurationOptions.SetupGet(x => x.Value).Returns(new SessionConfiguration());
|
||||
var mockSessionConfigurationOptions = new Mock<IOptionsMonitor<SessionConfiguration>>();
|
||||
mockSessionConfigurationOptions.SetupGet(x => x.CurrentValue).Returns(new SessionConfiguration());
|
||||
|
||||
using var loggerFactory = LoggerFactory.Create(builder =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user