diff --git a/cmd/config.go b/cmd/config.go index 7ba2f4f03..30e544365 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -7,6 +7,8 @@ import ( "sort" "strings" + "github.com/pulumi/pulumi/pkg/pack" + "github.com/pulumi/pulumi/pkg/util/contract" "github.com/pkg/errors" @@ -80,6 +82,10 @@ func prettyKey(key string) string { return key } + return prettyKeyForPackage(key, pkg) +} + +func prettyKeyForPackage(key string, pkg pack.Package) string { s := key defaultPrefix := fmt.Sprintf("%s:config:", pkg.Name) diff --git a/cmd/config_test.go b/cmd/config_test.go new file mode 100644 index 000000000..ceb6aa84f --- /dev/null +++ b/cmd/config_test.go @@ -0,0 +1,19 @@ +// Copyright 2016-2017, Pulumi Corporation. All rights reserved. + +package cmd + +import ( + "testing" + + "github.com/pulumi/pulumi/pkg/pack" + "github.com/pulumi/pulumi/pkg/tokens" + + "github.com/stretchr/testify/assert" +) + +func TestPrettyKeyForPackage(t *testing.T) { + pkg := pack.Package{Name: tokens.PackageName("test-package"), Runtime: "nodejs"} + + assert.Equal(t, "foo", prettyKeyForPackage("test-package:config:foo", pkg)) + assert.Equal(t, "other-package:config:bar", prettyKeyForPackage("other-package:config:bar", pkg)) +}