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 all 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
@@ -0,0 +1,4 @@
changes:
- type: feat
scope: cli
description: Adds option to have resource name in the node graph instead of full URNs.
16 changes: 15 additions & 1 deletion pkg/cmd/pulumi/stack_graph.go
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 resources instead of the URN")
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 URN.
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