feat: Initialize Zastava Webhook service with TLS and Authority authentication
- Added Program.cs to set up the web application with Serilog for logging, health check endpoints, and a placeholder admission endpoint. - Configured Kestrel server to use TLS 1.3 and handle client certificates appropriately. - Created StellaOps.Zastava.Webhook.csproj with necessary dependencies including Serilog and Polly. - Documented tasks in TASKS.md for the Zastava Webhook project, outlining current work and exit criteria for each task.
This commit is contained in:
86
Mongo2Go-4.1.0/src/MongoDownloader/Program.cs
Normal file
86
Mongo2Go-4.1.0/src/MongoDownloader/Program.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace MongoDownloader
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static async Task<int> Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var toolsDirectory = GetToolsDirectory();
|
||||
|
||||
foreach (DirectoryInfo dir in toolsDirectory.EnumerateDirectories())
|
||||
{
|
||||
dir.Delete(true);
|
||||
}
|
||||
|
||||
var cancellationTokenSource = new CancellationTokenSource();
|
||||
Console.CancelKeyPress += (_, eventArgs) =>
|
||||
{
|
||||
// Try to cancel gracefully the first time, then abort the process the second time Ctrl+C is pressed
|
||||
eventArgs.Cancel = !cancellationTokenSource.IsCancellationRequested;
|
||||
cancellationTokenSource.Cancel();
|
||||
};
|
||||
var options = new Options();
|
||||
var performStrip = args.All(e => e != "--no-strip");
|
||||
var binaryStripper = performStrip ? await GetBinaryStripperAsync(cancellationTokenSource.Token) : null;
|
||||
var archiveExtractor = new ArchiveExtractor(options, binaryStripper);
|
||||
var downloader = new MongoDbDownloader(archiveExtractor, options);
|
||||
var strippedSize = await downloader.RunAsync(toolsDirectory, cancellationTokenSource.Token);
|
||||
if (performStrip)
|
||||
{
|
||||
AnsiConsole.WriteLine($"Saved {strippedSize:#.#} by stripping executables");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (exception is not OperationCanceledException)
|
||||
{
|
||||
AnsiConsole.WriteException(exception, ExceptionFormats.ShortenPaths);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static DirectoryInfo GetToolsDirectory()
|
||||
{
|
||||
for (var directory = new DirectoryInfo("."); directory != null; directory = directory.Parent)
|
||||
{
|
||||
var toolsDirectory = directory.GetDirectories("tools", SearchOption.TopDirectoryOnly).SingleOrDefault();
|
||||
if (toolsDirectory?.Exists ?? false)
|
||||
{
|
||||
return toolsDirectory;
|
||||
}
|
||||
}
|
||||
throw new InvalidOperationException("The tools directory was not found");
|
||||
}
|
||||
|
||||
private static async Task<BinaryStripper?> GetBinaryStripperAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await BinaryStripper.CreateAsync(cancellationToken);
|
||||
}
|
||||
catch (FileNotFoundException exception)
|
||||
{
|
||||
string installCommand;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
installCommand = "brew install llvm";
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
installCommand = "scoop install llvm";
|
||||
else
|
||||
installCommand = "apt-get install llvm";
|
||||
|
||||
throw new Exception($"{exception.Message} Either install llvm with `{installCommand}` or run MongoDownloader with the --no-strip option to skip binary stripping.", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user