From b7ce87a43607084bb0c12a6420880cdbd91b53ad Mon Sep 17 00:00:00 2001 From: hernandoagudelo Date: Sun, 13 Nov 2022 22:13:36 +0800 Subject: [PATCH 1/6] feat: Add option to display resource name instead of urns on the vertices --- pkg/cmd/pulumi/stack_graph.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/pulumi/stack_graph.go b/pkg/cmd/pulumi/stack_graph.go index 90afd0fef5f8..2f56a1ef06fe 100644 --- a/pkg/cmd/pulumi/stack_graph.go +++ b/pkg/cmd/pulumi/stack_graph.go @@ -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 @@ -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") 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", @@ -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 { @@ -214,6 +219,15 @@ func (dg *dependencyGraph) Roots() []graph.Edge { return rootEdges } +// Display resource label on the graph vertex. If ignore-resource-urn is passed to the +// command line the graph will only display the resource name in the vertex label instead of the URNS. +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 { From 6af76b3f4e6845a42d223df0d9b43d87c41e0fb2 Mon Sep 17 00:00:00 2001 From: hernandoagudelo Date: Tue, 15 Nov 2022 09:56:53 +0800 Subject: [PATCH 2/6] chore: add changelog --- .../20221115--cli--add-resource-name-to-stack-graph.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/pending/20221115--cli--add-resource-name-to-stack-graph.yaml diff --git a/changelog/pending/20221115--cli--add-resource-name-to-stack-graph.yaml b/changelog/pending/20221115--cli--add-resource-name-to-stack-graph.yaml new file mode 100644 index 000000000000..2f66117cd4eb --- /dev/null +++ b/changelog/pending/20221115--cli--add-resource-name-to-stack-graph.yaml @@ -0,0 +1,4 @@ +changes: +- type: feat + scope: cli + description: adds option to have resource name in the node graph instead of full urns From 768974720df964a23255942eafcfea57ad1f89f0 Mon Sep 17 00:00:00 2001 From: Hernando Agudelo Madero <107454660+heagma@users.noreply.github.com> Date: Tue, 15 Nov 2022 11:12:31 +0800 Subject: [PATCH 3/6] chore: fix typo --- pkg/cmd/pulumi/stack_graph.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/pulumi/stack_graph.go b/pkg/cmd/pulumi/stack_graph.go index 2f56a1ef06fe..eeb1eec2099c 100644 --- a/pkg/cmd/pulumi/stack_graph.go +++ b/pkg/cmd/pulumi/stack_graph.go @@ -219,8 +219,8 @@ func (dg *dependencyGraph) Roots() []graph.Edge { return rootEdges } -// Display resource label on the graph vertex. If ignore-resource-urn is passed to the -// command line the graph will only display the resource name in the vertex label instead of the URNS. +// 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. func paintVertexLabel(vertex *dependencyVertex) string { if !showResourceName { return string(vertex.resource.URN) From 57053513382d7f872cbf26dc00630604afb96922 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Wed, 11 Jan 2023 22:08:44 -0800 Subject: [PATCH 4/6] Update changelog/pending/20221115--cli--add-resource-name-to-stack-graph.yaml Co-authored-by: Fraser Waters --- .../20221115--cli--add-resource-name-to-stack-graph.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/pending/20221115--cli--add-resource-name-to-stack-graph.yaml b/changelog/pending/20221115--cli--add-resource-name-to-stack-graph.yaml index 2f66117cd4eb..810274f8d983 100644 --- a/changelog/pending/20221115--cli--add-resource-name-to-stack-graph.yaml +++ b/changelog/pending/20221115--cli--add-resource-name-to-stack-graph.yaml @@ -1,4 +1,4 @@ changes: - type: feat scope: cli - description: adds option to have resource name in the node graph instead of full urns + description: Adds option to have resource name in the node graph instead of full URNs. From d32611a2f2c9f3eab6673305d666fa29eea9fa24 Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Wed, 11 Jan 2023 22:08:51 -0800 Subject: [PATCH 5/6] Update pkg/cmd/pulumi/stack_graph.go Co-authored-by: Fraser Waters --- pkg/cmd/pulumi/stack_graph.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/pulumi/stack_graph.go b/pkg/cmd/pulumi/stack_graph.go index eeb1eec2099c..2a795153a8d6 100644 --- a/pkg/cmd/pulumi/stack_graph.go +++ b/pkg/cmd/pulumi/stack_graph.go @@ -220,7 +220,7 @@ func (dg *dependencyGraph) Roots() []graph.Edge { } // 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. +// 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) From 644fc25c1c01943e8b9363c556d8f82c90ffc9ba Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Wed, 11 Jan 2023 22:08:56 -0800 Subject: [PATCH 6/6] Update pkg/cmd/pulumi/stack_graph.go Co-authored-by: Fraser Waters --- pkg/cmd/pulumi/stack_graph.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/pulumi/stack_graph.go b/pkg/cmd/pulumi/stack_graph.go index 2a795153a8d6..1b5fe56a887f 100644 --- a/pkg/cmd/pulumi/stack_graph.go +++ b/pkg/cmd/pulumi/stack_graph.go @@ -98,7 +98,7 @@ func newStackGraphCmd() *cobra.Command { 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") + "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",