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

60 lines
2.2 KiB
C#
Raw Normal View History

2023-06-26 11:58:41 +00:00
using ArgsUniform;
using CodexNetDeployer;
2023-06-22 08:17:12 +00:00
using DistTestCore;
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-23 06:18:48 +00:00
if (args.Any(a => a == "--external"))
2023-06-22 08:17:12 +00:00
{
2023-06-26 11:58:41 +00:00
config.RunnerLocation = TestRunnerLocation.ExternalToCluster;
2023-06-22 08:17:12 +00:00
}
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-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.");
}
2023-06-22 08:17:12 +00:00
var deployer = new Deployer(config);
var deployment = deployer.Deploy();
Console.WriteLine("Writing codex-deployment.json...");
File.WriteAllText("codex-deployment.json", JsonConvert.SerializeObject(deployment, Formatting.Indented));
2023-06-22 07:51:25 +00:00
2023-06-22 08:17:12 +00:00
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;
Console.WriteLine("CodexNetDeployer allows you to easily deploy multiple Codex nodes in a Kubernetes cluster. " +
"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);
Console.WriteLine("CodexNetDeployer assumes you are running this tool from *inside* the Kubernetes cluster you want to deploy to. " +
"If you are not running this from a container inside the cluster, add the argument '--external'." + nl);
}
2023-06-22 06:29:33 +00:00
}