mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-22 04:27:19 +01:00
Elasticsearch configuration now uses a Uri
Also fixed default setup wizard option not working Fixes #1599
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@
|
||||
<Import Project="ControlPanelVersion.props" />
|
||||
<PropertyGroup>
|
||||
<TgsCoreVersion>5.13.1</TgsCoreVersion>
|
||||
<TgsConfigVersion>4.7.0</TgsConfigVersion>
|
||||
<TgsConfigVersion>4.7.1</TgsConfigVersion>
|
||||
<TgsApiVersion>9.11.0</TgsApiVersion>
|
||||
<TgsCommonLibraryVersion>6.0.0</TgsCommonLibraryVersion>
|
||||
<TgsApiLibraryVersion>11.0.0</TgsApiLibraryVersion>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Tgstation.Server.Host.Configuration
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Host.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration options pertaining to elasticsearch log storage.
|
||||
@@ -18,7 +20,7 @@
|
||||
/// <summary>
|
||||
/// The host of the elasticsearch endpoint.
|
||||
/// </summary>
|
||||
public string Host { get; set; }
|
||||
public Uri Host { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Username for elasticsearch.
|
||||
|
||||
@@ -196,11 +196,7 @@ namespace Tgstation.Server.Host.Core
|
||||
rollOnFileSizeLimit: true);
|
||||
},
|
||||
elasticsearchConfiguration.Enable
|
||||
? new ElasticsearchSinkOptions(
|
||||
new Uri(
|
||||
String.IsNullOrWhiteSpace(elasticsearchConfiguration.Host)
|
||||
? throw new InvalidOperationException($"Missing {ElasticsearchConfiguration.Section}:{nameof(elasticsearchConfiguration.Host)}!")
|
||||
: elasticsearchConfiguration.Host))
|
||||
? new ElasticsearchSinkOptions(elasticsearchConfiguration.Host ?? throw new InvalidOperationException($"Missing {ElasticsearchConfiguration.Section}:{nameof(elasticsearchConfiguration.Host)}!"))
|
||||
{
|
||||
// Yes I know this means they cannot use a self signed cert unless they also have authentication, but lets be real here
|
||||
// No one is going to be doing one of those but not the other
|
||||
|
||||
@@ -790,11 +790,17 @@ namespace Tgstation.Server.Host.Setup
|
||||
do
|
||||
{
|
||||
await console.WriteAsync("ElasticSearch server endpoint (Include protocol and port, leave blank for http://127.0.0.1:9200): ", false, cancellationToken);
|
||||
elasticsearchConfiguration.Host = await console.ReadLineAsync(false, cancellationToken);
|
||||
if (!String.IsNullOrWhiteSpace(elasticsearchConfiguration.Host))
|
||||
var hostString = await console.ReadLineAsync(false, cancellationToken);
|
||||
if (String.IsNullOrWhiteSpace(hostString))
|
||||
hostString = "http://127.0.0.1:9200";
|
||||
|
||||
if (Uri.TryCreate(hostString, UriKind.Absolute, out var host))
|
||||
{
|
||||
elasticsearchConfiguration.Host = host;
|
||||
break;
|
||||
}
|
||||
|
||||
await console.WriteAsync("Invalid URI!", true, cancellationToken);
|
||||
}
|
||||
while (true);
|
||||
|
||||
@@ -803,9 +809,7 @@ namespace Tgstation.Server.Host.Setup
|
||||
await console.WriteAsync("Enter Elasticsearch username: ", false, cancellationToken);
|
||||
elasticsearchConfiguration.Username = await console.ReadLineAsync(false, cancellationToken);
|
||||
if (!String.IsNullOrWhiteSpace(elasticsearchConfiguration.Username))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
|
||||
@@ -814,9 +818,7 @@ namespace Tgstation.Server.Host.Setup
|
||||
await console.WriteAsync("Enter password: ", false, cancellationToken);
|
||||
elasticsearchConfiguration.Password = await console.ReadLineAsync(true, cancellationToken);
|
||||
if (!String.IsNullOrWhiteSpace(elasticsearchConfiguration.Username))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
}
|
||||
|
||||
@@ -200,7 +200,12 @@ namespace Tgstation.Server.Host.Setup.Tests
|
||||
//logging config
|
||||
"no",
|
||||
// elasticsearch config
|
||||
"n", // were not validating this travesty in CI
|
||||
"y",
|
||||
String.Empty,
|
||||
String.Empty,
|
||||
"user",
|
||||
String.Empty,
|
||||
"pass",
|
||||
//cp config
|
||||
"y",
|
||||
"y",
|
||||
@@ -267,7 +272,11 @@ namespace Tgstation.Server.Host.Setup.Tests
|
||||
"None",
|
||||
"Critical",
|
||||
// elasticsearch config
|
||||
"n", // were not validating this travesty in CI
|
||||
"y",
|
||||
"bad url",
|
||||
"http://localhost:929",
|
||||
"user",
|
||||
"pass",
|
||||
//cp config
|
||||
"y",
|
||||
"n",
|
||||
|
||||
Reference in New Issue
Block a user