Repository: tektoncd/operator
Pull request #1090 (2022-10-06 06:22:28)

removing printing of env-vars from S2i tasks
# 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:

- [x] Run `make test lint` before submitting a PR
- [x] Includes [tests](https://github.com/tektoncd/community/blob/master/standards.md#principles) (if functionality changed/added)
- [x] Includes [docs](https://github.com/tektoncd/community/blob/master/standards.md#principles) (if user facing)
- [x] 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

<!--
Describe any user facing changes here, or delete this block.

Examples of user facing changes:
- API changes
- Bug fixes
- Any changes in behavior
- Changes requiring upgrade notices or deprecation warnings

For pull requests with a release note:

```release-note
Your release note here
```

For pull requests that require additional action from users switching to the new release, include the string "action required" (case insensitive) in the release note:

```release-note
action required: your release note here
```

For pull requests that don't need to be mentioned at release time, use the `/release-note-none` Prow command to add the `release-note-none` label to the PR. You can also write the string "NONE" as a release note in your PR description:

```release-note
NONE
```
-->


rupalibehera: cc: @piyush-garg @concaf 
tekton-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/tektoncd/operator/pull/1090#pullrequestreview-1132392956" title="LGTM">concaf</a>*

The full list of commands accepted by this bot can be found [here](https://prow.tekton.dev/command-help?repo=tektoncd%2Foperator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/tektoncd/operator/blob/main/OWNERS)~~ [concaf]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
concaf: /cherrypick release-v0.60.x
tekton-robot: @concaf: once the present PR merges, I will cherry-pick it on top of release-v0.60.x in a new PR and assign it to you.

<details>

In response to [this](https://github.com/tektoncd/operator/pull/1090#issuecomment-1269436059):

>/cherrypick release-v0.60.x


Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
</details>

Patch:
diff --git a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-dotnet/s2i-dotnet-task.yaml b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-dotnet/s2i-dotnet-task.yaml
index 08d1bd6ef..c2908691e 100644
--- a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-dotnet/s2i-dotnet-task.yaml
+++ b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-dotnet/s2i-dotnet-task.yaml
@@ -65,11 +65,6 @@ spec:
             echo "$var" >> /env-vars/env-file
         done
 
-        echo "Generated Build Env Var file"
-        echo "------------------------------"
-        cat /env-vars/env-file
-        echo "------------------------------"
-
         s2i build $(params.PATH_CONTEXT) image-registry.openshift-image-registry.svc:5000/openshift/dotnet:$(params.VERSION) \
         --as-dockerfile /gen-source/Dockerfile.gen --environment-file /env-vars/env-file
       volumeMounts:
diff --git a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-go/s2i-go-task.yaml b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-go/s2i-go-task.yaml
index ed9269e37..0e215ef19 100644
--- a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-go/s2i-go-task.yaml
+++ b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-go/s2i-go-task.yaml
@@ -65,11 +65,6 @@ spec:
             echo "$var" >> /env-vars/env-file
         done
 
-        echo "Generated Build Env Var file"
-        echo "------------------------------"
-        cat /env-vars/env-file
-        echo "------------------------------"
-
         s2i build $(params.PATH_CONTEXT) image-registry.openshift-image-registry.svc:5000/openshift/golang:$(params.VERSION) \
         --as-dockerfile /gen-source/Dockerfile.gen --environment-file /env-vars/env-file
       env:
diff --git a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-java/s2i-java-task.yaml b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-java/s2i-java-task.yaml
index eba29a500..b61666577 100644
--- a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-java/s2i-java-task.yaml
+++ b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-java/s2i-java-task.yaml
@@ -80,11 +80,6 @@ spec:
             echo "$var" >> /env-vars/env-file
           done
 
-          echo "Generated Build Env Var file"
-          echo "------------------------------"
-          cat /env-vars/env-file
-          echo "------------------------------"
-
           s2i build $(params.PATH_CONTEXT) image-registry.openshift-image-registry.svc:5000/openshift/java:$(params.VERSION) \
           --image-scripts-url image:///usr/local/s2i \
           --as-dockerfile /gen-source/Dockerfile.gen --environment-file /env-vars/env-file
diff --git a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-nodejs/s2i-nodejs-task.yaml b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-nodejs/s2i-nodejs-task.yaml
index b08d5aec6..14fccda09 100644
--- a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-nodejs/s2i-nodejs-task.yaml
+++ b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-nodejs/s2i-nodejs-task.yaml
@@ -65,11 +65,6 @@ spec:
             echo "$var" >> /env-vars/env-file
         done
 
-        echo "Generated Build Env Var file"
-        echo "------------------------------"
-        cat /env-vars/env-file
-        echo "------------------------------"
-
         s2i build $(params.PATH_CONTEXT) image-registry.openshift-image-registry.svc:5000/openshift/nodejs:$(params.VERSION) \
         --as-dockerfile /gen-source/Dockerfile.gen --environment-file /env-vars/env-file
       volumeMounts:
diff --git a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-perl/s2i-perl-task.yaml b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-perl/s2i-perl-task.yaml
index c8c9b4f06..bc416bc42 100644
--- a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-perl/s2i-perl-task.yaml
+++ b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-perl/s2i-perl-task.yaml
@@ -65,11 +65,6 @@ spec:
             echo "$var" >> /env-vars/env-file
         done
 
-        echo "Generated Build Env Var file"
-        echo "------------------------------"
-        cat /env-vars/env-file
-        echo "------------------------------"
-
         s2i build $(params.PATH_CONTEXT) image-registry.openshift-image-registry.svc:5000/openshift/perl:$(params.VERSION) \
         --as-dockerfile /gen-source/Dockerfile.gen --environment-file /env-vars/env-file
       volumeMounts:
diff --git a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-php/s2i-php-task.yaml b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-php/s2i-php-task.yaml
index f41295a81..689b2f0f3 100644
--- a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-php/s2i-php-task.yaml
+++ b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-php/s2i-php-task.yaml
@@ -65,10 +65,6 @@ spec:
             echo "$var" >> /env-vars/env-file
         done
 
-        echo "Generated Build Env Var file"
-        echo "------------------------------"
-        cat /env-vars/env-file
-        echo "------------------------------"
 
         s2i build $(params.PATH_CONTEXT) image-registry.openshift-image-registry.svc:5000/openshift/php:$(params.VERSION) \
         --as-dockerfile /gen-source/Dockerfile.gen --environment-file /env-vars/env-file
diff --git a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-python/s2i-python-task.yaml b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-python/s2i-python-task.yaml
index e75180961..80aa04ce0 100644
--- a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-python/s2i-python-task.yaml
+++ b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-python/s2i-python-task.yaml
@@ -65,11 +65,6 @@ spec:
             echo "$var" >> /env-vars/env-file
         done
 
-        echo "Generated Build Env Var file"
-        echo "------------------------------"
-        cat /env-vars/env-file
-        echo "------------------------------"
-
         s2i build $(params.PATH_CONTEXT) image-registry.openshift-image-registry.svc:5000/openshift/python:$(params.VERSION) \
         --as-dockerfile /gen-source/Dockerfile.gen --environment-file /env-vars/env-file
       volumeMounts:
diff --git a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-ruby/s2i-ruby-task.yaml b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-ruby/s2i-ruby-task.yaml
index 7e2416d6f..8bdf15ae4 100644
--- a/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-ruby/s2i-ruby-task.yaml
+++ b/cmd/openshift/operator/kodata/tekton-addon/addons/02-clustertasks/source_local/s2i-ruby/s2i-ruby-task.yaml
@@ -65,11 +65,6 @@ spec:
             echo "$var" >> /env-vars/env-file
         done
 
-        echo "Generated Build Env Var file"
-        echo "------------------------------"
-        cat /env-vars/env-file
-        echo "------------------------------"
-
         s2i build $(params.PATH_CONTEXT) image-registry.openshift-image-registry.svc:5000/openshift/ruby:$(params.VERSION) \
         --as-dockerfile /gen-source/Dockerfile.gen --environment-file /env-vars/env-file
       volumeMounts:
diff --git a/pkg/reconciler/shared/tektonconfig/pipeline/pipeline.go b/pkg/reconciler/shared/tektonconfig/pipeline/pipeline.go
index d75457ad5..59068a33c 100644
--- a/pkg/reconciler/shared/tektonconfig/pipeline/pipeline.go
+++ b/pkg/reconciler/shared/tektonconfig/pipeline/pipeline.go
@@ -29,21 +29,20 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
-func EnsureTektonPipelineExists(ctx context.Context, clients op.TektonPipelineInterface, config *v1alpha1.TektonConfig) (*v1alpha1.TektonPipeline, error) {
+func EnsureTektonPipelineExists(ctx context.Context, clients op.TektonPipelineInterface, tp *v1alpha1.TektonPipeline) (*v1alpha1.TektonPipeline, error) {
 	tpCR, err := GetPipeline(ctx, clients, v1alpha1.PipelineResourceName)
 
 	if err != nil {
 		if !apierrs.IsNotFound(err) {
 			return nil, err
 		}
-		_, err = CreatePipeline(ctx, clients, config)
-		if err != nil {
+		if err := CreatePipeline(ctx, clients, tp); err != nil {
 			return nil, err
 		}
 		return nil, v1alpha1.RECONCILE_AGAIN_ERR
 	}
 
-	tpCR, err = UpdatePipeline(ctx, tpCR, config, clients)
+	tpCR, err = UpdatePipeline(ctx, tpCR, tp, clients)
 	if err != nil {
 		return nil, err
 	}
@@ -63,10 +62,9 @@ func GetPipeline(ctx context.Context, clients op.TektonPipelineInterface, name s
 	return clients.Get(ctx, name, metav1.GetOptions{})
 }
 
-func CreatePipeline(ctx context.Context, clients op.TektonPipelineInterface, config *v1alpha1.TektonConfig) (*v1alpha1.TektonPipeline, error) {
+func GetTektonPipelineCR(config *v1alpha1.TektonConfig) *v1alpha1.TektonPipeline {
 	ownerRef := *metav1.NewControllerRef(config, config.GroupVersionKind())
-
-	tpCR := &v1alpha1.TektonPipeline{
+	return &v1alpha1.TektonPipeline{
 		ObjectMeta: metav1.ObjectMeta{
 			Name:            v1alpha1.PipelineResourceName,
 			OwnerReferences: []metav1.OwnerReference{ownerRef},
@@ -79,46 +77,45 @@ func CreatePipeline(ctx context.Context, clients op.TektonPipelineInterface, con
 			Config:   config.Spec.Config,
 		},
 	}
-	_, err := clients.Create(ctx, tpCR, metav1.CreateOptions{})
-	if err != nil {
-		return nil, err
-	}
-	return tpCR, err
 }
 
-func UpdatePipeline(ctx context.Context, tpCR *v1alpha1.TektonPipeline, config *v1alpha1.TektonConfig, clients op.TektonPipelineInterface) (*v1alpha1.TektonPipeline, error) {
+func CreatePipeline(ctx context.Context, clients op.TektonPipelineInterface, tp *v1alpha1.TektonPipeline) error {
+	_, err := clients.Create(ctx, tp, metav1.CreateOptions{})
+	return err
+}
+
+func UpdatePipeline(ctx context.Context, old *v1alpha1.TektonPipeline, new *v1alpha1.TektonPipeline, clients op.TektonPipelineInterface) (*v1alpha1.TektonPipeline, error) {
 	// if the pipeline spec is changed then update the instance
 	updated := false
 
-	if config.Spec.TargetNamespace != tpCR.Spec.TargetNamespace {
-		tpCR.Spec.TargetNamespace = config.Spec.TargetNamespace
+	if new.Spec.TargetNamespace != old.Spec.TargetNamespace {
+		old.Spec.TargetNamespace = new.Spec.TargetNamespace
 		updated = true
 	}
 
-	if !reflect.DeepEqual(tpCR.Spec.Pipeline, config.Spec.Pipeline) {
-		tpCR.Spec.Pipeline = config.Spec.Pipeline
+	if !reflect.DeepEqual(old.Spec.Pipeline, new.Spec.Pipeline) {
+		old.Spec.Pipeline = new.Spec.Pipeline
 		updated = true
 	}
 
-	if !reflect.DeepEqual(tpCR.Spec.Config, config.Spec.Config) {
-		tpCR.Spec.Config = config.Spec.Config
+	if !reflect.DeepEqual(old.Spec.Config, new.Spec.Config) {
+		old.Spec.Config = new.Spec.Config
 		updated = true
 	}
 
-	if tpCR.ObjectMeta.OwnerReferences == nil {
-		ownerRef := *metav1.NewControllerRef(config, config.GroupVersionKind())
-		tpCR.ObjectMeta.OwnerReferences = []metav1.OwnerReference{ownerRef}
+	if old.ObjectMeta.OwnerReferences == nil {
+		old.ObjectMeta.OwnerReferences = new.ObjectMeta.OwnerReferences
 		updated = true
 	}
 
 	if updated {
-		_, err := clients.Update(ctx, tpCR, metav1.UpdateOptions{})
+		_, err := clients.Update(ctx, old, metav1.UpdateOptions{})
 		if err != nil {
 			return nil, err
 		}
 		return nil, v1alpha1.RECONCILE_AGAIN_ERR
 	}
-	return tpCR, nil
+	return old, nil
 }
 
 // IsTektonPipelineReady will check the status conditions of the TektonPipeline and return true if the TektonPipeline is ready.
diff --git a/pkg/reconciler/shared/tektonconfig/tektonconfig.go b/pkg/reconciler/shared/tektonconfig/tektonconfig.go
index 67380111e..e9a54e286 100644
--- a/pkg/reconciler/shared/tektonconfig/tektonconfig.go
+++ b/pkg/reconciler/shared/tektonconfig/tektonconfig.go
@@ -113,7 +113,9 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, tc *v1alpha1.TektonConfi
 	tc.Status.MarkPreInstallComplete()
 
 	// Ensure if the pipeline CR already exists, if not create Pipeline CR
-	if _, err := pipeline.EnsureTektonPipelineExists(ctx, r.operatorClientSet.OperatorV1alpha1().TektonPipelines(), tc); err != nil {
+	tektonpipeline := pipeline.GetTektonPipelineCR(tc)
+	// Ensure it exists
+	if _, err := pipeline.EnsureTektonPipelineExists(ctx, r.operatorClientSet.OperatorV1alpha1().TektonPipelines(), tektonpipeline); err != nil {
 		tc.Status.MarkComponentNotReady(fmt.Sprintf("TektonPipeline: %s", err.Error()))
 		if err == v1alpha1.RECONCILE_AGAIN_ERR {
 			return v1alpha1.REQUEUE_EVENT_AFTER
@@ -123,7 +125,8 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, tc *v1alpha1.TektonConfi
 
 	// Create TektonTrigger CR if the profile is all or basic
 	if tc.Spec.Profile == v1alpha1.ProfileAll || tc.Spec.Profile == v1alpha1.ProfileBasic {
-		if _, err := trigger.EnsureTektonTriggerExists(ctx, r.operatorClientSet.OperatorV1alpha1().TektonTriggers(), tc); err != nil {
+		tektontrigger := trigger.GetTektonTriggerCR(tc)
+		if _, err := trigger.EnsureTektonTriggerExists(ctx, r.operatorClientSet.OperatorV1alpha1().TektonTriggers(), tektontrigger); err != nil {
 			tc.Status.MarkComponentNotReady(fmt.Sprintf("TektonTrigger: %s", err.Error()))
 			return v1alpha1.REQUEUE_EVENT_AFTER
 		}
diff --git a/pkg/reconciler/shared/tektonconfig/trigger/trigger.go b/pkg/reconciler/shared/tektonconfig/trigger/trigger.go
index f5530829b..773582b81 100644
--- a/pkg/reconciler/shared/tektonconfig/trigger/trigger.go
+++ b/pkg/reconciler/shared/tektonconfig/trigger/trigger.go
@@ -29,21 +29,20 @@ import (
 	"knative.dev/pkg/apis"
 )
 
-func EnsureTektonTriggerExists(ctx context.Context, clients op.TektonTriggerInterface, config *v1alpha1.TektonConfig) (*v1alpha1.TektonTrigger, error) {
+func EnsureTektonTriggerExists(ctx context.Context, clients op.TektonTriggerInterface, tt *v1alpha1.TektonTrigger) (*v1alpha1.TektonTrigger, error) {
 	ttCR, err := GetTrigger(ctx, clients, v1alpha1.TriggerResourceName)
 
 	if err != nil {
 		if !apierrs.IsNotFound(err) {
 			return nil, err
 		}
-		_, err = CreateTrigger(ctx, clients, config)
-		if err != nil {
+		if err := CreateTrigger(ctx, clients, tt); err != nil {
 			return nil, err
 		}
 		return nil, v1alpha1.RECONCILE_AGAIN_ERR
 	}
 
-	ttCR, err = UpdateTrigger(ctx, ttCR, config, clients)
+	ttCR, err = UpdateTrigger(ctx, ttCR, tt, clients)
 	if err != nil {
 		return nil, err
 	}
@@ -63,10 +62,9 @@ func GetTrigger(ctx context.Context, clients op.TektonTriggerInterface, name str
 	return clients.Get(ctx, name, metav1.GetOptions{})
 }
 
-func CreateTrigger(ctx context.Context, clients op.TektonTriggerInterface, config *v1alpha1.TektonConfig) (*v1alpha1.TektonTrigger, error) {
+func GetTektonTriggerCR(config *v1alpha1.TektonConfig) *v1alpha1.TektonTrigger {
 	ownerRef := *metav1.NewControllerRef(config, config.GroupVersionKind())
-
-	ttCR := &v1alpha1.TektonTrigger{
+	return &v1alpha1.TektonTrigger{
 		ObjectMeta: metav1.ObjectMeta{
 			Name:            v1alpha1.TriggerResourceName,
 			OwnerReferences: []metav1.OwnerReference{ownerRef},
@@ -79,46 +77,45 @@ func CreateTrigger(ctx context.Context, clients op.TektonTriggerInterface, confi
 			Trigger: config.Spec.Trigger,
 		},
 	}
-	_, err := clients.Create(ctx, ttCR, metav1.CreateOptions{})
-	if err != nil {
-		return nil, err
-	}
-	return ttCR, err
 }
 
-func UpdateTrigger(ctx context.Context, ttCR *v1alpha1.TektonTrigger, config *v1alpha1.TektonConfig, clients op.TektonTriggerInterface) (*v1alpha1.TektonTrigger, error) {
+func CreateTrigger(ctx context.Context, clients op.TektonTriggerInterface, tt *v1alpha1.TektonTrigger) error {
+	_, err := clients.Create(ctx, tt, metav1.CreateOptions{})
+	return err
+}
+
+func UpdateTrigger(ctx context.Context, old *v1alpha1.TektonTrigger, new *v1alpha1.TektonTrigger, clients op.TektonTriggerInterface) (*v1alpha1.TektonTrigger, error) {
 	// if the trigger spec is changed then update the instance
 	updated := false
 
-	if config.Spec.TargetNamespace != ttCR.Spec.TargetNamespace {
-		ttCR.Spec.TargetNamespace = config.Spec.TargetNamespace
+	if new.Spec.TargetNamespace != old.Spec.TargetNamespace {
+		old.Spec.TargetNamespace = new.Spec.TargetNamespace
 		updated = true
 	}
 
-	if !reflect.DeepEqual(ttCR.Spec.Trigger, config.Spec.Trigger) {
-		ttCR.Spec.Trigger = config.Spec.Trigger
+	if !reflect.DeepEqual(old.Spec.Trigger, new.Spec.Trigger) {
+		old.Spec.Trigger = new.Spec.Trigger
 		updated = true
 	}
 
-	if !reflect.DeepEqual(ttCR.Spec.Config, config.Spec.Config) {
-		ttCR.Spec.Config = config.Spec.Config
+	if !reflect.DeepEqual(old.Spec.Config, new.Spec.Config) {
+		old.Spec.Config = new.Spec.Config
 		updated = true
 	}
 
-	if ttCR.ObjectMeta.OwnerReferences == nil {
-		ownerRef := *metav1.NewControllerRef(config, config.GroupVersionKind())
-		ttCR.ObjectMeta.OwnerReferences = []metav1.OwnerReference{ownerRef}
+	if old.ObjectMeta.OwnerReferences == nil {
+		old.ObjectMeta.OwnerReferences = new.ObjectMeta.OwnerReferences
 		updated = true
 	}
 
 	if updated {
-		_, err := clients.Update(ctx, ttCR, metav1.UpdateOptions{})
+		_, err := clients.Update(ctx, old, metav1.UpdateOptions{})
 		if err != nil {
 			return nil, err
 		}
 		return nil, v1alpha1.RECONCILE_AGAIN_ERR
 	}
-	return ttCR, nil
+	return old, nil
 }
 
 // isTektonTriggerReady will check the status conditions of the TektonTrigger and return true if the TektonTrigger is ready.


Test patch:
diff --git a/pkg/reconciler/shared/tektonconfig/pipeline/pipeline_test.go b/pkg/reconciler/shared/tektonconfig/pipeline/pipeline_test.go
index 1d796f5e6..f52923b29 100644
--- a/pkg/reconciler/shared/tektonconfig/pipeline/pipeline_test.go
+++ b/pkg/reconciler/shared/tektonconfig/pipeline/pipeline_test.go
@@ -34,37 +34,37 @@ import (
 func TestEnsureTektonPipelineExists(t *testing.T) {
 	ctx, _, _ := ts.SetupFakeContextWithCancel(t)
 	c := fake.Get(ctx)
-	tConfig := GetTektonConfig()
+	tp := GetTektonPipelineCR(GetTektonConfig())
 
 	// first invocation should create instance as it is non-existent and return RECONCILE_AGAIN_ERR
-	_, err := EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tConfig)
+	_, err := EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tp)
 	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
 
 	// during second invocation instance exists but waiting on dependencies (pipeline, triggers)
 	// hence returns DEPENDENCY_UPGRADE_PENDING_ERR
-	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tConfig)
+	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tp)
 	util.AssertEqual(t, err, v1alpha1.DEPENDENCY_UPGRADE_PENDING_ERR)
 
 	// make upgrade checks pass
 	makeUpgradeCheckPass(t, ctx, c.OperatorV1alpha1().TektonPipelines())
 
 	// next invocation should return RECONCILE_AGAIN_ERR as Dashboard is waiting for installation (prereconcile, postreconcile, installersets...)
-	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tConfig)
+	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tp)
 	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
 
 	// mark the instance ready
 	markPipelineReady(t, ctx, c.OperatorV1alpha1().TektonPipelines())
 
 	// next invocation should return nil error as the instance is ready
-	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tConfig)
+	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tp)
 	util.AssertEqual(t, err, nil)
 
 	// test update propagation from tektonConfig
-	tConfig.Spec.TargetNamespace = "foobar"
-	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tConfig)
+	tp.Spec.TargetNamespace = "foobar"
+	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tp)
 	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
 
-	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tConfig)
+	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tp)
 	util.AssertEqual(t, err, nil)
 }
 
@@ -77,8 +77,8 @@ func TestEnsureTektonPipelineCRNotExists(t *testing.T) {
 	util.AssertEqual(t, err, nil)
 
 	// create an instance for testing other cases
-	tConfig := GetTektonConfig()
-	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tConfig)
+	tp := GetTektonPipelineCR(GetTektonConfig())
+	_, err = EnsureTektonPipelineExists(ctx, c.OperatorV1alpha1().TektonPipelines(), tp)
 	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
 
 	// when an instance exists the first invoacation should make the delete API call and
diff --git a/pkg/reconciler/shared/tektonconfig/trigger/trigger_test.go b/pkg/reconciler/shared/tektonconfig/trigger/trigger_test.go
index 3b094ed2e..7f650eec1 100644
--- a/pkg/reconciler/shared/tektonconfig/trigger/trigger_test.go
+++ b/pkg/reconciler/shared/tektonconfig/trigger/trigger_test.go
@@ -34,37 +34,37 @@ import (
 func TestEnsureTektonTriggerExists(t *testing.T) {
 	ctx, _, _ := ts.SetupFakeContextWithCancel(t)
 	c := fake.Get(ctx)
-	tConfig := GetTektonConfig()
+	tt := GetTektonTriggerCR(GetTektonConfig())
 
 	// first invocation should create instance as it is non-existent and return RECONCILE_AGAIN_ERR
-	_, err := EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tConfig)
+	_, err := EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tt)
 	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
 
 	// during second invocation instance exists but waiting on dependencies (pipeline, triggers)
 	// hence returns DEPENDENCY_UPGRADE_PENDING_ERR
-	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tConfig)
+	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tt)
 	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
 
 	// make upgrade checks pass
 	makeUpgradeCheckPass(t, ctx, c.OperatorV1alpha1().TektonTriggers())
 
 	// next invocation should return RECONCILE_AGAIN_ERR as Dashboard is waiting for installation (prereconcile, postreconcile, installersets...)
-	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tConfig)
+	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tt)
 	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
 
 	// mark the instance ready
 	markTriggersReady(t, ctx, c.OperatorV1alpha1().TektonTriggers())
 
 	// next invocation should return nil error as the instance is ready
-	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tConfig)
+	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tt)
 	util.AssertEqual(t, err, nil)
 
 	// test update propagation from tektonConfig
-	tConfig.Spec.TargetNamespace = "foobar"
-	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tConfig)
+	tt.Spec.TargetNamespace = "foobar"
+	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tt)
 	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
 
-	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tConfig)
+	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tt)
 	util.AssertEqual(t, err, nil)
 }
 
@@ -77,8 +77,8 @@ func TestEnsureTektonTriggerCRNotExists(t *testing.T) {
 	util.AssertEqual(t, err, nil)
 
 	// create an instance for testing other cases
-	tConfig := GetTektonConfig()
-	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tConfig)
+	tt := GetTektonTriggerCR(GetTektonConfig())
+	_, err = EnsureTektonTriggerExists(ctx, c.OperatorV1alpha1().TektonTriggers(), tt)
 	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
 
 	// when an instance exists the first invoacation should make the delete API call and
diff --git a/test/resources/rbac.go b/test/resources/rbac.go
index 83a8ac478..ace5bbe8e 100644
--- a/test/resources/rbac.go
+++ b/test/resources/rbac.go
@@ -4,15 +4,11 @@ import (
 	"context"
 	"testing"
 
+	"github.com/tektoncd/operator/test/utils"
 	corev1 "k8s.io/api/core/v1"
-
 	apierrs "k8s.io/apimachinery/pkg/api/errors"
-
-	"github.com/tektoncd/operator/test/utils"
-
-	"k8s.io/apimachinery/pkg/util/wait"
-
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/wait"
 )
 
 // EnsureTestNamespaceExists creates a Test Namespace