From e6f6e6777043cafd01504249ee8888460f2b014f Mon Sep 17 00:00:00 2001 From: Richard Hagen Date: Tue, 28 Nov 2023 13:13:18 +0100 Subject: [PATCH 1/2] Allow new and old tekton spec, upgrade to k8s yaml (#98) * Changed yaml parser * Changed task parsing * Fix task validation issue * added hotfix to hanle Value objects --------- Co-authored-by: Sergey Smolnikov Co-authored-by: Richard Hagen --- go.mod | 7 +--- go.sum | 27 ------------- pkg/pipeline/prepare_pipelines.go | 48 ++++++++++++++++-------- pkg/pipeline/radix-application_config.go | 4 +- 4 files changed, 35 insertions(+), 51 deletions(-) diff --git a/go.mod b/go.mod index 7584248..a753e7e 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/equinor/radix-common v1.5.0 github.com/equinor/radix-operator v1.45.2 github.com/go-git/go-git/v5 v5.9.0 - github.com/goccy/go-yaml v1.9.5 github.com/golang/mock v1.6.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 @@ -19,6 +18,7 @@ require ( k8s.io/apimachinery v0.27.6 k8s.io/client-go v0.27.6 knative.dev/pkg v0.0.0-20231011193800-bd99f2f98be7 + sigs.k8s.io/yaml v1.3.0 ) require ( @@ -40,7 +40,6 @@ require ( github.com/emirpasic/gods v1.18.1 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect - github.com/fatih/color v1.13.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect @@ -70,8 +69,6 @@ require ( github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/magiconair/properties v1.8.7 // 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.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -112,7 +109,6 @@ require ( golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.13.0 // indirect - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/api v0.147.0 // indirect google.golang.org/appengine v1.6.7 // indirect @@ -134,5 +130,4 @@ require ( sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/secrets-store-csi-driver v1.3.3 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index c0af644..3f201a0 100644 --- a/go.sum +++ b/go.sum @@ -119,9 +119,6 @@ github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCv github.com/evanphx/json-patch v5.6.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.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= @@ -161,18 +158,9 @@ github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En 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-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/goccy/go-yaml v1.9.5 h1:Eh/+3uk9kLxG4koCX6lRMAPS1OaMSAi+FJcya0INdB0= -github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -310,22 +298,12 @@ 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/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -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.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= -github.com/mattn/go-isatty v0.0.16/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= @@ -613,7 +591,6 @@ golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -642,11 +619,9 @@ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -738,8 +713,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T 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= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= diff --git a/pkg/pipeline/prepare_pipelines.go b/pkg/pipeline/prepare_pipelines.go index 94351f7..ba70c0d 100644 --- a/pkg/pipeline/prepare_pipelines.go +++ b/pkg/pipeline/prepare_pipelines.go @@ -22,11 +22,11 @@ import ( "github.com/equinor/radix-tekton/pkg/utils/git" "github.com/equinor/radix-tekton/pkg/utils/labels" "github.com/equinor/radix-tekton/pkg/utils/radix/deployment/commithash" - "github.com/goccy/go-yaml" log "github.com/sirupsen/logrus" pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/yaml" ) var privateSshFolderMode int32 = 0444 @@ -388,6 +388,9 @@ func getPipeline(pipelineFileName string) (*pipelinev1.Pipeline, error) { if err != nil { return nil, fmt.Errorf("failed to load the pipeline from the file %s: %v", pipelineFileName, err) } + hotfixForPipelineDefaultParamsWithBrokenValue(&pipeline) + hotfixForPipelineTasksParamsWithBrokenValue(&pipeline) + log.Debugf("loaded pipeline %s", pipelineFileName) err = validation.ValidatePipeline(&pipeline) if err != nil { @@ -396,6 +399,29 @@ func getPipeline(pipelineFileName string) (*pipelinev1.Pipeline, error) { return &pipeline, nil } +func hotfixForPipelineDefaultParamsWithBrokenValue(pipeline *pipelinev1.Pipeline) { + for ip, p := range pipeline.Spec.Params { + if p.Default != nil && p.Default.ObjectVal != nil && p.Type == "string" && p.Default.ObjectVal["stringVal"] != "" { + pipeline.Spec.Params[ip].Default = &pipelinev1.ParamValue{ + Type: "string", + StringVal: p.Default.ObjectVal["stringVal"], + } + } + } +} +func hotfixForPipelineTasksParamsWithBrokenValue(pipeline *pipelinev1.Pipeline) { + for it, task := range pipeline.Spec.Tasks { + for ip, p := range task.Params { + if p.Value.ObjectVal != nil && p.Value.ObjectVal["type"] == "string" && p.Value.ObjectVal["stringVal"] != "" { + pipeline.Spec.Tasks[it].Params[ip].Value = pipelinev1.ParamValue{ + Type: "string", + StringVal: p.Value.ObjectVal["stringVal"], + } + } + } + } +} + func getTasks(pipelineFilePath string) (map[string]pipelinev1.Task, error) { pipelineFolder := filepath.Dir(pipelineFilePath) if _, err := os.Stat(pipelineFolder); os.IsNotExist(err) { @@ -406,7 +432,6 @@ func getTasks(pipelineFilePath string) (map[string]pipelinev1.Task, error) { if err != nil { return nil, fmt.Errorf("failed to scan pipeline folder %s: %v", pipelineFolder, err) } - fileMap := make(map[interface{}]interface{}) taskMap := make(map[string]pipelinev1.Task) for _, fileName := range fileNameList { if strings.EqualFold(fileName, pipelineFilePath) { @@ -419,20 +444,15 @@ func getTasks(pipelineFilePath string) (map[string]pipelinev1.Task, error) { fileData = []byte(strings.ReplaceAll(string(fileData), defaults.SubstitutionRadixBuildSecretsSource, defaults.SubstitutionRadixBuildSecretsTarget)) fileData = []byte(strings.ReplaceAll(string(fileData), defaults.SubstitutionRadixGitDeployKeySource, defaults.SubstitutionRadixGitDeployKeyTarget)) - err = yaml.Unmarshal(fileData, &fileMap) + task := pipelinev1.Task{} + err = yaml.Unmarshal(fileData, &task) if err != nil { return nil, fmt.Errorf("failed to read data from the file %s: %v", fileName, err) } - if !fileMapContainsTektonTask(fileMap) { + if !taskIsValid(&task) { log.Debugf("skip the file %s - not a Tekton task", fileName) continue } - var task pipelinev1.Task - err = yaml.Unmarshal(fileData, &task) - if err != nil { - return nil, fmt.Errorf("failed to load the task from the file %s: %v", fileData, err) - } - addGitDeployKeyVolume(&task) taskMap[task.Name] = task } @@ -451,10 +471,6 @@ func addGitDeployKeyVolume(task *pipelinev1.Task) { }) } -func fileMapContainsTektonTask(fileMap map[interface{}]interface{}) bool { - if kind, hasKind := fileMap["kind"]; !hasKind || fmt.Sprintf("%v", kind) != "Task" { - return false - } - apiVersion, hasApiVersion := fileMap["apiVersion"] - return hasApiVersion && strings.HasPrefix(fmt.Sprintf("%v", apiVersion), "tekton.dev/") +func taskIsValid(task *pipelinev1.Task) bool { + return strings.HasPrefix(task.APIVersion, "tekton.dev/") && task.Kind == "Task" && len(task.ObjectMeta.Name) > 1 } diff --git a/pkg/pipeline/radix-application_config.go b/pkg/pipeline/radix-application_config.go index 8b51b13..6f0fdcf 100644 --- a/pkg/pipeline/radix-application_config.go +++ b/pkg/pipeline/radix-application_config.go @@ -12,10 +12,10 @@ import ( "github.com/equinor/radix-operator/pkg/apis/kube" v1 "github.com/equinor/radix-operator/pkg/apis/radix/v1" "github.com/equinor/radix-tekton/pkg/utils/configmap" - "github.com/goccy/go-yaml" log "github.com/sirupsen/logrus" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/yaml" ) // ProcessRadixAppConfig Load Radix config file to a ConfigMap and create RadixApplication @@ -111,7 +111,7 @@ func (ctx *pipelineContext) setTargetEnvironmentsForPromote() error { log.Infoln("pipeline type: promote") return commonErrors.Concat(errs) } - ctx.targetEnvironments = map[string]bool{ctx.env.GetRadixDeployToEnvironment(): true} //run Tekton pipelines for the promote target environment + ctx.targetEnvironments = map[string]bool{ctx.env.GetRadixDeployToEnvironment(): true} // run Tekton pipelines for the promote target environment log.Infof("promote the deployment %s from the environment %s to %s", ctx.env.GetRadixPromoteDeployment(), ctx.env.GetRadixPromoteFromEnvironment(), ctx.env.GetRadixDeployToEnvironment()) return nil } From 48bde69299d75f61178344f69893fd84fdf39605 Mon Sep 17 00:00:00 2001 From: Richard Hagen Date: Tue, 28 Nov 2023 14:40:55 +0100 Subject: [PATCH 2/2] remove delete uncreated pipelineruns (#99) Co-authored-by: Richard Hagen --- pkg/pipeline/run_pipelines.go | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/pkg/pipeline/run_pipelines.go b/pkg/pipeline/run_pipelines.go index 969ee91..d2a5271 100644 --- a/pkg/pipeline/run_pipelines.go +++ b/pkg/pipeline/run_pipelines.go @@ -65,13 +65,7 @@ func (ctx *pipelineContext) RunPipelinesJob() error { pipelineRunMap, err := ctx.runPipelines(pipelineList.Items, namespace) if err != nil { - err = fmt.Errorf("failed to run pipelines: %w", err) - deleteErrors := ctx.deletePipelineRuns(pipelineRunMap, namespace) - if len(deleteErrors) > 0 { - deleteErrors = append(deleteErrors, err) - return commonErrors.Concat(deleteErrors) - } - return err + return fmt.Errorf("failed to run pipelines: %w", err) } err = ctx.WaitForCompletionOf(pipelineRunMap) @@ -92,20 +86,6 @@ func (ctx *pipelineContext) getTargetEnvsAsString() string { return strings.Join(envs, ", ") } -func (ctx *pipelineContext) deletePipelineRuns(pipelineRunMap map[string]*pipelinev1.PipelineRun, namespace string) []error { - var deleteErrors []error - for _, pipelineRun := range pipelineRunMap { - log.Debugf("delete the pipeline-run %s", pipelineRun.Name) - deleteErr := ctx.tektonClient.TektonV1().PipelineRuns(namespace). - Delete(context.Background(), pipelineRun.GetName(), metav1.DeleteOptions{}) - if deleteErr != nil { - log.Debugf("failed to delete the pipeline-run %s", pipelineRun.Name) - deleteErrors = append(deleteErrors, deleteErr) - } - } - return deleteErrors -} - func (ctx *pipelineContext) runPipelines(pipelines []pipelinev1.Pipeline, namespace string) (map[string]*pipelinev1.PipelineRun, error) { timestamp := time.Now().Format("20060102150405") pipelineRunMap := make(map[string]*pipelinev1.PipelineRun) @@ -233,7 +213,7 @@ func (ctx *pipelineContext) WaitForCompletionOf(pipelineRuns map[string]*pipelin return err } informer := genericInformer.Informer() - informer.AddEventHandler(cache.ResourceEventHandlerFuncs{ + _, _ = informer.AddEventHandler(cache.ResourceEventHandlerFuncs{ UpdateFunc: func(old, cur interface{}) { run, success := cur.(*pipelinev1.PipelineRun) if !success {