A handful of UX improvments for config: - `pulumi config ls` has been removed. Now, `pulumi config` with no arguments prints the table of configuration values for a stack and a new command `pulumi config get <key>` prints the value for a single configuration key (useful for scripting). - `pulumi config text` and `pulumi config secret` have been merged into a single command `pulumi config set`. The flag `--secret` can be used to encrypt the value we store (like `pulumi config secret` used to do). - To make it obvious that setting a value with `pulumi config set` is in plan text, we now echo a message back to the user saying we added the configuration value in plaintext. Fixes #552
66 lines
1.4 KiB
Go
66 lines
1.4 KiB
Go
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/pulumi/pulumi/pkg/component"
|
|
"github.com/pulumi/pulumi/pkg/util/cmdutil"
|
|
)
|
|
|
|
func newLogsCmd() *cobra.Command {
|
|
var stack string
|
|
var follow bool
|
|
|
|
logsCmd := &cobra.Command{
|
|
Use: "logs",
|
|
Short: "Show aggregated logs for a project",
|
|
Run: cmdutil.RunFunc(func(cmd *cobra.Command, args []string) error {
|
|
stackName, err := explicitOrCurrent(stack, backend)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
sinceTime := time.Unix(0, 0)
|
|
highestTimeSeen := time.Unix(0, 0)
|
|
|
|
for {
|
|
logs, err := backend.GetLogs(stackName, component.LogQuery{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, logEntry := range logs {
|
|
eventTime := time.Unix(0, logEntry.Timestamp*1000000)
|
|
if eventTime.After(sinceTime) {
|
|
fmt.Printf("[%v] %v\n", eventTime, logEntry.Message)
|
|
}
|
|
|
|
if eventTime.After(highestTimeSeen) {
|
|
highestTimeSeen = eventTime
|
|
}
|
|
}
|
|
|
|
if !follow {
|
|
return nil
|
|
}
|
|
|
|
sinceTime = highestTimeSeen
|
|
time.Sleep(time.Second)
|
|
}
|
|
}),
|
|
}
|
|
|
|
logsCmd.PersistentFlags().StringVarP(
|
|
&stack, "stack", "s", "",
|
|
"List configuration for a different stack than the currently selected stack")
|
|
logsCmd.PersistentFlags().BoolVarP(
|
|
&follow, "follow", "f", false,
|
|
"Follow the log stream in real time (like tail -f)")
|
|
|
|
return logsCmd
|
|
}
|