github.com/redhat-appstudio/e2e-tests@v0.0.0-20240520140907-9709f6f59323/pkg/utils/tekton/pipeline_ref.go (about) 1 package tekton 2 3 import ( 4 pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" 5 ) 6 7 // GetPipelineNameAndBundleRef returns the pipeline name and bundle reference from a pipelineRef 8 // https://tekton.dev/docs/pipelines/pipelineruns/#tekton-bundles 9 func GetPipelineNameAndBundleRef(pipelineRef *pipeline.PipelineRef) (string, string) { 10 var name string 11 var bundleRef string 12 13 // Prefer the v1 style 14 if pipelineRef.Resolver != "" { 15 for _, param := range pipelineRef.Params { 16 switch param.Name { 17 case "name": 18 name = param.Value.StringVal 19 case "bundle": 20 bundleRef = param.Value.StringVal 21 } 22 } 23 } 24 25 return name, bundleRef 26 } 27 28 func NewBundleResolverPipelineRef(name string, bundleRef string) *pipeline.PipelineRef { 29 return &pipeline.PipelineRef{ 30 ResolverRef: pipeline.ResolverRef{ 31 Resolver: "bundles", 32 Params: []pipeline.Param{ 33 {Name: "name", Value: pipeline.ParamValue{StringVal: name, Type: pipeline.ParamTypeString}}, 34 {Name: "bundle", Value: pipeline.ParamValue{StringVal: bundleRef, Type: pipeline.ParamTypeString}}, 35 {Name: "kind", Value: pipeline.ParamValue{StringVal: "pipeline", Type: pipeline.ParamTypeString}}, 36 }, 37 }, 38 } 39 }