Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: Clean up pulumi stack output for non-deployed stacks #11004

Merged
merged 1 commit into from
Oct 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 25 additions & 25 deletions pkg/cmd/pulumi/stack.go
Original file line number Diff line number Diff line change
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