mirror of
https://github.com/aljazceru/btcpayserver-docker.git
synced 2025-12-17 08:34:21 +01:00
Show proper error message if using incompatible options
This commit is contained in:
@@ -54,6 +54,7 @@ namespace DockerGenerator
|
||||
var volumes = new List<KeyValuePair<YamlNode, YamlNode>>();
|
||||
var networks = new List<KeyValuePair<YamlNode, YamlNode>>();
|
||||
var exclusives = new List<(FragmentName FragmentName, string Exclusivity)>();
|
||||
var incompatibles = new List<(FragmentName FragmentName, string Exclusivity)>();
|
||||
|
||||
foreach (var fragment in Fragments.Where(NotExcluded))
|
||||
{
|
||||
@@ -92,6 +93,13 @@ namespace DockerGenerator
|
||||
exclusives.Add((fragment, node.ToString()));
|
||||
}
|
||||
}
|
||||
if (doc.Children.ContainsKey("incompatible") && doc.Children["incompatible"] is YamlSequenceNode fragmentIncompatibleRoot)
|
||||
{
|
||||
foreach (var node in fragmentIncompatibleRoot)
|
||||
{
|
||||
incompatibles.Add((fragment, node.ToString()));
|
||||
}
|
||||
}
|
||||
if (doc.Children.ContainsKey("required") && doc.Children["required"] is YamlSequenceNode fragmentRequireRoot)
|
||||
{
|
||||
foreach (var node in fragmentRequireRoot)
|
||||
@@ -126,6 +134,14 @@ namespace DockerGenerator
|
||||
if (exclusiveConflict != null)
|
||||
throw new YamlBuildException($"The fragments {String.Join(", ", exclusiveConflict.Select(e => e.FragmentName))} can't be used simultaneously (group '{exclusiveConflict.Key}')");
|
||||
|
||||
var groups = exclusives.ToDictionary(e => e.Exclusivity, e => e.FragmentName);
|
||||
var incompatible = incompatibles
|
||||
.Select(i => groups.TryGetValue(i.Exclusivity, out _) ? (i.FragmentName, i.Exclusivity) : (null, null))
|
||||
.Where(i => i.Exclusivity != null)
|
||||
.FirstOrDefault();
|
||||
if (incompatible.Exclusivity != null)
|
||||
throw new YamlBuildException($"The fragment {incompatible.FragmentName} is incompatible with '{incompatible.Exclusivity}'");
|
||||
|
||||
Console.WriteLine($"Selected fragments:");
|
||||
foreach (var fragment in processedFragments)
|
||||
{
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
"BTCPAYGEN_CRYPTO2": "ltc",
|
||||
"BTCPAYGEN_CRYPTO1": "btc",
|
||||
"BTCPAYGEN_REVERSEPROXY": "nginx",
|
||||
"BTCPAYGEN_ADDITIONAL_FRAGMENTS": "opt-save-storage",
|
||||
"BTCPAYGEN_EXCLUDE_FRAGMENTS": "postgres"
|
||||
"BTCPAYGEN_ADDITIONAL_FRAGMENTS": "opt-save-storage;opt-txindex"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user