Skip to content

Commit

Permalink
refactor: Do some minor sruff
Browse files Browse the repository at this point in the history
Signed-off-by: Sergiy Kulanov <[email protected]>
  • Loading branch information
SergK committed Oct 10, 2023
1 parent 56d2655 commit 059ea93
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/taskgraph/taskgraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type TaskNode struct {
}

// FormatFunc is a function that generates the output format string for a TaskGraph
type formatFuncType func(graph *TaskGraph, format string, withTaskRef bool) (string, error)
type formatFuncMap func(graph *TaskGraph, format string, withTaskRef bool) (string, error)

func createTaskNode(task *v1pipeline.PipelineTask) *TaskNode {
return &TaskNode{
Expand Down Expand Up @@ -109,11 +109,9 @@ func (g *TaskGraph) ToPlantUML(withTaskRef bool) (string, error) {

func (g *TaskGraph) ToMermaid(withTaskRef bool) (string, error) {
var builder strings.Builder
var tmpl string
tmpl := mermaidTemplate
if withTaskRef {
tmpl = mermaidTemplateWithTaskRef
} else {
tmpl = mermaidTemplate
}
t, err := template.New("mermaid").Parse(tmpl)
if err != nil {
Expand All @@ -126,7 +124,7 @@ func (g *TaskGraph) ToMermaid(withTaskRef bool) (string, error) {
}

// formatFunc generates the output format string for a TaskGraph based on the specified format
var formatFunc formatFuncType = func(graph *TaskGraph, format string, withTaskRef bool) (string, error) {
var formatFunc formatFuncMap = func(graph *TaskGraph, format string, withTaskRef bool) (string, error) {
switch strings.ToLower(format) {
case "dot":
return graph.ToDOT(withTaskRef)
Expand Down

0 comments on commit 059ea93

Please sign in to comment.