2023-06-26 11:58:41 +00:00
|
|
|
|
using ArgsUniform;
|
|
|
|
|
using CodexNetDeployer;
|
2023-06-23 06:44:27 +00:00
|
|
|
|
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
|
|
|
|
|
2023-06-30 07:09:59 +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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-08 05:29:55 +00:00
|
|
|
|
var deployer = new Deployer(config);
|
|
|
|
|
deployer.AnnouncePlugins();
|
|
|
|
|
|
2023-10-23 10:52:47 +00:00
|
|
|
|
if (config.IsPublicTestNet || !args.Any(a => a == "-y"))
|
2023-07-11 08:05:00 +00:00
|
|
|
|
{
|
2023-10-23 10:52:47 +00:00
|
|
|
|
if (config.IsPublicTestNet) Console.WriteLine("Deployment is configured as public testnet.");
|
2023-07-11 08:05:00 +00:00
|
|
|
|
Console.WriteLine("Does the above config look good? [y/n]");
|
|
|
|
|
if (Console.ReadLine()!.ToLowerInvariant() != "y") return;
|
2023-10-25 07:54:08 +00:00
|
|
|
|
if (config.IsPublicTestNet) Console.WriteLine("You better be right about that, cause it's going live right now.");
|
|
|
|
|
else Console.WriteLine("I think so too.");
|
2023-07-11 08:05:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-08 05:29:55 +00:00
|
|
|
|
var deployment = deployer.Deploy();
|
2023-10-05 06:55:13 +00:00
|
|
|
|
|
2023-10-08 05:29:55 +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
|
|
|
|
}
|