Skip to content

Commit

Permalink
cli: Add fully qualified stack reference to pulumi about
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFriel committed Nov 17, 2022
1 parent b950cf0 commit 3b6bbc8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
3 changes: 3 additions & 0 deletions pkg/backend/backend.go
Expand Up @@ -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 is the name
FullyQualifiedName() tokens.Name
}

// PolicyPackReference is an opaque type that refers to a PolicyPack managed by a backend. The CLI
Expand Down
5 changes: 5 additions & 0 deletions pkg/backend/filestate/backend.go
Expand Up @@ -99,6 +99,11 @@ func (r localBackendReference) Name() tokens.Name {
return r.name
}

func (c localBackendReference) FullyQualifiedName() tokens.Name {
// TODO[pulumi/pulumi#11390]: Unable to provide this value until we solve this issue.
return tokens.Name("")
}

func IsFileStateBackendURL(urlstr string) bool {
u, err := url.Parse(urlstr)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/backend/httpstate/stack.go
Expand Up @@ -74,6 +74,10 @@ func (c cloudBackendReference) Name() tokens.Name {
return c.name
}

func (c cloudBackendReference) FullyQualifiedName() tokens.Name {
return tokens.Name(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.
Expand Down
43 changes: 26 additions & 17 deletions pkg/cmd/pulumi/about.go
Expand Up @@ -86,16 +86,17 @@ type summaryAbout struct {
// We use pointers here to allow the field to be nullable. When
// constructing, we either fill in a field or add an error. We still
// indicate that the field should be present when we serialize the struct.
Plugins []pluginAbout `json:"plugins"`
Host *hostAbout `json:"host"`
Backend *backendAbout `json:"backend"`
CurrentStack *currentStackAbout `json:"currentStack"`
CLI *cliAbout `json:"cliAbout"`
Runtime *projectRuntimeAbout `json:"runtime"`
Dependencies []programDependencyAbout `json:"dependencies"`
ErrorMessages []string `json:"errors"`
Errors []error `json:"-"`
LogMessage string `json:"-"`
Plugins []pluginAbout `json:"plugins"`
Host *hostAbout `json:"host"`
Backend *backendAbout `json:"backend"`
CurrentStack *currentStackAbout `json:"currentStack"`
CLI *cliAbout `json:"cliAbout"`
Runtime *projectRuntimeAbout `json:"runtime"`
Dependencies []programDependencyAbout `json:"dependencies"`
ErrorMessages []string `json:"errors"`
StackReference string `json:"stackReference"`
Errors []error `json:"-"`
LogMessage string `json:"-"`
}

func getSummaryAbout(ctx context.Context, transitiveDependencies bool, selectedStack string) summaryAbout {
Expand Down Expand Up @@ -188,6 +189,7 @@ func getSummaryAbout(ctx context.Context, transitiveDependencies bool, selectedS
tmp := getBackendAbout(backend)
result.Backend = &tmp
}

return result
}

Expand Down Expand Up @@ -330,9 +332,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 {
Expand Down Expand Up @@ -386,9 +389,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
}

Expand Down Expand Up @@ -423,7 +427,12 @@ func (current currentStackAbout) String() string {
Rows: rows,
}.String() + "\n"
}
return fmt.Sprintf("Current Stack: %s\n\n%s\n%s", current.Name, resources, pending)
return fmt.Sprintf(`Current Stack: %s
Fully qualified stack name: %s
%s
%s`, current.Name, current.FullyQualifiedName, resources, pending)
}

func simpleTableRows(arr [][]string) []cmdutil.TableRow {
Expand Down

0 comments on commit 3b6bbc8

Please sign in to comment.