cs-codex-dist-tests/Tools/CodexNetDeployer/Program.cs

51 lines
1.8 KiB
C#
Raw Normal View History

2023-06-26 11:58:41 +00:00
using ArgsUniform;
using CodexNetDeployer;
using Newtonsoft.Json;
2023-06-22 08:17:12 +00:00
using Configuration = CodexNetDeployer.Configuration;
2023-06-22 07:51:25 +00:00
public class Program
2023-06-22 06:29:33 +00:00
{
public static void Main(string[] args)
{
2023-06-22 07:51:25 +00:00
var nl = Environment.NewLine;
2023-06-26 11:58:41 +00:00
Console.WriteLine("CodexNetDeployer" + nl);
2023-06-22 07:51:25 +00:00
var uniformArgs = new ArgsUniform<Configuration>(PrintHelp, args);
2023-06-26 11:58:41 +00:00
var config = uniformArgs.Parse(true);
2023-06-22 07:51:25 +00:00
var errors = config.Validate();
if (errors.Any())
{
Console.WriteLine($"Configuration errors: ({errors.Count})");
foreach ( var error in errors ) Console.WriteLine("\t" + error);
Console.WriteLine(nl);
2023-06-26 11:58:41 +00:00
PrintHelp();
2023-06-22 07:51:25 +00:00
return;
}
var deployer = new Deployer(config);
deployer.AnnouncePlugins();
2023-07-11 08:05:00 +00:00
if (!args.Any(a => a == "-y"))
{
Console.WriteLine("Does the above config look good? [y/n]");
if (Console.ReadLine()!.ToLowerInvariant() != "y") return;
Console.WriteLine("I think so too.");
}
var deployment = deployer.Deploy();
2023-10-05 06:55:13 +00:00
Console.WriteLine($"Writing deployment file '{config.DeployFile}'...");
File.WriteAllText(config.DeployFile, JsonConvert.SerializeObject(deployment, Formatting.Indented));
Console.WriteLine("Done!");
2023-06-22 06:29:33 +00:00
}
2023-06-26 11:58:41 +00:00
private static void PrintHelp()
{
var nl = Environment.NewLine;
2023-09-29 08:19:59 +00:00
Console.WriteLine("CodexNetDeployer allows you to deploy multiple Codex nodes in a Kubernetes cluster. " +
2023-06-26 11:58:41 +00:00
"The deployer will set up the required supporting services, deploy the Codex on-chain contracts, start and bootstrap the Codex instances. " +
"All Kubernetes objects will be created in the namespace provided, allowing you to easily find, modify, and delete them afterwards." + nl);
}
2023-06-22 06:29:33 +00:00
}