From 0ed67101055105de360cdc3ea1547d00526249e5 Mon Sep 17 00:00:00 2001 From: Sergiy Kulanov Date: Fri, 6 Oct 2023 17:38:00 +0300 Subject: [PATCH] refactor: Align code base to tektoncd/cli repo approach Signed-off-by: Sergiy Kulanov --- .vscode/launch.json | 2 +- cmd/graph/main.go | 119 +---------------- go.mod | 48 ++++--- go.sum | 195 ++++++++++++++++++++-------- pkg/cmd/pipeline/graph.go | 75 +++++++++++ pkg/cmd/pipeline/pipeline.go | 24 ++++ pkg/cmd/pipelinerun/graph.go | 75 +++++++++++ pkg/cmd/pipelinerun/pipelinerun.go | 24 ++++ pkg/cmd/root.go | 55 ++++++++ pkg/pipeline/pipeline.go | 21 +++ pkg/pipeline/pipeline_test.go | 81 ++++++++++++ pkg/pipelinerun/pipelinerun.go | 21 +++ pkg/pipelinerun/pipelinerun_test.go | 81 ++++++++++++ pkg/taskgraph/taskgraph.go | 70 ++++++++-- pkg/taskgraph/taskgraph_test.go | 120 +++++++++++++---- 15 files changed, 788 insertions(+), 223 deletions(-) create mode 100644 pkg/cmd/pipeline/graph.go create mode 100644 pkg/cmd/pipeline/pipeline.go create mode 100644 pkg/cmd/pipelinerun/graph.go create mode 100644 pkg/cmd/pipelinerun/pipelinerun.go create mode 100644 pkg/cmd/root.go create mode 100644 pkg/pipeline/pipeline.go create mode 100644 pkg/pipeline/pipeline_test.go create mode 100644 pkg/pipelinerun/pipelinerun.go create mode 100644 pkg/pipelinerun/pipelinerun_test.go diff --git a/.vscode/launch.json b/.vscode/launch.json index ed79898..9bd31f9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "mode": "auto", "program": "${fileDirname}", - "args": ["--namespace", "edp-delivery-tekton-dev", "--kind", "PipelineRun", "--output-format", "dot"], + "args": ["pipelinerun", "graph", "--namespace", "edp-delivery-tekton-dev", "--output-format", "mmd"], "cwd": "${workspaceFolder}" } ] diff --git a/cmd/graph/main.go b/cmd/graph/main.go index 39a051d..7b4fe9f 100644 --- a/cmd/graph/main.go +++ b/cmd/graph/main.go @@ -1,126 +1,17 @@ package main import ( - "fmt" - "log" "os" - "path/filepath" - "github.com/sergk/tkn-graph/pkg/client" - "github.com/sergk/tkn-graph/pkg/taskgraph" - "github.com/spf13/cobra" + "github.com/sergk/tkn-graph/pkg/cmd" + "github.com/tektoncd/cli/pkg/cli" ) -type Options struct { - Namespace string - TektonKind string - OutputFormat string - OutputDir string - WithTaskRef bool -} - func main() { - var options Options - - // Define the root command - rootCmd := &cobra.Command{ - Use: "tkn-graph", - Short: "Generate a graph of a Tekton object", - Long: "tkn-graph is a command-line tool for generating graphs from Tekton kind: Pipelines and kind: PipelineRuns.", - Example: ` graph --namespace my-namespace --kind Pipeline --output-format dot - graph --namespace my-namespace --kind PipelineRun --output-format puml - graph --namespace my-namespace --kind Pipeline --output-format mmd --output-dir /tmp/output`, - Run: func(cmd *cobra.Command, args []string) { - // Create the Kubernetes client - tektonClient, err := client.NewClient() - if err != nil { - log.Fatalf("Failed to create Tekton client: %v", err) - } - - // Get the namespace to use - if options.Namespace == "" { - namespace, err := tektonClient.GetNamespace() - if err != nil { - log.Fatalf("Failed to get namespace: %v", err) - } - options.Namespace = namespace - } - - // Build the list of task graphs - var graphs []*taskgraph.TaskGraph - - switch options.TektonKind { - case "Pipeline": - pipelines, err := tektonClient.GetPipelines(options.Namespace) - if err != nil { - log.Fatalf("Failed to get Pipelines: %v", err) - } - for i := range pipelines { - pipeline := &pipelines[i] - graph := taskgraph.BuildTaskGraph(pipeline.Spec.Tasks) - graph.PipelineName = pipeline.Name - graphs = append(graphs, graph) - } - - case "PipelineRun": - pipelineRuns, err := tektonClient.GetPipelineRuns(options.Namespace) - if err != nil { - log.Fatalf("Failed to get PipelineRuns: %v", err) - } - for i := range pipelineRuns { - pipelineRun := &pipelineRuns[i] - graph := taskgraph.BuildTaskGraph(pipelineRun.Status.PipelineSpec.Tasks) - graph.PipelineName = pipelineRun.Name - graphs = append(graphs, graph) - } - - default: - log.Fatalf("Invalid kind type: %s", options.TektonKind) - } - - // Generate graph for each object - for _, graph := range graphs { - // Generate the output format string - output, err := taskgraph.FormatFunc(graph, options.OutputFormat, options.WithTaskRef) - if err != nil { - log.Fatalf("Failed to generate output: %v", err) - } - - // Print or save the graph - if options.OutputDir == "" { - // Print the graph to the screen - fmt.Println(output) - } else { - // Save the graph to a file - err := os.MkdirAll(options.OutputDir, 0755) - if err != nil { - log.Fatalf("Failed to create directory %s: %v", options.OutputDir, err) - } - filename := filepath.Join(options.OutputDir, fmt.Sprintf("%s.%s", graph.PipelineName, options.OutputFormat)) - err = os.WriteFile(filename, []byte(output), 0600) - if err != nil { - log.Fatalf("Failed to write file %s: %v", filename, err) - } - } - } - }, - } - - // Define the command-line options - rootCmd.Flags().StringVar( - &options.Namespace, "namespace", "", "the Kubernetes namespace to use. Will try to get namespace from KUBECONFIG if not specified then fallback to 'default'") - rootCmd.Flags().StringVar( - &options.TektonKind, "kind", "Pipeline", "the kind of the Tekton object to parse (Pipeline or PipelineRun)") - rootCmd.Flags().StringVar( - &options.OutputFormat, "output-format", "dot", "the output format (dot - DOT, puml - PlantUML or mmd - Mermaid)") - rootCmd.Flags().StringVar( - &options.OutputDir, "output-dir", "", "the directory to save the output files. Otherwise, the output is printed to the screen") - rootCmd.Flags().BoolVar( - &options.WithTaskRef, "with-task-ref", false, "Include TaskRefName information in the output") + tp := &cli.TektonParams{} + tkn := cmd.Root(tp) - // Parse the command-line options - if err := rootCmd.Execute(); err != nil { - fmt.Println(err) + if err := tkn.Execute(); err != nil { os.Exit(1) } } diff --git a/go.mod b/go.mod index ddaeaa1..074a08a 100644 --- a/go.mod +++ b/go.mod @@ -4,58 +4,70 @@ go 1.21.1 require ( github.com/stretchr/testify v1.8.4 + github.com/tektoncd/cli v0.32.0 k8s.io/client-go v0.28.2 ) require ( contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect contrib.go.opencensus.io/exporter/prometheus v0.4.0 // indirect + github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blendle/zapdriver v1.3.1 // indirect github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/evanphx/json-patch v4.12.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect - github.com/go-kit/log v0.2.0 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect + github.com/fatih/color v1.15.0 // indirect + github.com/go-kit/log v0.2.1 // indirect + github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-openapi/swag v0.22.4 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/google/cel-go v0.17.1 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-containerregistry v0.16.1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect + github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect + github.com/google/uuid v1.3.1 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect + github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jonboulle/clockwork v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.37.0 // indirect - github.com/prometheus/procfs v0.8.0 // indirect + github.com/prometheus/client_golang v1.16.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.10.1 // indirect github.com/prometheus/statsd_exporter v0.21.0 // indirect + github.com/stoewer/go-strcase v1.2.0 // indirect + github.com/tektoncd/triggers v0.25.0 // indirect go.opencensus.io v0.24.0 // indirect - go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.10.0 // indirect + go.uber.org/atomic v1.11.0 // indirect + go.uber.org/goleak v1.2.1 // indirect + go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.25.0 // indirect - golang.org/x/exp v0.0.0-20230307190834-24139beb5833 // indirect + golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect golang.org/x/sync v0.3.0 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/api v0.138.0 // indirect - google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect google.golang.org/grpc v1.58.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.28.2 // indirect + k8s.io/apiextensions-apiserver v0.26.5 // indirect k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect knative.dev/pkg v0.0.0-20230718152110-aef227e72ead // indirect ) @@ -67,18 +79,18 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/imdario/mergo v0.3.13 // indirect + github.com/imdario/mergo v0.3.15 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/spf13/cobra v1.7.0 - github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/pflag v1.0.5 github.com/tektoncd/pipeline v0.52.0 golang.org/x/net v0.14.0 // indirect golang.org/x/oauth2 v0.11.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/term v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/term v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.31.0 // indirect diff --git a/go.sum b/go.sum index 7d392d0..29212e7 100644 --- a/go.sum +++ b/go.sum @@ -43,6 +43,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -55,7 +57,6 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -65,11 +66,21 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cloudevents/sdk-go/v2 v2.14.0 h1:Nrob4FwVgi5L4tV9lhjzZcjYqFVyJzsA56CwPaPfv6s= github.com/cloudevents/sdk-go/v2 v2.14.0/go.mod h1:xDmKfzNjM8gBvjaF8ijFjM1VYOVUEeUfapHMUX1T5To= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSkDwbkEETK84kQgEeFwDC+62k= +github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/docker/cli v24.0.6+incompatible h1:fF+XCQCgJjjQNIMjzaSmiKJSCcfcXb3TWTcc7GAneOY= +github.com/docker/cli v24.0.6+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v24.0.6+incompatible h1:hceabKCtUgDqPu+qm0NgsaXf28Ljf4/pWFL7xjWWDgE= +github.com/docker/docker v24.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= +github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -81,20 +92,24 @@ github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= +github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0 h1:7i2K3eKTos3Vc0enKCfnVcgHh2olr/MyfboYq7cAcFw= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= +github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -102,8 +117,9 @@ github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= @@ -140,11 +156,16 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= +github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= +github.com/google/cel-go v0.17.1 h1:s2151PDGy/eqpCI80/8dl4VL3xTkqI/YubXLXCFw0mw= +github.com/google/cel-go v0.17.1/go.mod h1:HXZKzB0LXqer5lHHgfWAnlYwJaQBDKMjxjulNQzhwhY= +github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= +github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -173,17 +194,23 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20230406165453-00490a63f317 h1:hFhpt7CTmR3DX+b4R19ydQFtofxT0Sv3QsKNMVQYTMQ= +github.com/google/pprof v0.0.0-20230406165453-00490a63f317/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= +github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 h1:lLT7ZLSzGLI08vc9cpd+tYmNWjdKDqyr/2L+f6U12Fk= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= +github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b h1:wDUNC2eKiL35DbLvsDhiblTUXHxcOPwQSCzi7xpQUN4= +github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b/go.mod h1:VzxiSdG6j1pi7rwGm/xYI5RbtpBgM8sARDXlvEvxlu0= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -194,11 +221,13 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= -github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= +github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= @@ -215,6 +244,8 @@ github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dv github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= +github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -226,11 +257,22 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/letsencrypt/boulder v0.0.0-20221109233200-85aa52084eaf h1:ndns1qx/5dL43g16EQkPV/i8+b3l5bYQwLeoSBe7tS8= +github.com/letsencrypt/boulder v0.0.0-20221109233200-85aa52084eaf/go.mod h1:aGkAgvWY/IUcVFfuly53REpfv5edu25oij+qHRFaraA= +github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= +github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -238,6 +280,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0= +github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -248,6 +292,12 @@ github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0= +github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/openzipkin/zipkin-go v0.3.0 h1:XtuXmOLIXLjiU2XduuWREDT0LOKtSgos/g7i7RYyoZQ= +github.com/openzipkin/zipkin-go v0.3.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ= +github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -258,29 +308,26 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.28.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= -github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/prometheus/statsd_exporter v0.21.0 h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf33yKI+pyX6T8= github.com/prometheus/statsd_exporter v0.21.0/go.mod h1:rbT83sZq2V+p73lHhPZfMc3MLCHmSHelCh9hSGYNLTQ= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -288,13 +335,19 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sigstore/sigstore v1.7.3 h1:HVVTfrMezJeLyl2xhJ8edzkrEGBa4KxjQZB4FlQ4JLU= +github.com/sigstore/sigstore v1.7.3/go.mod h1:cl0c7Dtg3MM3c13L8pqqrfrmBa0eM3POcdtBepjylmw= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= +github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= @@ -302,14 +355,35 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/tektoncd/cli v0.32.0 h1:B4hNzEBn02HBisjLghW4HHMPRw7LlhEo9p9qJAl2koA= +github.com/tektoncd/cli v0.32.0/go.mod h1:BZyW2sjs3XOak97RoXfwm4fMBSeI1EcHQ0tCY4T90Dg= github.com/tektoncd/pipeline v0.52.0 h1:R5SLf4wQYc2eCVQh1UyCNbPTDdIUQz5MisyBRngQ068= github.com/tektoncd/pipeline v0.52.0/go.mod h1:27wryvb8VIPIZ2u5evUphOPgM8Z7hGgzp00E8/3DCls= +github.com/tektoncd/triggers v0.25.0 h1:HaHZ0w8RpeIvB/7DoIZz+KhIOAVzPiFIPZOrDtvEPbM= +github.com/tektoncd/triggers v0.25.0/go.mod h1:yIxJZ4rLqZmLidFgyhR882BEy3gaW3gQkSsofP1KlRM= +github.com/theupdateframework/go-tuf v0.6.1 h1:6J89fGjQf7s0mLmTG7p7pO/MbKOg+bIXhaLyQdmbKuE= +github.com/theupdateframework/go-tuf v0.6.1/go.mod h1:LAFusuQsFNBnEyYoTuA5zZrF7iaQ4TEgBXm8lb6Vj18= +github.com/tidwall/gjson v1.12.1 h1:ikuZsLdhr8Ws0IdROXUS1Gi4v9Z4pGqpX/CvJkxvfpo= +github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/sjson v1.2.4 h1:cuiLzLnaMeBhRmEv00Lpk3tkYrcxpmbU81tAY4Dw0tc= +github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM= +github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 h1:e/5i7d4oYZ+C1wj2THlRK+oAhjeS/TRQwMfkIuet3w0= +github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399/go.mod h1:LdwHTNJT99C5fTAzDz0ud328OgXz+gierycbcIx2fRs= +github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck= +github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY= +github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk= +github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -322,14 +396,16 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc= +go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= -go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= +go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= -go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= @@ -339,6 +415,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -349,8 +427,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230307190834-24139beb5833 h1:SChBja7BCQewoTAU7IgvucQKMIXrEpFxNMs0spT3/5s= -golang.org/x/exp v0.0.0-20230307190834-24139beb5833/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -371,8 +449,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -405,8 +483,6 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -415,7 +491,6 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU= golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -466,24 +541,20 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= -golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -531,8 +602,8 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= -golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -641,6 +712,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= +gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -651,9 +724,11 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= +gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -663,8 +738,12 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/api v0.28.2 h1:9mpl5mOb6vXZvqbQmankOfPIGiudghwCoLl1EYfUZbw= k8s.io/api v0.28.2/go.mod h1:RVnJBsjU8tcMq7C3iaRSGMeaKt2TWEUXcpIt/90fjEg= +k8s.io/apiextensions-apiserver v0.26.5 h1:VJ946z9RjyCPn3qiz4Kus/UYjCRrdn1xUvEsJFvN5Yo= +k8s.io/apiextensions-apiserver v0.26.5/go.mod h1:Olsde7ZNWnyz9rsL13iXYXmL1h7kWujtKeC3yWVCDPo= k8s.io/apimachinery v0.28.2 h1:KCOJLrc6gu+wV1BYgwik4AF4vXOlVJPdiqn0yAWWwXQ= k8s.io/apimachinery v0.28.2/go.mod h1:RdzF87y/ngqk9H4z3EL2Rppv5jj95vGS/HaFXrLDApU= +k8s.io/cli-runtime v0.25.13 h1:9SUnmF++TspwNZ+zydplu7Rw39PFdA11wJiSbKgp+pY= +k8s.io/cli-runtime v0.25.13/go.mod h1:wwGCtpAMULPjQNEwBSMoWxdGHFz0+XGTQlhcyCo5vHE= k8s.io/client-go v0.28.2 h1:DNoYI1vGq0slMBN/SWKMZMw0Rq+0EQW6/AK4v9+3VeY= k8s.io/client-go v0.28.2/go.mod h1:sMkApowspLuc7omj1FOSUxSoqjr+d5Q0Yc0LOFnYFJY= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= @@ -673,13 +752,23 @@ k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5Ohx k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= k8s.io/utils v0.0.0-20230505201702-9f6742963106 h1:EObNQ3TW2D+WptiYXlApGNLVy0zm/JIBVY9i+M4wpAU= k8s.io/utils v0.0.0-20230505201702-9f6742963106/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +knative.dev/eventing v0.30.1-0.20220407170245-58865afba92c h1:5QvWwe3uB7BefHGMg6hC05YVi+zr1kGK7DVMFquqJMI= +knative.dev/eventing v0.30.1-0.20220407170245-58865afba92c/go.mod h1:6hU8ayB9weJ6cqZejOjZiHkqy1PuNA2I9T32hWj2laI= +knative.dev/networking v0.0.0-20220404212543-dde40b019aff h1:pqzWi29qb44TY+5xtc9vty4mSyUYvojXZGCp0y/91eo= +knative.dev/networking v0.0.0-20220404212543-dde40b019aff/go.mod h1:5mOmDZAOLZ4spdHWoiRpjIVCSWuA8V4NYIVtFycdSn8= knative.dev/pkg v0.0.0-20230718152110-aef227e72ead h1:2dDzorpKuVZW3Qp7TbirMMq16FbId8f6bacQFX8jXLw= knative.dev/pkg v0.0.0-20230718152110-aef227e72ead/go.mod h1:WmrwRV/P+hGHoMraAEfwg6ec+fBTf+Obu41v354Iabc= +knative.dev/serving v0.30.1-0.20220402124840-21c05dc9d9a4 h1:iRFWsFKsA5ddhi+eKZVJdf8gPBomTfjIyRAKk9Uh7Ko= +knative.dev/serving v0.30.1-0.20220402124840-21c05dc9d9a4/go.mod h1:TIKeQ1Dvn/wfmgth1fpBeYi1Qf0TPlulnwUDwOdZN50= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/kustomize/api v0.12.1 h1:7YM7gW3kYBwtKvoY216ZzY+8hM+lV53LUayghNRJ0vM= +sigs.k8s.io/kustomize/api v0.12.1/go.mod h1:y3JUhimkZkR6sbLNwfJHxvo1TCLwuwm14sCYnkH6S1s= +sigs.k8s.io/kustomize/kyaml v0.13.9 h1:Qz53EAaFFANyNgyOEJbT/yoIHygK40/ZcvU3rgry2Tk= +sigs.k8s.io/kustomize/kyaml v0.13.9/go.mod h1:QsRbD0/KcU+wdk0/L0fIp2KLnohkVzs6fQ85/nOXac4= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/pkg/cmd/pipeline/graph.go b/pkg/cmd/pipeline/graph.go new file mode 100644 index 0000000..f1d0634 --- /dev/null +++ b/pkg/cmd/pipeline/graph.go @@ -0,0 +1,75 @@ +package pipeline + +import ( + "fmt" + + pipelinepkg "github.com/sergk/tkn-graph/pkg/pipeline" + "github.com/sergk/tkn-graph/pkg/taskgraph" + "github.com/spf13/cobra" + "github.com/tektoncd/cli/pkg/cli" + "github.com/tektoncd/cli/pkg/flags" +) + +type graphOptions struct { + OutputFormat string + OutputDir string + WithTaskRef bool +} + +func graphCommand(p cli.Params) *cobra.Command { + + opts := &graphOptions{} + // Define the root command + c := &cobra.Command{ + Use: "graph", + Aliases: []string{"g"}, + Short: "Generates Graph", + Annotations: map[string]string{ + "commandType": "main", + }, + SilenceUsage: true, + Args: func(cmd *cobra.Command, args []string) error { + // Add global args to the args list + if err := flags.InitParams(p, cmd); err != nil { + return err + } + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + cs, err := p.Clients() + if err != nil { + return err + } + + // Build the list of task graphs + var graphs []*taskgraph.TaskGraph + + pipelines, err := pipelinepkg.GetAllPipelines(cs, p.Namespace()) + if err != nil { + return fmt.Errorf("failed to get Pipelines: %w", err) + } + + for i := range pipelines { + pipeline := &pipelines[i] + graph := taskgraph.BuildTaskGraph(pipeline.Spec.Tasks) + graph.PipelineName = pipeline.Name + graphs = append(graphs, graph) + } + + if err = taskgraph.PrintAllGraphs(graphs, opts.OutputFormat, opts.WithTaskRef); err != nil { + return fmt.Errorf("failed to print graph: %w", err) + } + return nil + }, + } + + // Define the command-line opts + c.Flags().StringVar( + &opts.OutputFormat, "output-format", "dot", "the output format (dot - DOT, puml - PlantUML or mmd - Mermaid)") + c.Flags().StringVar( + &opts.OutputDir, "output-dir", "", "the directory to save the output files. Otherwise, the output is printed to the screen") + c.Flags().BoolVar( + &opts.WithTaskRef, "with-task-ref", false, "Include TaskRefName information in the output") + + return c +} diff --git a/pkg/cmd/pipeline/pipeline.go b/pkg/cmd/pipeline/pipeline.go new file mode 100644 index 0000000..a1f281f --- /dev/null +++ b/pkg/cmd/pipeline/pipeline.go @@ -0,0 +1,24 @@ +package pipeline + +import ( + "github.com/spf13/cobra" + "github.com/tektoncd/cli/pkg/cli" + "github.com/tektoncd/cli/pkg/flags" +) + +func Command(p cli.Params) *cobra.Command { + cmd := &cobra.Command{ + Use: "pipeline", + Aliases: []string{"p", "pipelines"}, + Short: "Graph pipelines", + Annotations: map[string]string{ + "commandType": "main", + }, + } + + flags.AddTektonOptions(cmd) + cmd.AddCommand( + graphCommand(p), + ) + return cmd +} diff --git a/pkg/cmd/pipelinerun/graph.go b/pkg/cmd/pipelinerun/graph.go new file mode 100644 index 0000000..64fff5d --- /dev/null +++ b/pkg/cmd/pipelinerun/graph.go @@ -0,0 +1,75 @@ +package pipelinerun + +import ( + "fmt" + + pipelinerunpkg "github.com/sergk/tkn-graph/pkg/pipelinerun" + "github.com/sergk/tkn-graph/pkg/taskgraph" + "github.com/spf13/cobra" + "github.com/tektoncd/cli/pkg/cli" + "github.com/tektoncd/cli/pkg/flags" +) + +type graphOptions struct { + OutputFormat string + OutputDir string + WithTaskRef bool +} + +func graphCommand(p cli.Params) *cobra.Command { + + opts := &graphOptions{} + // Define the root command + c := &cobra.Command{ + Use: "graph", + Aliases: []string{"g"}, + Short: "Generates Graph", + Annotations: map[string]string{ + "commandType": "main", + }, + SilenceUsage: true, + Args: func(cmd *cobra.Command, args []string) error { + // Add global args to the args list + if err := flags.InitParams(p, cmd); err != nil { + return err + } + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + cs, err := p.Clients() + if err != nil { + return err + } + + // Build the list of task graphs + var graphs []*taskgraph.TaskGraph + + pipelineruns, err := pipelinerunpkg.GetAllPipelineRuns(cs, p.Namespace()) + if err != nil { + return fmt.Errorf("failed to get Pipelines: %w", err) + } + + for i := range pipelineruns { + pipelineRun := &pipelineruns[i] + graph := taskgraph.BuildTaskGraph(pipelineRun.Status.PipelineSpec.Tasks) + graph.PipelineName = pipelineRun.Name + graphs = append(graphs, graph) + } + + if err = taskgraph.PrintAllGraphs(graphs, opts.OutputFormat, opts.WithTaskRef); err != nil { + return fmt.Errorf("failed to print graph: %w", err) + } + return nil + }, + } + + // Define the command-line opts + c.Flags().StringVar( + &opts.OutputFormat, "output-format", "dot", "the output format (dot - DOT, puml - PlantUML or mmd - Mermaid)") + c.Flags().StringVar( + &opts.OutputDir, "output-dir", "", "the directory to save the output files. Otherwise, the output is printed to the screen") + c.Flags().BoolVar( + &opts.WithTaskRef, "with-task-ref", false, "Include TaskRefName information in the output") + + return c +} diff --git a/pkg/cmd/pipelinerun/pipelinerun.go b/pkg/cmd/pipelinerun/pipelinerun.go new file mode 100644 index 0000000..c5379af --- /dev/null +++ b/pkg/cmd/pipelinerun/pipelinerun.go @@ -0,0 +1,24 @@ +package pipelinerun + +import ( + "github.com/spf13/cobra" + "github.com/tektoncd/cli/pkg/cli" + "github.com/tektoncd/cli/pkg/flags" +) + +func Command(p cli.Params) *cobra.Command { + cmd := &cobra.Command{ + Use: "pipelinerun", + Aliases: []string{"pr", "pipelineruns"}, + Short: "Graph PipelineRuns", + Annotations: map[string]string{ + "commandType": "main", + }, + } + + flags.AddTektonOptions(cmd) + cmd.AddCommand( + graphCommand(p), + ) + return cmd +} diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go new file mode 100644 index 0000000..a4b9331 --- /dev/null +++ b/pkg/cmd/root.go @@ -0,0 +1,55 @@ +package cmd + +import ( + "os" + + "github.com/sergk/tkn-graph/pkg/cmd/pipeline" + "github.com/sergk/tkn-graph/pkg/cmd/pipelinerun" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + "github.com/tektoncd/cli/pkg/cli" +) + +const usageTemplate = `Usage:{{if .Runnable}} + {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} + {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}} +Aliases: + {{.NameAndAliases}}{{end}}{{if .HasExample}} + +Examples: +{{.Example}}{{end}}{{if .HasAvailableSubCommands}} + +Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}} + {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}} + +Flags: +{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}} + +Global Flags: +{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}} + +Additional help topics:{{range .Commands}}{{if .IsHelpCommand}} + {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}} + +Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}} +` + +func Root(p cli.Params) *cobra.Command { + // Reset CommandLine so we don't get the flags from the libraries, i.e: + pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ExitOnError) + + cmd := &cobra.Command{ + Use: "tkn-graph", + Short: "Generate a graph of a Tekton Pipelines", + Long: "tkn-graph is a command-line tool for generating graphs from Tekton Pipelines and PipelineRuns.", + SilenceUsage: true, + } + cmd.SetUsageTemplate(usageTemplate) + + cmd.AddCommand( + pipeline.Command(p), + pipelinerun.Command(p), + ) + + return cmd +} diff --git a/pkg/pipeline/pipeline.go b/pkg/pipeline/pipeline.go new file mode 100644 index 0000000..b15469e --- /dev/null +++ b/pkg/pipeline/pipeline.go @@ -0,0 +1,21 @@ +package pipeline + +import ( + "context" + "fmt" + + "github.com/tektoncd/cli/pkg/cli" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func GetAllPipelines(c *cli.Clients, ns string) ([]v1.Pipeline, error) { + pipelines, err := c.Tekton.TektonV1().Pipelines(ns).List(context.TODO(), metav1.ListOptions{}) + if err != nil { + return nil, fmt.Errorf("failed to get Pipelines: %w", err) + } + if len(pipelines.Items) == 0 { + return nil, fmt.Errorf("no Pipelines found in namespace %s", ns) + } + return pipelines.Items, nil +} diff --git a/pkg/pipeline/pipeline_test.go b/pkg/pipeline/pipeline_test.go new file mode 100644 index 0000000..9e3d981 --- /dev/null +++ b/pkg/pipeline/pipeline_test.go @@ -0,0 +1,81 @@ +package pipeline + +import ( + "context" + "testing" + + "github.com/tektoncd/cli/pkg/cli" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" + fakeclient "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/fake" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + namespace = "my-namespace" +) + +func TestGetAllPipelines(t *testing.T) { + fakeClient := fakeclient.NewSimpleClientset() + + // Define the expected pipeline runs + expectedPipelines := []v1.Pipeline{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: "pipeline-1", + Namespace: namespace, + }, + }, + { + ObjectMeta: metav1.ObjectMeta{ + Name: "pipeline-2", + Namespace: namespace, + }, + }, + } + + // Create the fake pipeline runs + for _, pr := range expectedPipelines { + _, err := fakeClient.TektonV1().Pipelines(namespace).Create(context.TODO(), &pr, metav1.CreateOptions{}) + if err != nil { + t.Fatalf("Error creating fake pipeline run: %v", err) + } + } + + c := &cli.Clients{ + Tekton: fakeClient, + } + + // Get the pipeline runs + pipelines, err := GetAllPipelines(c, namespace) + if err != nil { + t.Fatalf("Error getting pipeline runs: %v", err) + } + + // Check that the pipeline runs are as expected + if len(pipelines) != len(expectedPipelines) { + t.Fatalf("Expected %d pipeline runs, got %d", len(expectedPipelines), len(pipelines)) + } + for i, pr := range pipelines { + if pr.Name != expectedPipelines[i].Name { + t.Fatalf("Expected pipeline run %d to have name %s, got %s", i, expectedPipelines[i].Name, pr.Name) + } + } + +} + +func TestGetAllPipelineWithError(t *testing.T) { + fakeClient := fakeclient.NewSimpleClientset() + + c := &cli.Clients{ + Tekton: fakeClient, + } + + // Get the pipeline runs + _, err := GetAllPipelines(c, namespace) + if err == nil { + t.Fatal("GetAllPipelines did not return an error, expected an error") + } + if err.Error() != "no Pipelines found in namespace my-namespace" { + t.Fatalf("Expected error message to be 'no Pipelines found in namespace my-namespace', got %s", err.Error()) + } +} diff --git a/pkg/pipelinerun/pipelinerun.go b/pkg/pipelinerun/pipelinerun.go new file mode 100644 index 0000000..17ef228 --- /dev/null +++ b/pkg/pipelinerun/pipelinerun.go @@ -0,0 +1,21 @@ +package pipelinerun + +import ( + "context" + "fmt" + + "github.com/tektoncd/cli/pkg/cli" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func GetAllPipelineRuns(c *cli.Clients, ns string) ([]v1.PipelineRun, error) { + pipelineruns, err := c.Tekton.TektonV1().PipelineRuns(ns).List(context.TODO(), metav1.ListOptions{}) + if err != nil { + return nil, fmt.Errorf("failed to get PipelineRuns: %w", err) + } + if len(pipelineruns.Items) == 0 { + return nil, fmt.Errorf("no PipelineRuns found in namespace %s", ns) + } + return pipelineruns.Items, nil +} diff --git a/pkg/pipelinerun/pipelinerun_test.go b/pkg/pipelinerun/pipelinerun_test.go new file mode 100644 index 0000000..b5ba75c --- /dev/null +++ b/pkg/pipelinerun/pipelinerun_test.go @@ -0,0 +1,81 @@ +package pipelinerun + +import ( + "context" + "testing" + + "github.com/tektoncd/cli/pkg/cli" + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" + fakeclient "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/fake" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + namespace = "my-namespace" +) + +func TestGetAllPipelineRuns(t *testing.T) { + fakeClient := fakeclient.NewSimpleClientset() + + // Define the expected pipeline runs + expectedPipelineRuns := []v1.PipelineRun{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: "pipeline-1", + Namespace: namespace, + }, + }, + { + ObjectMeta: metav1.ObjectMeta{ + Name: "pipeline-2", + Namespace: namespace, + }, + }, + } + + // Create the fake pipeline runs + for _, pr := range expectedPipelineRuns { + _, err := fakeClient.TektonV1().PipelineRuns(namespace).Create(context.TODO(), &pr, metav1.CreateOptions{}) + if err != nil { + t.Fatalf("Error creating fake pipelineRun run: %v", err) + } + } + + c := &cli.Clients{ + Tekton: fakeClient, + } + + // Get the pipeline runs + pipelineRuns, err := GetAllPipelineRuns(c, namespace) + if err != nil { + t.Fatalf("Error getting pipeline runs: %v", err) + } + + // Check that the pipeline runs are as expected + if len(pipelineRuns) != len(expectedPipelineRuns) { + t.Fatalf("Expected %d pipelineRuns, got %d", len(expectedPipelineRuns), len(pipelineRuns)) + } + for i, pr := range pipelineRuns { + if pr.Name != expectedPipelineRuns[i].Name { + t.Fatalf("Expected pipelineRuns %d to have name %s, got %s", i, expectedPipelineRuns[i].Name, pr.Name) + } + } + +} + +func TestGetAllPipelineRunsWithError(t *testing.T) { + fakeClient := fakeclient.NewSimpleClientset() + + c := &cli.Clients{ + Tekton: fakeClient, + } + + // Get the pipeline runs + _, err := GetAllPipelineRuns(c, namespace) + if err == nil { + t.Fatal("GetAllPipelineRuns did not return an error, expected an error") + } + if err.Error() != "no PipelineRuns found in namespace my-namespace" { + t.Fatalf("Expected error message to be 'no PipelineRuns found in namespace my-namespace', got %s", err.Error()) + } +} diff --git a/pkg/taskgraph/taskgraph.go b/pkg/taskgraph/taskgraph.go index 1569b3c..d49600f 100644 --- a/pkg/taskgraph/taskgraph.go +++ b/pkg/taskgraph/taskgraph.go @@ -3,6 +3,8 @@ package taskgraph import ( "bytes" "fmt" + "os" + "path/filepath" "strings" v1pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" @@ -26,7 +28,7 @@ type DOT 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 formatFuncType func(graph *TaskGraph, format string, withTaskRef bool) (string, error) // In the case where the order of tasks is arbitrary, it is necessary to create all the nodes first // and then add the dependencies in a separate loop (since dependencies doesn't exist in TaskRef). @@ -69,8 +71,12 @@ func (g *TaskGraph) ToDOT() *DOT { } for _, node := range g.Nodes { + if len(node.Dependencies) == 0 { + // "end" is the special node that represents the end of the pipeline + dot.Edges = append(dot.Edges, fmt.Sprintf(" \"%s\" -> \"end\"", node.Name)) + } for _, dep := range node.Dependencies { - dot.Edges = append(dot.Edges, fmt.Sprintf(" \"%s\" -> \"%s\"", dep.Name, node.Name)) + dot.Edges = append(dot.Edges, fmt.Sprintf(" \"%s\" -> \"%s\"", node.Name, dep.Name)) } } @@ -85,8 +91,12 @@ func (g *TaskGraph) ToDOTWithTaskRef() *DOT { } for _, node := range g.Nodes { + if len(node.Dependencies) == 0 { + // "end" is the special node that represents the end of the pipeline + dot.Edges = append(dot.Edges, fmt.Sprintf(" \"%s\n(%s)\" -> \"end\"", node.Name, node.TaskRefName)) + } for _, dep := range node.Dependencies { - dot.Edges = append(dot.Edges, fmt.Sprintf(" \"%s\n(%s)\" -> \"%s\n(%s)\"", dep.Name, dep.TaskRefName, node.Name, node.TaskRefName)) + dot.Edges = append(dot.Edges, fmt.Sprintf(" \"%s\n(%s)\" -> \"%s\n(%s)\"", node.Name, node.TaskRefName, dep.Name, dep.TaskRefName)) } } @@ -96,7 +106,7 @@ func (g *TaskGraph) ToDOTWithTaskRef() *DOT { // String converts a DOT graph to a string func (d *DOT) String() string { var buf bytes.Buffer - buf.WriteString(fmt.Sprintf("%s {\n labelloc=\"t\"\n label=\"%s\"\n", d.Format, d.Name)) + buf.WriteString(fmt.Sprintf("%s {\n labelloc=\"t\"\n label=\"%s\"\n end [shape=\"point\" width=0.2]\n", d.Format, d.Name)) for _, edge := range d.Edges { buf.WriteString(fmt.Sprintf("%s\n", edge)) } @@ -112,12 +122,12 @@ func (g *TaskGraph) ToPlantUML() string { nodeName := strings.ReplaceAll(node.Name, "-", "_") // the root node is the one with no dependencies and that task starts the execution immediately if len(node.Dependencies) == 0 { - plantuml += fmt.Sprintf("[*] --> %s\n", nodeName) + plantuml += fmt.Sprintf("%s --> [*]\n", nodeName) } for _, dep := range node.Dependencies { // Replace dashes with underscores in node names because PlantUML doesn't like dashes depName := strings.ReplaceAll(dep.Name, "-", "_") - plantuml += fmt.Sprintf("%s <-down- %s\n", nodeName, depName) + plantuml += fmt.Sprintf("%s -down-> %s\n", nodeName, depName) } } plantuml += "\n@enduml\n" @@ -136,12 +146,12 @@ func (g *TaskGraph) ToPlantUMLWithTaskRef() string { nodeName := strings.ReplaceAll(node.Name, "-", "_") // the root node is the one with no dependencies and that task starts the execution immediately if len(node.Dependencies) == 0 { - plantuml += fmt.Sprintf("[*] --> %s\n", nodeName) + plantuml += fmt.Sprintf("%s --> [*]\n", nodeName) } for _, dep := range node.Dependencies { // Replace dashes with underscores in node names because PlantUML doesn't like dashes depName := strings.ReplaceAll(dep.Name, "-", "_") - plantuml += fmt.Sprintf("%s <-down- %s\n", nodeName, depName) + plantuml += fmt.Sprintf("%s -down-> %s\n", nodeName, depName) } // Add the node to the uniqueNodes map if it doesn't already exist if _, ok := uniqueNodes[nodeName]; !ok { @@ -161,8 +171,11 @@ func (g *TaskGraph) ToPlantUMLWithTaskRef() string { func (g *TaskGraph) ToMermaid() string { mermaid := fmt.Sprintf("---\ntitle: %s\n---\nflowchart TD\n", g.PipelineName) for _, node := range g.Nodes { + if len(node.Dependencies) == 0 { + mermaid += fmt.Sprintf(" %s --> id([fa:fa-circle])\n", node.Name) + } for _, dep := range node.Dependencies { - mermaid += fmt.Sprintf(" %s --> %s\n", dep.Name, node.Name) + mermaid += fmt.Sprintf(" %s --> %s\n", node.Name, dep.Name) } } return mermaid @@ -172,15 +185,18 @@ func (g *TaskGraph) ToMermaid() string { func (g *TaskGraph) ToMermaidWithTaskRef() string { mermaid := fmt.Sprintf("---\ntitle: %s\n---\nflowchart TD\n", g.PipelineName) for _, node := range g.Nodes { + if len(node.Dependencies) == 0 { + mermaid += fmt.Sprintf(" %s(\"%s\n (%s)\") --> id([fa:fa-circle])\n", node.Name, node.Name, node.TaskRefName) + } for _, dep := range node.Dependencies { - mermaid += fmt.Sprintf(" %s(\"%s\n (%s)\") --> %s(\"%s\n (%s)\")\n", dep.Name, dep.Name, dep.TaskRefName, node.Name, node.Name, node.TaskRefName) + mermaid += fmt.Sprintf(" %s(\"%s\n (%s)\") --> %s(\"%s\n (%s)\")\n", node.Name, node.Name, node.TaskRefName, dep.Name, dep.Name, dep.TaskRefName) } } return mermaid } // 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 formatFuncType = func(graph *TaskGraph, format string, withTaskRef bool) (string, error) { switch strings.ToLower(format) { case "dot": if withTaskRef { @@ -201,3 +217,35 @@ var FormatFunc FormatFuncType = func(graph *TaskGraph, format string, withTaskRe return "", fmt.Errorf("Invalid output format: %s", format) } } + +// Function that prints graph to stdout +func PrintAllGraphs(graphs []*TaskGraph, outputFormat string, withTaskRef bool) error { + for _, graph := range graphs { + output, err := formatFunc(graph, outputFormat, withTaskRef) + if err != nil { + return fmt.Errorf("Failed to generate output: %w", err) + } + fmt.Println(output) + } + return nil +} + +// Function that writes graph to file +func WriteAllGraphs(graphs []*TaskGraph, outputFormat string, outputDir string, withTaskRef bool) error { + err := os.MkdirAll(outputDir, 0755) + if err != nil { + return fmt.Errorf("Failed to create directory %s: %w", outputDir, err) + } + for _, graph := range graphs { + output, err := formatFunc(graph, outputFormat, withTaskRef) + if err != nil { + return fmt.Errorf("Failed to generate output: %w", err) + } + filename := filepath.Join(outputDir, fmt.Sprintf("%s.%s", graph.PipelineName, outputFormat)) + err = os.WriteFile(filename, []byte(output), 0600) + if err != nil { + return fmt.Errorf("Failed to write file %s: %w", filename, err) + } + } + return nil +} diff --git a/pkg/taskgraph/taskgraph_test.go b/pkg/taskgraph/taskgraph_test.go index ff3845e..0a61faa 100644 --- a/pkg/taskgraph/taskgraph_test.go +++ b/pkg/taskgraph/taskgraph_test.go @@ -33,6 +33,13 @@ func getTestTasks() []v1pipeline.PipelineTask { Name: "taskRef3", }, }, + // we can have task without any dependencies + { + Name: "task4", + TaskRef: &v1pipeline.TaskRef{ + Name: "taskRef4", + }, + }, } } @@ -41,7 +48,7 @@ func TestBuildTaskGraph(t *testing.T) { graph := BuildTaskGraph(getTestTasks()) // Assert that the graph has the correct number of nodes - assert.Equal(t, 3, len(graph.Nodes)) + assert.Equal(t, 4, len(graph.Nodes)) // Assert that the nodes have the correct names and task references assert.Equal(t, "taskRef1", graph.Nodes["task1"].TaskRefName) @@ -66,9 +73,11 @@ func TestTaskGraphToDOT(t *testing.T) { dot := graph.ToDOT() assert.Equal(t, "digraph", dot.Format) assert.Equal(t, testPipelineName, dot.Name) - assert.Contains(t, dot.Edges, " \"task1\" -> \"task2\"") - assert.Contains(t, dot.Edges, " \"task1\" -> \"task3\"") - assert.Contains(t, dot.Edges, " \"task2\" -> \"task3\"") + assert.Contains(t, dot.Edges, " \"task2\" -> \"task1\"") + assert.Contains(t, dot.Edges, " \"task3\" -> \"task1\"") + assert.Contains(t, dot.Edges, " \"task3\" -> \"task2\"") + assert.Contains(t, dot.Edges, " \"task1\" -> \"end\"") + assert.Contains(t, dot.Edges, " \"task4\" -> \"end\"") } func TestTaskGraphToDOTWithTaskRef(t *testing.T) { @@ -80,9 +89,11 @@ func TestTaskGraphToDOTWithTaskRef(t *testing.T) { dot := graph.ToDOTWithTaskRef() assert.Equal(t, "digraph", dot.Format) assert.Equal(t, testPipelineName, dot.Name) - assert.Contains(t, dot.Edges, " \"task1\n(taskRef1)\" -> \"task2\n(taskRef2)\"") - assert.Contains(t, dot.Edges, " \"task1\n(taskRef1)\" -> \"task3\n(taskRef3)\"") - assert.Contains(t, dot.Edges, " \"task2\n(taskRef2)\" -> \"task3\n(taskRef3)\"") + assert.Contains(t, dot.Edges, " \"task2\n(taskRef2)\" -> \"task1\n(taskRef1)\"") + assert.Contains(t, dot.Edges, " \"task3\n(taskRef3)\" -> \"task1\n(taskRef1)\"") + assert.Contains(t, dot.Edges, " \"task3\n(taskRef3)\" -> \"task2\n(taskRef2)\"") + assert.Contains(t, dot.Edges, " \"task1\n(taskRef1)\" -> \"end\"") + assert.Contains(t, dot.Edges, " \"task4\n(taskRef4)\" -> \"end\"") } func TestDOTString(t *testing.T) { @@ -101,7 +112,7 @@ func TestDOTString(t *testing.T) { } // Test the String method - expected := "digraph {\n labelloc=\"t\"\n label=\"test-pipeline\"\n \"task1\" -> \"task2\"\n \"task1\" -> \"task3\"\n \"task2\" -> \"task3\"\n}\n" + expected := "digraph {\n labelloc=\"t\"\n label=\"test-pipeline\"\n end [shape=\"point\" width=0.2]\n \"task1\" -> \"task2\"\n \"task1\" -> \"task3\"\n \"task2\" -> \"task3\"\n}\n" assert.Equal(t, expected, dot.String()) } @@ -113,10 +124,11 @@ func TestTaskGraphToPlantUML(t *testing.T) { // Test the ToPlantUML method plantuml := graph.ToPlantUML() assert.Contains(t, plantuml, "@startuml\nhide empty description\ntitle test-pipeline\n\n") - assert.Contains(t, plantuml, "[*] --> task1\n") - assert.Contains(t, plantuml, "task2 <-down- task1\n") - assert.Contains(t, plantuml, "task3 <-down- task1\n") - assert.Contains(t, plantuml, "task3 <-down- task2\n") + assert.Contains(t, plantuml, "task1 --> [*]\n") + assert.Contains(t, plantuml, "task4 --> [*]\n") + assert.Contains(t, plantuml, "task2 -down-> task1\n") + assert.Contains(t, plantuml, "task3 -down-> task1\n") + assert.Contains(t, plantuml, "task3 -down-> task2\n") assert.Contains(t, plantuml, "\n@enduml\n") } @@ -128,10 +140,11 @@ func TestTaskGraphToPlantUMLWithTaskRef(t *testing.T) { // Test the ToPlantUMLWithTaskRef method plantuml := graph.ToPlantUMLWithTaskRef() assert.Contains(t, plantuml, "@startuml\nhide empty description\ntitle test-pipeline\n\n") - assert.Contains(t, plantuml, "[*] --> task1") - assert.Contains(t, plantuml, "task2 <-down- task1") - assert.Contains(t, plantuml, "task3 <-down- task1") - assert.Contains(t, plantuml, "task3 <-down- task2") + assert.Contains(t, plantuml, "task1 --> [*]") + assert.Contains(t, plantuml, "task4 --> [*]") + assert.Contains(t, plantuml, "task2 -down-> task1") + assert.Contains(t, plantuml, "task3 -down-> task1") + assert.Contains(t, plantuml, "task3 -down-> task2") assert.Contains(t, plantuml, "task1: taskRef1\n") assert.Contains(t, plantuml, "task2: taskRef2\n") assert.Contains(t, plantuml, "task3: taskRef3\n") @@ -146,9 +159,11 @@ func TestTaskGraphToMermaid(t *testing.T) { // Test the ToMermaid method mermaid := graph.ToMermaid() assert.Contains(t, mermaid, "---\ntitle: test-pipeline\n---\nflowchart TD\n") - assert.Contains(t, mermaid, " task1 --> task2\n") - assert.Contains(t, mermaid, " task1 --> task3\n") - assert.Contains(t, mermaid, " task2 --> task3\n") + assert.Contains(t, mermaid, " task2 --> task1\n") + assert.Contains(t, mermaid, " task3 --> task1\n") + assert.Contains(t, mermaid, " task3 --> task2\n") + assert.Contains(t, mermaid, " task1 --> id([fa:fa-circle])\n") + assert.Contains(t, mermaid, " task4 --> id([fa:fa-circle])\n") } func TestTaskGraphToMermaidWithTaskRef(t *testing.T) { @@ -159,9 +174,11 @@ func TestTaskGraphToMermaidWithTaskRef(t *testing.T) { // Test the ToMermaidWithTaskRef method mermaid := graph.ToMermaidWithTaskRef() assert.Contains(t, mermaid, "---\ntitle: test-pipeline\n---\nflowchart TD\n") - assert.Contains(t, mermaid, " task1(\"task1\n (taskRef1)\") --> task2(\"task2\n (taskRef2)\")\n") - assert.Contains(t, mermaid, " task1(\"task1\n (taskRef1)\") --> task3(\"task3\n (taskRef3)\")\n") - assert.Contains(t, mermaid, " task2(\"task2\n (taskRef2)\") --> task3(\"task3\n (taskRef3)\")\n") + assert.Contains(t, mermaid, " task2(\"task2\n (taskRef2)\") --> task1(\"task1\n (taskRef1)\")\n") + assert.Contains(t, mermaid, " task3(\"task3\n (taskRef3)\") --> task1(\"task1\n (taskRef1)\")\n") + assert.Contains(t, mermaid, " task3(\"task3\n (taskRef3)\") --> task2(\"task2\n (taskRef2)\")\n") + assert.Contains(t, mermaid, " task1(\"task1\n (taskRef1)\") --> id([fa:fa-circle])\n") + assert.Contains(t, mermaid, " task4(\"task4\n (taskRef4)\") --> id([fa:fa-circle])\n") } func TestFormatFunc(t *testing.T) { @@ -170,20 +187,71 @@ func TestFormatFunc(t *testing.T) { graph.PipelineName = testPipelineName // Test the FormatFunc method - dot, err := FormatFunc(graph, "dot", false) + dot, err := formatFunc(graph, "dot", false) assert.NoError(t, err) assert.NotEmpty(t, dot) - puml, err := FormatFunc(graph, "puml", false) + puml, err := formatFunc(graph, "puml", false) assert.NoError(t, err) assert.NotEmpty(t, puml) - mmd, err := FormatFunc(graph, "mmd", false) + mmd, err := formatFunc(graph, "mmd", false) assert.NoError(t, err) assert.NotEmpty(t, mmd) - invalid, err := FormatFunc(graph, "invalid", false) + invalid, err := formatFunc(graph, "invalid", false) assert.Error(t, err) assert.Empty(t, invalid) assert.Equal(t, "Invalid output format: invalid", err.Error()) } + +func TestPrintAllGraphs(t *testing.T) { + // Create a test graph + testGraph := &TaskGraph{ + Nodes: map[string]*TaskNode{ + "task1": { + Name: "task1", + TaskRefName: "taskRef1", + Dependencies: []*TaskNode{ + { + Name: "task2", + TaskRefName: "taskRef2", + }, + }, + }, + "task2": { + Name: "task2", + TaskRefName: "taskRef2", + Dependencies: []*TaskNode{ + { + Name: "task3", + TaskRefName: "taskRef3", + }, + }, + }, + }, + } + + // Create a test output format and withTaskRef value + testOutputFormat := "dot" + testWithTaskRef := true + + // Test the PrintAllGraphs method + err := PrintAllGraphs([]*TaskGraph{testGraph}, testOutputFormat, testWithTaskRef) + assert.NoError(t, err) +} + +func TestPrintAllGraphsWithUnsupportedFormat(t *testing.T) { + // Create a test graph + testGraph := &TaskGraph{} + + // Create a test output format and withTaskRef value + testOutputFormat := "FAIL" + testWithTaskRef := true + + // Test the PrintAllGraphs method + err := PrintAllGraphs([]*TaskGraph{testGraph}, testOutputFormat, testWithTaskRef) + assert.Error(t, err) + // contains error message + assert.Contains(t, err.Error(), "Invalid output format: FAIL") +}