Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature graph shortname #11352

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- type: feat
scope: cli
description: adds option to have resource name in the node graph instead of full urns
RobbieMcKinstry marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 15 additions & 1 deletion pkg/cmd/pulumi/stack_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ var ignoreParentEdges bool
// Whether or not we should ignore dependency edges when building up our graph.
var ignoreDependencyEdges bool

// Wether or not we should show the resource name instead of the urns when displaying the graph
var showResourceName bool

// The color of dependency edges in the graph. Defaults to #246C60, a blush-green.
var dependencyEdgeColor string

Expand Down Expand Up @@ -94,6 +97,8 @@ func newStackGraphCmd() *cobra.Command {
"Ignores edges introduced by parent/child resource relationships")
cmd.PersistentFlags().BoolVar(&ignoreDependencyEdges, "ignore-dependency-edges", false,
"Ignores edges introduced by dependency resource relationships")
cmd.PersistentFlags().BoolVar(&showResourceName, "show-resource-name", false,
"Display the name of the resource instead of their urns")
RobbieMcKinstry marked this conversation as resolved.
Show resolved Hide resolved
cmd.PersistentFlags().StringVar(&dependencyEdgeColor, "dependency-edge-color", "#246C60",
"Sets the color of dependency edges in the graph")
cmd.PersistentFlags().StringVar(&parentEdgeColor, "parent-edge-color", "#AA6639",
Expand Down Expand Up @@ -178,7 +183,7 @@ func (vertex *dependencyVertex) Data() interface{} {
}

func (vertex *dependencyVertex) Label() string {
return string(vertex.resource.URN)
return paintVertexLabel(vertex)
}

func (vertex *dependencyVertex) Ins() []graph.Edge {
Expand Down Expand Up @@ -214,6 +219,15 @@ func (dg *dependencyGraph) Roots() []graph.Edge {
return rootEdges
}

// Display resource label on the graph vertex. If show-resource-name is passed to the
// command line, the graph will only display the resource name in the vertex label instead of the URNS.
RobbieMcKinstry marked this conversation as resolved.
Show resolved Hide resolved
func paintVertexLabel(vertex *dependencyVertex) string {
if !showResourceName {
return string(vertex.resource.URN)
}
return string(vertex.resource.URN.Name())
}

// Makes a dependency graph from a deployment snapshot, allocating a vertex
// for every resource in the graph.
func makeDependencyGraph(snapshot *deploy.Snapshot) *dependencyGraph {
Expand Down