Skip to content

Commit

Permalink
Don't truncate stage labels in --layers mode (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhoefler committed Feb 5, 2023
1 parent e0d71e5 commit 7d2b82e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/images/Dockerfile-layers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions internal/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ It creates a visual graph representation of the build process.
}
;
subgraph cluster_stage_1 {
label="build-tool-depend...";
label="build-tool-dependencies";
margin=16;
stage_1_layer_0 [ fillcolor=white, label="FROM golang:1.19 ...", penwidth=0.5, shape=box, style="filled,rounded", width=2 ];
stage_1_layer_1 [ fillcolor=white, label="RUN --mount=type=...", penwidth=0.5, shape=box, style="filled,rounded", width=2 ];
Expand Down Expand Up @@ -232,7 +232,7 @@ It creates a visual graph representation of the build process.
stage_0_layer_0 -> stage_0_layer_1;
}
subgraph cluster_stage_1 {
graph [label="build-tool-depend...",
graph [label="build-tool-dependencies",
margin=16
];
stage_1_layer_0 [fillcolor=white,
Expand Down
4 changes: 2 additions & 2 deletions internal/dockerfile2dot/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func BuildDotFile(
cluster := fmt.Sprintf("cluster_stage_%d", stageIndex)

clusterAttrs := map[string]string{
"label": getStageLabel(stageIndex, stage, maxLabelLength),
"label": getStageLabel(stageIndex, stage, 0),
"margin": "16",
}

Expand Down Expand Up @@ -237,7 +237,7 @@ func addLegend(graph *gographviz.Escape, edgestyle string) {
}

func getStageLabel(stageIndex int, stage Stage, maxLabelLength int) string {
if len(stage.Name) > maxLabelLength {
if maxLabelLength > 0 && len(stage.Name) > maxLabelLength {
return truncate.Truncate(
stage.Name, maxLabelLength, "...", truncate.PositionEnd,
)
Expand Down

0 comments on commit 7d2b82e

Please sign in to comment.