/// <summary> /// Returns a list summarizing all previews and current results from Stack lifecycle operations (up/preview/refresh/destroy). /// </summary> /// <param name="options">Options to customize the behavior of the fetch history action.</param> /// <param name="cancellationToken">A cancellation token.</param> public async Task <ImmutableList <UpdateSummary> > GetHistoryAsync( HistoryOptions?options = null, CancellationToken cancellationToken = default) { var args = new List <string>() { "history", "--json", "--show-secrets", }; if (options?.PageSize.HasValue == true) { if (options.PageSize !.Value < 1) { throw new ArgumentException($"{nameof(options.PageSize)} must be greater than or equal to 1.", nameof(options.PageSize)); } var page = !options.Page.HasValue ? 1 : options.Page.Value < 1 ? 1 : options.Page.Value; args.Add("--page-size"); args.Add(options.PageSize.Value.ToString()); args.Add("--page"); args.Add(page.ToString()); } var result = await this.RunCommandAsync(args, null, cancellationToken).ConfigureAwait(false); var jsonOptions = LocalSerializer.BuildJsonSerializerOptions(); var list = JsonSerializer.Deserialize <List <UpdateSummary> >(result.StandardOutput, jsonOptions); return(list.ToImmutableList()); }
/// <summary> /// Gets the current set of Stack outputs from the last <see cref="UpAsync(UpOptions?, CancellationToken)"/>. /// </summary> public async Task <ImmutableDictionary <string, OutputValue> > GetOutputsAsync(CancellationToken cancellationToken = default) { await this.Workspace.SelectStackAsync(this.Name).ConfigureAwait(false); // TODO: do this in parallel after this is fixed https://github.com/pulumi/pulumi/issues/6050 var maskedResult = await this.RunCommandAsync(new[] { "stack", "output", "--json" }, null, null, null, cancellationToken).ConfigureAwait(false); var plaintextResult = await this.RunCommandAsync(new[] { "stack", "output", "--json", "--show-secrets" }, null, null, null, cancellationToken).ConfigureAwait(false); var jsonOptions = LocalSerializer.BuildJsonSerializerOptions(); var maskedOutput = string.IsNullOrWhiteSpace(maskedResult.StandardOutput) ? new Dictionary <string, object>() : JsonSerializer.Deserialize <Dictionary <string, object> >(maskedResult.StandardOutput, jsonOptions); var plaintextOutput = string.IsNullOrWhiteSpace(plaintextResult.StandardOutput) ? new Dictionary <string, object>() : JsonSerializer.Deserialize <Dictionary <string, object> >(plaintextResult.StandardOutput, jsonOptions); var output = new Dictionary <string, OutputValue>(); foreach (var(key, value) in plaintextOutput) { var secret = maskedOutput[key] is string maskedValue && maskedValue == "[secret]"; output[key] = new OutputValue(value, secret); } return(output.ToImmutableDictionary()); }
void MainWindowClosing(object sender, CancelEventArgs e) { LocalSerializer.SaveBackup(chat._User.GetUserInfoData(), chat._User.GetContactList()); }