Skip to content

Commit

Permalink
cli: Clean up pulumi stack output for non-deployed stacks
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFriel committed Oct 11, 2022
1 parent 954ef04 commit 0de16b5
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions pkg/cmd/pulumi/stack.go
Expand Up @@ -90,38 +90,38 @@ func newStackCmd() *cobra.Command {
}

if snap != nil {
if t := snap.Manifest.Time; t.IsZero() && startTime == "" {
fmt.Printf(" Last update time unknown\n")
} else if startTime == "" {
fmt.Printf(" Last updated: %s (%v)\n", humanize.Time(t), t)
t := snap.Manifest.Time.Local()
if startTime == "" {
// If a stack update is not in progress
if !t.IsZero() && t.Before(time.Now()) {
// If the update time is in the future, best to not display something incorrect based on
// inaccurate clocks.
fmt.Printf(" Last updated: %s (%v)\n", humanize.Time(t), t)
}
}
var cliver string
if snap.Manifest.Version == "" {
cliver = "?"
} else {
cliver = snap.Manifest.Version
if snap.Manifest.Version != "" {
fmt.Printf(" Pulumi version used: %s\n", snap.Manifest.Version)
}
fmt.Printf(" Pulumi version: %s\n", cliver)
for _, plugin := range snap.Manifest.Plugins {
var plugver string
if plugin.Version == nil {
plugver = "?"
for _, p := range snap.Manifest.Plugins {
var pluginVersion string
if p.Version == nil {
pluginVersion = "?"
} else {
plugver = plugin.Version.String()
pluginVersion = p.Version.String()
}
fmt.Printf(" Plugin %s [%s] version: %s\n", plugin.Name, plugin.Kind, plugver)
fmt.Printf(" Plugin %s [%s] version: %s\n", p.Name, p.Kind, pluginVersion)
}
} else {
fmt.Printf(" No updates yet; run `pulumi up`\n")
}

// Now show the resources.
var rescnt int
var resourceCount int
if snap != nil {
rescnt = len(snap.Resources)
resourceCount = len(snap.Resources)
}
fmt.Printf("Current stack resources (%d):\n", rescnt)
if rescnt == 0 {
fmt.Printf("Current stack resources (%d):\n", resourceCount)
if resourceCount == 0 {
fmt.Printf(" No resources currently in this stack\n")
} else {
rows, ok := renderTree(snap, showURNs, showIDs)
Expand Down Expand Up @@ -197,15 +197,15 @@ func printStackOutputs(outputs map[string]interface{}) {
if len(outputs) == 0 {
fmt.Printf(" No output values currently in this stack\n")
} else {
var outkeys []string
for outkey := range outputs {
outkeys = append(outkeys, outkey)
var outKeys []string
for v := range outputs {
outKeys = append(outKeys, v)
}
sort.Strings(outkeys)
sort.Strings(outKeys)

rows := []cmdutil.TableRow{}

for _, key := range outkeys {
for _, key := range outKeys {
rows = append(rows, cmdutil.TableRow{Columns: []string{key, stringifyOutput(outputs[key])}})
}

Expand Down

0 comments on commit 0de16b5

Please sign in to comment.