Have pulumi config ls
take the current stack into account
This commit is contained in:
parent
95062100f7
commit
e15131e3e7
1 changed files with 12 additions and 3 deletions
|
@ -7,6 +7,8 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pulumi/pulumi/pkg/util/contract"
|
||||||
|
|
||||||
"github.com/pulumi/pulumi/pkg/pack"
|
"github.com/pulumi/pulumi/pkg/pack"
|
||||||
"github.com/pulumi/pulumi/pkg/resource/config"
|
"github.com/pulumi/pulumi/pkg/resource/config"
|
||||||
|
|
||||||
|
@ -38,7 +40,10 @@ func newConfigLsCmd() *cobra.Command {
|
||||||
Short: "List configuration for a stack",
|
Short: "List configuration for a stack",
|
||||||
Args: cobra.MaximumNArgs(1),
|
Args: cobra.MaximumNArgs(1),
|
||||||
Run: cmdutil.RunFunc(func(cmd *cobra.Command, args []string) error {
|
Run: cmdutil.RunFunc(func(cmd *cobra.Command, args []string) error {
|
||||||
stackName := tokens.QName(stack)
|
stackName, err := explicitOrCurrent(stack)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
key, err := parseConfigKey(args[0])
|
key, err := parseConfigKey(args[0])
|
||||||
|
@ -252,16 +257,20 @@ func getConfig(stackName tokens.QName, key tokens.ModuleMember) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfiguration(stackName tokens.QName) (map[tokens.ModuleMember]config.Value, error) {
|
func getConfiguration(stackName tokens.QName) (map[tokens.ModuleMember]config.Value, error) {
|
||||||
|
contract.Require(stackName != "", "stackName")
|
||||||
|
|
||||||
pkg, err := getPackage()
|
pkg, err := getPackage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if stackName == "" {
|
stackInfo, hasStackInfo := pkg.Stacks[stackName]
|
||||||
|
|
||||||
|
if !hasStackInfo {
|
||||||
return pkg.Config, nil
|
return pkg.Config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return mergeConfigs(pkg.Config, pkg.Stacks[stackName].Config), nil
|
return mergeConfigs(pkg.Config, stackInfo.Config), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteConfiguration(stackName tokens.QName, key tokens.ModuleMember) error {
|
func deleteConfiguration(stackName tokens.QName, key tokens.ModuleMember) error {
|
||||||
|
|
Loading…
Reference in a new issue