Repository: tektoncd/operator (go)

Issue:
TektonResult installaiton fails if targerNamespace is different
# Expected Behavior
Tekton Result should installed and we should get:
```
 oc get TektonResult result -w
result   v0.9.1    True      
```
# Actual Behavior
Installation fails and we get:
```
 oc get TektonResult result -w
NAME     VERSION   READY   REASON
result   v0.9.1    False   Installer set not ready: Install failed with message: namespaces "tekton-pipelines" not found
```

# Steps to Reproduce the Problem

1. Install v0.70 operator
2. Instal TektonResult CR.


Pull request description:
Fix filter and Transform for TektonResult
Filter was changing the reference for Transformer which led to an incorrect manifest (the one without any transformation but only filter) being applied.

Fix #2023

* This issue introduced in #2003 and hope this PR fixes that

# Changes

<!-- 🎉🎉🎉 Thank you for the PR!!! 🎉🎉🎉 -->

<!-- Describe your changes here- ideally you can get that description straight from
your descriptive commit message(s)! -->

# Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

- [ ] Run `make test lint` before submitting a PR
- [ ] Includes [tests](https://github.com/tektoncd/community/blob/master/standards.md#principles) (if functionality changed/added)
- [ ] Includes [docs](https://github.com/tektoncd/community/blob/master/standards.md#principles) (if user facing)
- [ ] Commit messages follow [commit message best practices](https://github.com/tektoncd/community/blob/master/standards.md#commit-messages)

_See [the contribution guide](https://github.com/tektoncd/operator/blob/master/CONTRIBUTING.md) for more details._

# Release Notes

```release-note
NONE
```


Patch:
diff --git a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/buildah/buildah-task.yaml b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/buildah/buildah-task.yaml
index c99879981..0f8b44614 100644
--- a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/buildah/buildah-task.yaml
+++ b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/buildah/buildah-task.yaml
@@ -114,7 +114,7 @@ spec:
         --digestfile /tmp/image-digest $(params.IMAGE) \
         docker://$(params.IMAGE)
       cat /tmp/image-digest | tee $(results.IMAGE_DIGEST.path)
-      echo "$(params.IMAGE)" | tee $(results.IMAGE_URL.path)
+      echo -n "$(params.IMAGE)" | tee $(results.IMAGE_URL.path)
     volumeMounts:
     - name: varlibcontainers
       mountPath: /var/lib/containers
diff --git a/pkg/reconciler/kubernetes/tektonresult/filter.go b/pkg/reconciler/kubernetes/tektonresult/filter.go
index 757c54cb0..9e40794f6 100644
--- a/pkg/reconciler/kubernetes/tektonresult/filter.go
+++ b/pkg/reconciler/kubernetes/tektonresult/filter.go
@@ -26,11 +26,10 @@ const (
 	servicePostgresDB = "tekton-results-postgres-service"
 )
 
-func filterExternalDB(tr *v1alpha1.TektonResult, manifest mf.Manifest) *mf.Manifest {
+func filterExternalDB(tr *v1alpha1.TektonResult, manifest *mf.Manifest) {
 	if tr.Spec.IsExternalDB {
-		manifest = manifest.Filter(mf.Not(mf.All(mf.ByKind("StatefulSet"), mf.ByName(statefulSetDB))))
-		manifest = manifest.Filter(mf.Not(mf.All(mf.ByKind("ConfigMap"), mf.ByName(configPostgresDB))))
-		manifest = manifest.Filter(mf.Not(mf.All(mf.ByKind("Service"), mf.ByName(servicePostgresDB))))
+		*manifest = manifest.Filter(mf.Not(mf.All(mf.ByKind("StatefulSet"), mf.ByName(statefulSetDB))))
+		*manifest = manifest.Filter(mf.Not(mf.All(mf.ByKind("ConfigMap"), mf.ByName(configPostgresDB))))
+		*manifest = manifest.Filter(mf.Not(mf.All(mf.ByKind("Service"), mf.ByName(servicePostgresDB))))
 	}
-	return &manifest
 }
diff --git a/pkg/reconciler/kubernetes/tektonresult/transform.go b/pkg/reconciler/kubernetes/tektonresult/transform.go
index e0779c2a5..6df37ec4a 100644
--- a/pkg/reconciler/kubernetes/tektonresult/transform.go
+++ b/pkg/reconciler/kubernetes/tektonresult/transform.go
@@ -68,7 +68,7 @@ func (r *Reconciler) transform(ctx context.Context, manifest *mf.Manifest, comp
 	resultImgs := common.ToLowerCaseKeys(common.ImagesFromEnv(common.ResultsImagePrefix))
 
 	targetNs := comp.GetSpec().GetTargetNamespace()
-	manifest = filterExternalDB(instance, *manifest)
+	filterExternalDB(instance, manifest)
 	extra := []mf.Transformer{
 		common.InjectOperandNameLabelOverwriteExisting(v1alpha1.OperandTektoncdResults),
 		common.ApplyProxySettings,


Test patch:
diff --git a/pkg/reconciler/kubernetes/tektonresult/filter_test.go b/pkg/reconciler/kubernetes/tektonresult/filter_test.go
index 7d2bbcfc4..a8fba3d89 100644
--- a/pkg/reconciler/kubernetes/tektonresult/filter_test.go
+++ b/pkg/reconciler/kubernetes/tektonresult/filter_test.go
@@ -32,13 +32,13 @@ func Test_filterExternalDB(t *testing.T) {
 	num := len(manifest.Resources())
 	assert.Equal(t, num, 4)
 	assert.Equal(t, manifest.Resources()[0].GetName(), statefulSetDB)
-	manifest = *filterExternalDB(&v1alpha1.TektonResult{
+	filterExternalDB(&v1alpha1.TektonResult{
 		Spec: v1alpha1.TektonResultSpec{
 			ResultsAPIProperties: v1alpha1.ResultsAPIProperties{
 				IsExternalDB: true,
 			},
 		},
-	}, manifest)
+	}, &manifest)
 	num = len(manifest.Resources())
 	assert.Equal(t, num, 1)
 	assert.Equal(t, manifest.Resources()[0].GetName(), statefulSetDB+"-external")