[CLI] Add Version to the output of pulumi stack history (#6063)

fixes: #4328

Allows events to be tracked back to those of the Pulumi SaaS

Co-authored-by: stack72 <public@paulstack.co.uk>
This commit is contained in:
Pulumi Bot 2021-01-07 11:44:15 -08:00 committed by GitHub
parent 9d0bac3e08
commit 42f355b497
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 2 deletions

View file

@ -2,7 +2,10 @@ CHANGELOG
=========
## HEAD (Unreleased)
_(none)_
- [CLI] Add `version` to the stack history output to be able to
correlate events back to the Pulumi SaaS
[#6063](https://github.com/pulumi/pulumi/pull/6063)
## 2.17.0 (2021-01-06)

View file

@ -1114,6 +1114,7 @@ func (b *cloudBackend) GetHistory(ctx context.Context, stackRef backend.StackRef
}
beUpdates = append(beUpdates, backend.UpdateInfo{
Version: update.Version,
Kind: update.Kind,
Message: update.Message,
Environment: update.Environment,

View file

@ -107,6 +107,7 @@ type UpdateInfo struct {
Config config.Map `json:"config"`
// Information obtained from an update completing.
Version int `json:"version"`
Result UpdateResult `json:"result"`
EndTime int64 `json:"endTime"`
ResourceChanges engine.ResourceChanges `json:"resourceChanges,omitempty"`

View file

@ -77,6 +77,7 @@ This command displays data about previous updates for a stack.`,
// updateInfoJSON is the shape of the --json output for a configuration value. While we can add fields to this
// structure in the future, we should not change existing fields.
type updateInfoJSON struct {
Version int `json:"version"`
Kind string `json:"kind"`
StartTime string `json:"startTime"`
Message string `json:"message"`
@ -97,6 +98,7 @@ func displayUpdatesJSON(updates []backend.UpdateInfo, decrypter config.Decrypter
updatesJSON := make([]updateInfoJSON, len(updates))
for idx, update := range updates {
info := updateInfoJSON{
Version: update.Version,
Kind: string(update.Kind),
StartTime: time.Unix(update.StartTime, 0).UTC().Format(timeFormat),
Message: update.Message,
@ -155,7 +157,7 @@ func displayUpdatesConsole(updates []backend.UpdateInfo, opts display.Options) e
}
for _, update := range updates {
fmt.Printf("Version: %d\n", update.Version)
fmt.Printf("UpdateKind: %v\n", update.Kind)
if update.Result == "succeeded" {
fmt.Print(opts.Color.Colorize(fmt.Sprintf("%sStatus: %v%s\n", colors.Green, update.Result, colors.Reset)))