public override int Execute(string[] commandLineArguments) { var packageFile = variables.GetPathToPrimaryPackage(fileSystem, true); if (packageFile == null) // required: true in the above call means it will throw rather than return null, but there's no way to tell the compiler that. And ! doesn't work in older frameworks { throw new CommandException("Package File path could not be determined"); } var journal = new DeploymentJournal(fileSystem, SemaphoreFactory.Get(), variables); var conventions = new List <IConvention> { new AlreadyInstalledConvention(log, journal), new TransferPackageConvention(log, fileSystem), }; var deployment = new RunningDeployment(packageFile, variables); var conventionRunner = new ConventionProcessor(deployment, conventions, log); try { conventionRunner.RunConventions(); deploymentJournalWriter.AddJournalEntry(deployment, true); } catch (Exception) { deploymentJournalWriter.AddJournalEntry(deployment, false); throw; } return(0); }
public override int Execute(string[] commandLineArguments) { var packageFile = variables.GetPathToPrimaryPackage(fileSystem, true); var journal = new DeploymentJournal(fileSystem, SemaphoreFactory.Get(), variables); var conventions = new List <IConvention> { new AlreadyInstalledConvention(log, journal), new TransferPackageConvention(log, fileSystem), }; var deployment = new RunningDeployment(packageFile, variables); var conventionRunner = new ConventionProcessor(deployment, conventions); try { conventionRunner.RunConventions(); deploymentJournalWriter.AddJournalEntry(deployment, true); } catch (Exception) { deploymentJournalWriter.AddJournalEntry(deployment, false); throw; } return(0); }
public override int Execute(string[] commandLineArguments) { Options.Parse(commandLineArguments); var fileSystem = CalamariPhysicalFileSystem.GetPhysicalFileSystem(); var variables = new CalamariVariableDictionary(variablesFile, sensitiveVariableFiles, sensitiveVariablesPassword); var packageFile = variables.GetEnvironmentExpandedPath(SpecialVariables.Tentacle.CurrentDeployment.PackageFilePath); if (string.IsNullOrEmpty(packageFile)) { throw new CommandException($"No package file was specified. Please provide `{SpecialVariables.Tentacle.CurrentDeployment.PackageFilePath}` variable"); } if (!fileSystem.FileExists(packageFile)) { throw new CommandException("Could not find package file: " + packageFile); } fileSystem.FreeDiskSpaceOverrideInMegaBytes = variables.GetInt32(SpecialVariables.FreeDiskSpaceOverrideInMegaBytes); fileSystem.SkipFreeDiskSpaceCheck = variables.GetFlag(SpecialVariables.SkipFreeDiskSpaceCheck); var journal = new DeploymentJournal(fileSystem, SemaphoreFactory.Get(), variables); var conventions = new List <IConvention> { new ContributeEnvironmentVariablesConvention(), new ContributePreviousInstallationConvention(journal), new ContributePreviousSuccessfulInstallationConvention(journal), new LogVariablesConvention(), new AlreadyInstalledConvention(journal), new TransferPackageConvention(fileSystem), }; var deployment = new RunningDeployment(packageFile, variables); var conventionRunner = new ConventionProcessor(deployment, conventions); try { conventionRunner.RunConventions(); deploymentJournalWriter.AddJournalEntry(deployment, true); } catch (Exception) { deploymentJournalWriter.AddJournalEntry(deployment, false); throw; } return(0); }
public override int Execute(string[] commandLineArguments) { Options.Parse(commandLineArguments); if (!File.Exists(packageFile)) { throw new CommandException("Could not find package file: " + packageFile); } if (variablesFile != null && !File.Exists(variablesFile)) { throw new CommandException("Could not find variables file: " + variablesFile); } var variables = new CalamariVariableDictionary(variablesFile, sensitiveVariableFiles, sensitiveVariablesPassword); var commandLineRunner = new CommandLineRunner(new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables))); var substituter = new FileSubstituter(fileSystem); var extractor = new GenericPackageExtractorFactory().createStandardGenericPackageExtractor(); ValidateRequiredVariables(variables); var conventions = new List <IConvention> { new ContributeEnvironmentVariablesConvention(), new LogVariablesConvention(), new ExtractPackageToStagingDirectoryConvention(extractor, fileSystem), new StageScriptPackagesConvention(null, fileSystem, extractor, true), new ConfiguredScriptConvention(DeploymentStages.PreDeploy, fileSystem, scriptEngine, commandLineRunner), new SubstituteInFilesConvention(fileSystem, substituter, _ => true, FileTargetFactory), new ConfiguredScriptConvention(DeploymentStages.Deploy, fileSystem, scriptEngine, commandLineRunner), new HelmUpgradeConvention(scriptEngine, commandLineRunner, fileSystem), new ConfiguredScriptConvention(DeploymentStages.PostDeploy, fileSystem, scriptEngine, commandLineRunner), }; var deployment = new RunningDeployment(packageFile, variables); var conventionRunner = new ConventionProcessor(deployment, conventions); try { conventionRunner.RunConventions(); deploymentJournalWriter.AddJournalEntry(deployment, true, packageFile); } catch (Exception) { deploymentJournalWriter.AddJournalEntry(deployment, false, packageFile); throw; } return(0); }
public override int Execute(string[] commandLineArguments) { Options.Parse(commandLineArguments); var configurationTransformer = ConfigurationTransformer.FromVariables(variables); var transformFileLocator = new TransformFileLocator(fileSystem); var replacer = new ConfigurationVariablesReplacer(variables.GetFlag(SpecialVariables.Package.IgnoreVariableReplacementErrors)); var jsonVariableReplacer = new JsonConfigurationVariableReplacer(); ValidateArguments(); WriteVariableScriptToFile(); var conventions = new List <IConvention> { new StageScriptPackagesConvention(packageFile, fileSystem, new CombinedPackageExtractor(log)), // Substitute the script source file new DelegateInstallConvention(d => substituteInFiles.Substitute(d, ScriptFileTargetFactory(d).ToList())), // Substitute any user-specified files new DelegateInstallConvention(d => substituteInFiles.SubstituteBasedSettingsInSuppliedVariables(d)), new ConfigurationTransformsConvention(fileSystem, configurationTransformer, transformFileLocator), new ConfigurationVariablesConvention(fileSystem, replacer), new JsonConfigurationVariablesConvention(jsonVariableReplacer, fileSystem), new ExecuteScriptConvention(scriptEngine, commandLineRunner) }; var deployment = new RunningDeployment(packageFile, variables); var conventionRunner = new ConventionProcessor(deployment, conventions); conventionRunner.RunConventions(); var exitCode = variables.GetInt32(SpecialVariables.Action.Script.ExitCode); deploymentJournalWriter.AddJournalEntry(deployment, exitCode == 0, packageFile); return(exitCode.Value); }
public override int Execute(string[] commandLineArguments) { Options.Parse(commandLineArguments); var configurationTransformer = ConfigurationTransformer.FromVariables(variables, log); var transformFileLocator = new TransformFileLocator(fileSystem, log); var replacer = new ConfigurationVariablesReplacer(variables, log); var allFileFormatReplacers = FileFormatVariableReplacers.BuildAllReplacers(fileSystem, log); var structuredConfigVariablesService = new StructuredConfigVariablesService(allFileFormatReplacers, fileSystem, log); ValidateArguments(); WriteVariableScriptToFile(); var conventions = new List <IConvention> { new StageScriptPackagesConvention(packageFile, fileSystem, new CombinedPackageExtractor(log)), // Substitute the script source file new DelegateInstallConvention(d => substituteInFiles.Substitute(d, ScriptFileTargetFactory(d).ToList())), // Substitute any user-specified files new SubstituteInFilesConvention(new SubstituteInFilesBehaviour(substituteInFiles)), new ConfigurationTransformsConvention(new ConfigurationTransformsBehaviour(fileSystem, configurationTransformer, transformFileLocator, log)), new ConfigurationVariablesConvention(new ConfigurationVariablesBehaviour(fileSystem, replacer, log)), new StructuredConfigurationVariablesConvention(new StructuredConfigurationVariablesBehaviour(structuredConfigVariablesService)), new ExecuteScriptConvention(scriptEngine, commandLineRunner) }; var deployment = new RunningDeployment(packageFile, variables); var conventionRunner = new ConventionProcessor(deployment, conventions, log); conventionRunner.RunConventions(); var exitCode = variables.GetInt32(SpecialVariables.Action.Script.ExitCode); deploymentJournalWriter.AddJournalEntry(deployment, exitCode == 0, packageFile); return(exitCode.Value); }
public override int Execute(string[] commandLineArguments) { Options.Parse(commandLineArguments); if (!File.Exists(pathToPackage)) { throw new CommandException("Could not find package file: " + pathToPackage); } ValidateRequiredVariables(); var conventions = new List <IConvention> { new DelegateInstallConvention(d => extractPackage.ExtractToStagingDirectory(pathToPackage)), new StageScriptPackagesConvention(null, fileSystem, new CombinedPackageExtractor(log, variables, commandLineRunner), true), new ConfiguredScriptConvention(new PreDeployConfiguredScriptBehaviour(log, fileSystem, scriptEngine, commandLineRunner)), // Any values.yaml files in any packages referenced by the step will automatically have variable substitution applied (we won't log a warning if these aren't present) new DelegateInstallConvention(d => substituteInFiles.Substitute(d, DefaultValuesFiles().ToList(), false)), // Any values files explicitly specified by the user will also have variable substitution applied new DelegateInstallConvention(d => substituteInFiles.Substitute(d, ExplicitlySpecifiedValuesFiles().ToList(), true)), new ConfiguredScriptConvention(new DeployConfiguredScriptBehaviour(log, fileSystem, scriptEngine, commandLineRunner)), new HelmUpgradeConvention(log, scriptEngine, commandLineRunner, fileSystem), new ConfiguredScriptConvention(new PostDeployConfiguredScriptBehaviour(log, fileSystem, scriptEngine, commandLineRunner)) }; var deployment = new RunningDeployment(pathToPackage, variables); var conventionRunner = new ConventionProcessor(deployment, conventions, log); try { conventionRunner.RunConventions(); deploymentJournalWriter.AddJournalEntry(deployment, true, pathToPackage); } catch (Exception) { deploymentJournalWriter.AddJournalEntry(deployment, false, pathToPackage); throw; } return(0); }
public override int Execute(string[] commandLineArguments) { Options.Parse(commandLineArguments); if (!File.Exists(pathToPackage)) { throw new CommandException("Could not find package file: " + pathToPackage); } ValidateRequiredVariables(); var conventions = new List <IConvention> { new DelegateInstallConvention(d => extractPackage.ExtractToStagingDirectory(pathToPackage)), new StageScriptPackagesConvention(null, fileSystem, new CombinedPackageExtractor(log), true), new ConfiguredScriptConvention(new PreDeployConfiguredScriptBehaviour(log, fileSystem, scriptEngine, commandLineRunner)), new DelegateInstallConvention(d => substituteInFiles.Substitute(d, FileTargetFactory().ToList())), new ConfiguredScriptConvention(new DeployConfiguredScriptBehaviour(log, fileSystem, scriptEngine, commandLineRunner)), new HelmUpgradeConvention(log, scriptEngine, commandLineRunner, fileSystem), new ConfiguredScriptConvention(new PostDeployConfiguredScriptBehaviour(log, fileSystem, scriptEngine, commandLineRunner)) }; var deployment = new RunningDeployment(pathToPackage, variables); var conventionRunner = new ConventionProcessor(deployment, conventions, log); try { conventionRunner.RunConventions(); deploymentJournalWriter.AddJournalEntry(deployment, true, pathToPackage); } catch (Exception) { deploymentJournalWriter.AddJournalEntry(deployment, false, pathToPackage); throw; } return(0); }
public override int Execute(string[] commandLineArguments) { Options.Parse(commandLineArguments); var fileSystem = CalamariPhysicalFileSystem.GetPhysicalFileSystem(); var commandLineRunner = new CommandLineRunner(new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables))); fileSubstituter = new FileSubstituter(fileSystem); var configurationTransformer = ConfigurationTransformer.FromVariables(variables); var transformFileLocator = new TransformFileLocator(fileSystem); var replacer = new ConfigurationVariablesReplacer(variables.GetFlag(SpecialVariables.Package.IgnoreVariableReplacementErrors)); var jsonVariableReplacer = new JsonConfigurationVariableReplacer(); var extractor = new GenericPackageExtractorFactory().createStandardGenericPackageExtractor(); ValidateArguments(); WriteVariableScriptToFile(); var conventions = new List <IConvention> { new ContributeEnvironmentVariablesConvention(), new ContributeVariablesFromJsonFileConvention(), new LogVariablesConvention(), new StageScriptPackagesConvention(packageFile, fileSystem, extractor), // Substitute the script source file new SubstituteInFilesConvention(fileSystem, fileSubstituter, _ => true, ScriptFileTargetFactory), // Substitute any user-specified files new SubstituteInFilesConvention(fileSystem, fileSubstituter), new ConfigurationTransformsConvention(fileSystem, configurationTransformer, transformFileLocator), new ConfigurationVariablesConvention(fileSystem, replacer), new JsonConfigurationVariablesConvention(jsonVariableReplacer, fileSystem), new ExecuteScriptConvention(scriptEngine, commandLineRunner) }; var deployment = new RunningDeployment(packageFile, variables); var conventionRunner = new ConventionProcessor(deployment, conventions); conventionRunner.RunConventions(); var exitCode = variables.GetInt32(SpecialVariables.Action.Script.ExitCode); deploymentJournalWriter.AddJournalEntry(deployment, exitCode == 0, packageFile); return(exitCode.Value); }