private async Task Run(string url) { _scriptWrapper = Create.WithParam(_view, SolrInfoExtensions.Convert); await _scriptWrapper.Run(Modules.Functions.TestSolrEndpoint, new Dictionary <string, dynamic> { { "Url", url } }); }
CalamariResult ExecuteScript(IScriptWrapper wrapper, string scriptName, IVariables variables) { var runner = new TestCommandLineRunner(ConsoleLog.Instance, variables); wrapper.NextWrapper = new TerminalScriptWrapper(new PowerShellScriptExecutor(), variables); var result = wrapper.ExecuteScript(new Script(scriptName), ScriptSyntax.PowerShell, runner, new Dictionary <string, string>()); return(new CalamariResult(result.ExitCode, runner.Output)); }
private CalamariResult ExecuteScript(IScriptWrapper wrapper, string scriptName, CalamariVariableDictionary variables) { var capture = new CaptureCommandOutput(); var runner = new CommandLineRunner(capture); wrapper.NextWrapper = new TerminalScriptWrapper(new PowerShellScriptEngine()); var result = wrapper.ExecuteScript(new Script(scriptName), ScriptSyntax.PowerShell, variables, runner, new StringDictionary()); //var result = psse.Execute(new Script(scriptName), variables, runner); return(new CalamariResult(result.ExitCode, capture)); }
CalamariResult ExecuteScript(IScriptWrapper wrapper, string scriptName) { var calamariResult = ExecuteScriptInternal(new CommandLineRunner(Log, variables), wrapper, scriptName); foreach (var message in Log.Messages) { Console.WriteLine($"[{message.Level}] {message.FormattedMessage}"); } return(calamariResult); }
internal PortalCredentialsPresenter(IPortalCredentialsView view) { _view = view; _settingsProvider = Create.New <ISettingsProvider>(); _view.FormLoaded += FormLoad; _view.TestClicked += TestClicked; _view.ValuesChanged += ValuesChanged; _scriptWrapper = Create.WithParam(_view, d => d); }
internal PrerequsitesPresenter(IPrerequisitesView view) { _view = view; _view.FormLoaded += FormLoaded; _view.InstallClicked += InstallClicked; var localProfile = Create.New <IProfilesProvider>().CreateLocal(); _scriptWrapper = Create.WithParam(_view, d => bool.Parse(d.ToString()), localProfile); _scriptWrapper.ProgressReady += ProgressReady; _scriptWrapper.ErrorReady += ErrorReady; }
public async Task PrepareAndStart(string script, Dictionary <string, dynamic> parameters, bool enforceLocal = false) { _scriptWrapper = enforceLocal ? LocalScriptWrapper : Create.WithParam(_view, d => d); AddHandlers(); _view.BeginUI(); await _scriptWrapper.Run(script, parameters); RemoveHandlers(); _view.FinishUI(); }
CalamariResult ExecuteScriptInternal(ICommandLineRunner runner, IScriptWrapper wrapper, string scriptName) { var wrappers = new List <IScriptWrapper>(new[] { wrapper }); if (variables.Get(Deployment.SpecialVariables.Account.AccountType) == "AmazonWebServicesAccount") { wrappers.Add(new AwsScriptWrapper(Log, variables)); } var engine = new ScriptEngine(wrappers); var result = engine.Execute(new Script(scriptName), variables, runner, GetEnvironments()); return(new CalamariResult(result.ExitCode, new CaptureCommandInvocationOutputSink())); }
private void RemoveHandlers() { if (_scriptWrapper != null) { _scriptWrapper.Complete -= Complete; _scriptWrapper.ObjectReady -= ObjectReady; _scriptWrapper.ProgressReady -= ProgressReady; _scriptWrapper.InformationReady -= InformationReady; _scriptWrapper.WarningReady -= WarningReady; _scriptWrapper.ErrorReady -= ErrorReady; _scriptWrapper = null; } }
internal BaseBackupRestorePresenter(IBaseBackupRestoreView view) { _profileProvider = Create.New <IProfilesProvider>(); var profile = _profileProvider.SelectedProfile; _view = view; _view.FolderBrowserClicked += (sender, e) => e.Value1.Text = ShowFolderSelector(profile, e.Value2); _view.AppendEnvironmentToCaption(profile.WindowCaptionSuffix); _scriptWrapper = Create.WithParam(_view, d => d.ToString()); _remoteScriptCopier = Create.WithCurrentProfile <IRemoteScriptCopier>(_view); _siteProvider = Create.WithCurrentProfile <ISiteProvider>(_view); }
// fake profile is initially passed: always runs local, also passes credentials internal InitRemotePresenter(InitRemoteView view, IRemoteSettings remoteSettings) { _view = view; _parameters = CreateParameters(remoteSettings); _view.FormLoaded += FormLoaded; var localProfile = Create.New <IProfilesProvider>().CreateLocal(); _scriptWrapper = Create.WithParam(_view, d => d?.ToString(), localProfile); _scriptWrapper.ProgressReady += ProgressReady; _scriptWrapper.ErrorReady += ErrorReady; }
internal InstallSolrPresenter(IInstallSolr view, SolrHelper viewHelper) { _view = view; _view.LoadedAsync += async(s, e) => { await Loaded(s, e); }; _viewHelper = viewHelper; _view.InstallClicked += InstallClicked; _view.UninstallClicked += async(s, e) => { await UninstallClicked(s, (EventArgs <string>) e); }; _view.ClosingForm += ClosingForm; _profile = Create.New <IProfilesProvider>().SelectedProfile; _scriptWrapper = Create.WithParam(_view, d => bool.Parse(d.ToString()), _profile); _view.FolderBrowserClicked += (sender, e) => e.Value1.Text = ShowFolderSelector(_profile, e.Value2); }
internal SqlSettingsPresenter(ISqlSettingsView sqlSettingsView) { _view = sqlSettingsView; _sqlService = Create.New <ISqlServerRecordProvider>(); _profilesProvider = Create.New <IProfilesProvider>(); _view.FormLoad += FormLoad; _view.TestClicked += TestClicked; _view.SelectedRecordChanged += SelectedRecordChanged; _view.SqlRecordAdded += SqlRecordAdded; _view.SqlRecordRenamed += SqlRecordRenamed; _view.SqlRecordDeleted += SqlRecordDeleted; _view.ClosingForm += ClosingForm; _scriptWrapper = Create.WithParam(_view, d => d); }
protected void TestScript(IScriptWrapper wrapper, string scriptName) { using (var dir = TemporaryDirectory.Create()) { var folderPath = Path.Combine(dir.DirectoryPath, "Folder with spaces"); using (var temp = new TemporaryFile(Path.Combine(folderPath, $"{scriptName}.{(variables.Get(ScriptVariables.Syntax) == ScriptSyntax.Bash.ToString() ? "sh" : "ps1")}"))) { Directory.CreateDirectory(folderPath); File.WriteAllText(temp.FilePath, $"echo running target script..."); var output = ExecuteScript(wrapper, temp.FilePath); output.AssertSuccess(); } } }
private void TestScript(IScriptWrapper wrapper, string scriptName) { using (var dir = TemporaryDirectory.Create()) using (var temp = new TemporaryFile(Path.Combine(dir.DirectoryPath, scriptName))) { File.WriteAllText(temp.FilePath, "kubectl get nodes"); var deploymentVariables = new CalamariVariableDictionary(); deploymentVariables.Set(SpecialVariables.ClusterUrl, ServerUrl); deploymentVariables.Set(SpecialVariables.SkipTlsVerification, "true"); deploymentVariables.Set(SpecialVariables.Namespace, "calamari-testing"); deploymentVariables.Set(Deployment.SpecialVariables.Account.AccountType, "Token"); deploymentVariables.Set(Deployment.SpecialVariables.Account.Token, ClusterToken); var output = ExecuteScript(wrapper, temp.FilePath, deploymentVariables); output.AssertSuccess(); } }
CalamariResult TestScriptInReadOnlyMode(IScriptWrapper wrapper, [CallerMemberName] string testName = null, [CallerFilePath] string filePath = null) { using (var dir = TemporaryDirectory.Create()) using (var temp = new TemporaryFile(Path.Combine(dir.DirectoryPath, $"scriptName.{(variables.Get(ScriptVariables.Syntax) == ScriptSyntax.Bash.ToString() ? "sh" : "ps1")}"))) { File.WriteAllText(temp.FilePath, "kubectl get nodes"); var output = ExecuteScriptInRecordOnlyMode(wrapper, temp.FilePath); redactMap[dir.DirectoryPath + Path.DirectorySeparatorChar] = "<path>"; var sb = new StringBuilder(); foreach (var message in log.Messages) { var text = message.FormattedMessage; text = redactMap.Aggregate(text, (current, pair) => current.Replace(pair.Key, pair.Value)); sb.AppendLine($"[{message.Level}] {text}"); } this.Assent(sb.ToString().Replace("\r\n", "\n"), testName: testName, filePath: filePath, configuration: AssentConfiguration.Default); return(output); } }
CalamariResult ExecuteScriptInRecordOnlyMode(IScriptWrapper wrapper, string scriptName) { return(ExecuteScriptInternal(new RecordOnly(), wrapper, scriptName)); }
internal SolrIdentifier(ISynchronizeInvoke invoke) { _scriptWrapper = Create.WithParam(invoke, SolrInfoExtensions.Convert); _scriptWrapper.ProgressReady += ProgressReady; }
internal IndexFinder(IProfile profile, ISynchronizeInvoke invoke) { _profile = profile; _scriptWrapper = Create.WithParam(invoke, s => s?.ToString(), profile); }