imjasonh / ideas

A place for me to file issues against myself for things I want to build when I'm bored
5 stars 0 forks source link

Tekton Pipeline graphviz generator #106

Open imjasonh opened 2 years ago

imjasonh commented 2 years ago

kubectl get pipeline foo | tknviz | dot -Tpng ...

Ideas:

mattmoor commented 2 years ago

Have you seen n3wscott/graph?

imjasonh commented 2 years ago

Very nice. I think he had some cgo-less graphviz SVG thing I wanted to use right?

@n3wscott @jonjohnsonjr

Graphviz squad assemble

mattmoor commented 2 years ago

y'all should check out mermaid diagrams too, I hear they are the new hotness (or so my daughter tells me).

n3wscott commented 2 years ago

Take a look at https://github.com/n3wscott/go-graphviz

I forked go-graphviz and removed all the cgo parts. I also found it is not great at making dot files, but I use it like this:

    graph, err := graphviz.ParseBytes(g.Dot(opts))
    if err != nil {
        return err
    }

    gv := graphviz.New()
    defer func() {
        if err := graph.Close(); err != nil {
            log.Fatal(err)
        }
        _ = gv.Close()
    }()

    return gv.RenderFilename(graph, graphviz.SVG, file)

I make dot files by hand (or generated) and then pass it to this parser and it spits out an SVG., good enough for me.

imjasonh commented 2 years ago

I hacked this up: https://gist.github.com/imjasonh/ff2d293540b578efb433110d8e9c2a20

out

(green rectangles are pipeline params, red rectangles are pipeline results)

It's pretty noisy, and it's not even that complicated. I may play with it more.