Program.cs
1 using ArgsUniform; 2 using CodexNetDeployer; 3 using Newtonsoft.Json; 4 using Configuration = CodexNetDeployer.Configuration; 5 6 public class Program 7 { 8 public static void Main(string[] args) 9 { 10 var nl = Environment.NewLine; 11 Console.WriteLine("CodexNetDeployer" + nl); 12 13 var uniformArgs = new ArgsUniform<Configuration>(PrintHelp, args); 14 var config = uniformArgs.Parse(true); 15 16 var errors = config.Validate(); 17 if (errors.Any()) 18 { 19 Console.WriteLine($"Configuration errors: ({errors.Count})"); 20 foreach ( var error in errors ) Console.WriteLine("\t" + error); 21 Console.WriteLine(nl); 22 PrintHelp(); 23 return; 24 } 25 26 var deployer = new Deployer(config); 27 deployer.AnnouncePlugins(); 28 29 if (config.IsPublicTestNet || !args.Any(a => a == "-y")) 30 { 31 if (config.IsPublicTestNet) Console.WriteLine("Deployment is configured as public testnet."); 32 Console.WriteLine("Does the above config look good? [y/n]"); 33 if (Console.ReadLine()!.ToLowerInvariant() != "y") return; 34 if (config.IsPublicTestNet) Console.WriteLine("You better be right about that, cause it's going live right now."); 35 else Console.WriteLine("I think so too."); 36 } 37 38 var deployment = deployer.Deploy(); 39 40 Console.WriteLine($"Writing deployment file '{config.DeployFile}'..."); 41 File.WriteAllText(config.DeployFile, JsonConvert.SerializeObject(deployment, Formatting.Indented)); 42 Console.WriteLine("Done!"); 43 } 44 45 private static void PrintHelp() 46 { 47 var nl = Environment.NewLine; 48 Console.WriteLine("CodexNetDeployer allows you to deploy multiple Codex nodes in a Kubernetes cluster. " + 49 "The deployer will set up the required supporting services, deploy the Codex on-chain contracts, start and bootstrap the Codex instances. " + 50 "All Kubernetes objects will be created in the namespace provided, allowing you to easily find, modify, and delete them afterwards." + nl); 51 } 52 }