public static void Deploy(string commandLine) { try { var newArgs = DeploymentCommandLineParser.Parse(commandLine); _log.DebugFormat("Deployment: '{0}'", newArgs.Deployment); //what is the better way to state this? DeploymentFinder finder = newArgs.Deployment == "SEARCH" ? new SearchesForAnAssemblyEndingInDeployment() : newArgs.Deployment.EndsWith(".dll") || newArgs.Deployment.EndsWith(".exe") ? new AssemblyWasSpecifiedAssumingOnlyOneDeploymentClass() : (DeploymentFinder) new TypeWasSpecifiedAssumingItHasADefaultConstructor(); var deployment = finder.Find(newArgs.Deployment); DeploymentPlanDispatcher.KickItOutThereAlready(deployment, newArgs); } catch (Exception ex) { _log.Debug(commandLine); _log.Error(ex); } }
public static void Deploy(string commandLine) { if (!_coarseLog.IsDebugEnabled) { Console.WriteLine("Sad Emo Otter says \"DEBUG LOGGING IS OFF - THIS ISN'T GOING TO BE FUN :(\""); } try { _coarseLog.Info("****************************************************"); _coarseLog.Info("DropkicK"); _coarseLog.Info("****************************************************"); _coarseLog.Info(""); DeploymentArguments newArgs = DeploymentCommandLineParser.Parse(commandLine); _coarseLog.Info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); _coarseLog.InfoFormat("Command: {0}", newArgs.Command); _coarseLog.InfoFormat("Environment: {0}", newArgs.Environment); _coarseLog.InfoFormat("Role: {0}", newArgs.Role); //////// DEPLOYMENT STUFF FindResult findResult = _finder.Find(newArgs.Deployment); Deployment deployment = findResult.Deployment; _coarseLog.InfoFormat("Deployment Method: '{0}'", findResult.MethodOfFinding); _coarseLog.InfoFormat("Deployment Found: '{0}'", findResult.Deployment.GetType().Name); if (deployment.GetType().Equals(typeof(NullDeployment))) { _coarseLog.Fatal("Couldn't find a deployment to run."); return; } //////// ////////// File Checks if (!VerifyPathToServerMapsFile(newArgs.PathToServerMapsFile)) { return; } if (!VerifyPathToSettingsFile(newArgs.PathToSettingsFile)) { return; } //////////////////// RoleToServerMap maps = _serverParser.Parse(new FileInfo(newArgs.PathToServerMapsFile)); newArgs.ServerMappings.Merge(maps); DisplayServerMappingsForEnvironment(newArgs.ServerMappings); _coarseLog.Info(""); _coarseLog.Info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); _coarseLog.Info("Please review the settings above when you are ready,"); _coarseLog.Info(" Press 'ctrl+c' to cancel."); if (deployment.HardPrompt) { bool wrong = true; do { _coarseLog.Info(" Please type the environment name '{0}' to continue.".FormatWith(newArgs.Environment)); var environment = Console.ReadLine(); if (environment.EqualsIgnoreCase(newArgs.Environment)) { wrong = false; } } while (wrong); } else { _coarseLog.Info(" Press enter to kick it out there"); Console.ReadKey(true); } /////// how to clean this up - below Type settingsType = deployment.GetType().BaseType.GetGenericArguments()[1]; var settings = (DropkickConfiguration)_parser.Parse(settingsType, new FileInfo(newArgs.PathToSettingsFile), commandLine, newArgs.Environment); settings.Environment = newArgs.Environment; deployment.Initialize(settings); DeploymentPlanDispatcher.KickItOutThereAlready(deployment, newArgs); } catch (Exception ex) { _coarseLog.Debug(commandLine); _coarseLog.Error(ex); } }