2017-06-26 23:46:34 +02:00
|
|
|
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
2017-02-26 22:06:33 +01:00
|
|
|
|
2017-09-22 04:18:21 +02:00
|
|
|
package cmd
|
2017-02-26 22:06:33 +01:00
|
|
|
|
|
|
|
import (
|
2017-10-02 22:34:33 +02:00
|
|
|
"fmt"
|
|
|
|
"strconv"
|
|
|
|
|
2017-02-26 22:06:33 +01:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2017-09-22 04:18:21 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/util/cmdutil"
|
2017-02-26 22:06:33 +01:00
|
|
|
)
|
|
|
|
|
2017-03-06 15:32:39 +01:00
|
|
|
func newEnvLsCmd() *cobra.Command {
|
2017-02-26 22:06:33 +01:00
|
|
|
return &cobra.Command{
|
2017-09-23 00:29:24 +02:00
|
|
|
Use: "ls",
|
|
|
|
Short: "List all known environments",
|
2017-04-12 20:12:25 +02:00
|
|
|
Run: cmdutil.RunFunc(func(cmd *cobra.Command, args []string) error {
|
2017-10-02 22:34:33 +02:00
|
|
|
envs, err := lumiEngine.GetEnvironments()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("%-20s %-48s %-12s\n", "NAME", "LAST UPDATE", "RESOURCE COUNT")
|
|
|
|
for _, env := range envs {
|
|
|
|
// Now print out the name, last deployment time (if any), and resources (if any).
|
|
|
|
lastDeploy := "n/a"
|
|
|
|
resourceCount := "n/a"
|
|
|
|
if env.Checkpoint.Latest != nil {
|
|
|
|
lastDeploy = env.Checkpoint.Latest.Time.String()
|
|
|
|
}
|
|
|
|
if env.Snapshot != nil {
|
|
|
|
resourceCount = strconv.Itoa(len(env.Snapshot.Resources))
|
|
|
|
}
|
|
|
|
display := env.Name
|
|
|
|
if env.IsCurrent {
|
|
|
|
display += "*" // fancify the current environment.
|
|
|
|
}
|
|
|
|
fmt.Printf("%-20s %-48s %-12s\n", display, lastDeploy, resourceCount)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2017-08-23 01:23:50 +02:00
|
|
|
}),
|
|
|
|
}
|
|
|
|
}
|