Skip to content

Commit aa0396e

Browse files
authored
Use plugin bat when installing on Windows (#23)
This commit updates the InstallPlugins task to use the plugin batch file as the binary when installing plugins. Previously, plugin installation used cmd as the binary, delegating to the batch file as an argument. This can cause issues where a plugin writes warnings to stderr, such as ingest-attachmeent, which triggers the InstallPlugins task to throw an exception. Remove IsMono property and replace with IsWindows property, using RuntimeInformation. Ultimately, this property is used to determine the platform running on, specifically whether Windows or not.
1 parent 24e6583 commit aa0396e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/Elastic.Managed.Ephemeral/Tasks/IClusterComposeTask.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public abstract class ClusterComposeTask : IClusterComposeTask
3939
{
4040
public abstract void Run(IEphemeralCluster<EphemeralClusterConfiguration> cluster);
4141

42-
protected static bool IsMono { get; } = Type.GetType("Mono.Runtime") != null;
43-
protected static string BinarySuffix => IsMono || Path.DirectorySeparatorChar == '/' ? "" : ".bat";
42+
protected static bool IsWindows { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
43+
protected static string BinarySuffix => IsWindows ? ".bat" : string.Empty;
4444

4545
protected static void DownloadFile(string from, string to)
4646
{

src/Elastic.Managed.Ephemeral/Tasks/InstallationTasks/InstallPlugins.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ public override void Run(IEphemeralCluster<EphemeralClusterConfiguration> cluste
7171
cluster.Writer?.WriteDiagnostic($"{{{nameof(Run)}}} attempting install [{plugin.SubProductName}] as it's not OOTB: {{{plugin.ShippedByDefaultAsOf}}} and valid for {v}: {{{plugin.IsValid(v)}}}");
7272
//var installParameter = v.ReleaseState == ReleaseState.Released ? plugin.Moniker : UseHttpPluginLocation(cluster.Writer, fs, plugin, v);
7373
var installParameter = UseHttpPluginLocation(cluster.Writer, fs, plugin, v);
74-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
75-
ExecuteBinary(cluster.ClusterConfiguration, cluster.Writer, "cmd", $"install elasticsearch plugin: {plugin.SubProductName}", $"/c CALL {fs.PluginBinary} install --batch", installParameter);
76-
else
77-
{
78-
if (!Directory.Exists(fs.ConfigPath)) Directory.CreateDirectory(fs.ConfigPath);
79-
ExecuteBinary(cluster.ClusterConfiguration, cluster.Writer, fs.PluginBinary, $"install elasticsearch plugin: {plugin.SubProductName}", "install --batch", installParameter);
80-
}
81-
74+
if (!Directory.Exists(fs.ConfigPath)) Directory.CreateDirectory(fs.ConfigPath);
75+
ExecuteBinary(
76+
cluster.ClusterConfiguration,
77+
cluster.Writer,
78+
fs.PluginBinary + BinarySuffix,
79+
$"install elasticsearch plugin: {plugin.SubProductName}",
80+
"install --batch", installParameter);
81+
8282
CopyConfigDirectoryToHomeCacheConfigDirectory(cluster, plugin);
8383
}
8484

src/Elastic.Managed.Ephemeral/Tasks/InstallationTasks/XPack/PathXPackInBatFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public override void Run(IEphemeralCluster<EphemeralClusterConfiguration> cluste
1717
var v = config.Version;
1818

1919
if (v.Major != 5) return;
20-
if (IsMono || Path.DirectorySeparatorChar == '/') return;
20+
if (!IsWindows) return;
2121

2222
cluster.Writer?.WriteDiagnostic($"{{{nameof(PathXPackInBatFile)}}} patching x-pack .in.bat to accept CONF_DIR");
2323
PatchPlugin(v, fileSystem);

0 commit comments

Comments
 (0)