diff --git a/changelog/pending/20221118--cli-about--add-fully-qualified-stack-name-to-current-stack.yaml b/changelog/pending/20221118--cli-about--add-fully-qualified-stack-name-to-current-stack.yaml new file mode 100644 index 000000000000..0eb5cbba99a0 --- /dev/null +++ b/changelog/pending/20221118--cli-about--add-fully-qualified-stack-name-to-current-stack.yaml @@ -0,0 +1,4 @@ +changes: +- type: feat + scope: cli/about + description: Add fully qualified stack name to current stack. diff --git a/pkg/backend/backend.go b/pkg/backend/backend.go index de5c154fb4e6..495f7fa5a770 100644 --- a/pkg/backend/backend.go +++ b/pkg/backend/backend.go @@ -75,6 +75,9 @@ type StackReference interface { // name may not uniquely identify the stack (e.g. the cloud backend embeds owner information in the StackReference // but that information is not part of the StackName() we pass to the engine. Name() tokens.Name + + // Fully qualified name of the stack. + FullyQualifiedName() tokens.QName } // PolicyPackReference is an opaque type that refers to a PolicyPack managed by a backend. The CLI diff --git a/pkg/backend/filestate/backend.go b/pkg/backend/filestate/backend.go index 22d0f01652f1..a1abc41ad25a 100644 --- a/pkg/backend/filestate/backend.go +++ b/pkg/backend/filestate/backend.go @@ -99,6 +99,10 @@ func (r localBackendReference) Name() tokens.Name { return r.name } +func (r localBackendReference) FullyQualifiedName() tokens.QName { + return r.Name().Q() +} + func IsFileStateBackendURL(urlstr string) bool { u, err := url.Parse(urlstr) if err != nil { diff --git a/pkg/backend/httpstate/stack.go b/pkg/backend/httpstate/stack.go index f9b97318dc20..c2542915a764 100644 --- a/pkg/backend/httpstate/stack.go +++ b/pkg/backend/httpstate/stack.go @@ -74,6 +74,10 @@ func (c cloudBackendReference) Name() tokens.Name { return c.name } +func (c cloudBackendReference) FullyQualifiedName() tokens.QName { + return tokens.IntoQName(fmt.Sprintf("%v/%v/%v", c.owner, c.project, c.name.String())) +} + // cloudStack is a cloud stack descriptor. type cloudStack struct { // ref is the stack's unique name. diff --git a/pkg/cmd/pulumi/about.go b/pkg/cmd/pulumi/about.go index 22156583d3ba..676fac6808bc 100644 --- a/pkg/cmd/pulumi/about.go +++ b/pkg/cmd/pulumi/about.go @@ -330,9 +330,10 @@ func (b backendAbout) String() string { } type currentStackAbout struct { - Name string `json:"name"` - Resources []aboutState `json:"resources"` - PendingOps []aboutState `json:"pendingOps"` + Name string `json:"name"` + FullyQualifiedName string `json:"fullyQualifiedName"` + Resources []aboutState `json:"resources"` + PendingOps []aboutState `json:"pendingOps"` } type aboutState struct { @@ -386,9 +387,10 @@ func getCurrentStackAbout(ctx context.Context, b backend.Backend, selectedStack } } return currentStackAbout{ - Name: name, - Resources: aboutResources, - PendingOps: aboutPending, + Name: name, + FullyQualifiedName: stack.Ref().FullyQualifiedName().String(), + Resources: aboutResources, + PendingOps: aboutPending, }, nil } @@ -423,7 +425,11 @@ func (current currentStackAbout) String() string { Rows: rows, }.String() + "\n" } - return fmt.Sprintf("Current Stack: %s\n\n%s\n%s", current.Name, resources, pending) + stackName := current.Name + if current.FullyQualifiedName != "" { + stackName = current.FullyQualifiedName + } + return fmt.Sprintf("Current Stack: %s\n\n%s\n%s", stackName, resources, pending) } func simpleTableRows(arr [][]string) []cmdutil.TableRow { diff --git a/pkg/cmd/pulumi/stack_ls_test.go b/pkg/cmd/pulumi/stack_ls_test.go index 42c3a1dabd54..2152a2281535 100644 --- a/pkg/cmd/pulumi/stack_ls_test.go +++ b/pkg/cmd/pulumi/stack_ls_test.go @@ -82,6 +82,10 @@ func (msr *mockStackReference) Name() tokens.Name { return tokens.Name(msr.name) } +func (msr *mockStackReference) FullyQualifiedName() tokens.QName { + return msr.Name().Q() +} + func (msr *mockStackReference) String() string { return msr.name }