Repository: tektoncd/operator
Pull request #1125 (2022-10-28 05:24:11)

[OpenShift] Creates OpenShiftPipelinesAsCode through TektonConfig
this adds platform section in spec move pipelinesascode field from addon to openshift platform section
```
  spec:
    addon:
      params:
      - name: communityClusterTasks
        value: "true"
      - name: clusterTasks
        value: "true"
      - name: pipelineTemplates
        value: "true"
    config: {}
    pipeline:
      ...
    platforms:
      openshift:
        pipelinesAsCode:
          enable: true

```


Signed-off-by: Shivam Mukhade <smukhade@redhat.com>

# 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
- [ ] 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)
- [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
```
-->


tekton-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by:
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please ask for approval from **sm43** after the PR has been reviewed.

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

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

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

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":["sm43"]} -->
tekton-robot: The following is the coverage report on the affected files.
Say `/test pull-tekton-operator-go-coverage` to re-run this coverage report

File | Old Coverage | New Coverage | Delta
---- |:------------:|:------------:|:-----:
[pkg/apis/operator/v1alpha1/tektonconfig_defaults.go](https://storage.cloud.google.com/tekton-prow/pr-logs/pull/tektoncd_operator/1125/pull-tekton-operator-go-coverage/1585864992450678784/artifacts/line-cov.html#file2) | 76.9% | 84.2% | 7.3
[pkg/reconciler/openshift/tektonconfig/extension/pipelinesascode.go](https://storage.cloud.google.com/tekton-prow/pr-logs/pull/tektoncd_operator/1125/pull-tekton-operator-go-coverage/1585864992450678784/artifacts/line-cov.html#file5) | Do not exist | 71.2% | 

tekton-robot: @sm43: The following test **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-tekton-operator-build-tests | f38b23f35e2ca8483ab21ca40ef13b737955a3ad | [link](https://prow.tekton.dev/view/gs/tekton-prow/pr-logs/pull/tektoncd_operator/1125/pull-tekton-operator-build-tests/1585864992358404096) | true | `/test pull-tekton-operator-build-tests`

[Full PR test history](https://prow.tekton.dev/pr-history?org=tektoncd&repo=operator&pr=1125). [Your PR dashboard](https://prow.tekton.dev/pr?query=is%3Apr%20state%3Aopen%20author%3Asm43).

<details>

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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
tekton-robot: The following is the coverage report on the affected files.
Say `/test pull-tekton-operator-go-coverage` to re-run this coverage report

File | Old Coverage | New Coverage | Delta
---- |:------------:|:------------:|:-----:
[pkg/apis/operator/v1alpha1/tektonconfig_defaults.go](https://storage.cloud.google.com/tekton-prow/pr-logs/pull/tektoncd_operator/1125/pull-tekton-operator-go-coverage/1585876265561231360/artifacts/line-cov.html#file2) | 76.9% | 84.2% | 7.3
[pkg/reconciler/openshift/tektonconfig/extension/pipelinesascode.go](https://storage.cloud.google.com/tekton-prow/pr-logs/pull/tektoncd_operator/1125/pull-tekton-operator-go-coverage/1585876265561231360/artifacts/line-cov.html#file5) | Do not exist | 71.2% | 

sm43: > How does it act on upgrade ? If I add the pac addon enabled, will it be migrated to this new field or do I need to do something ?

webhook will handle the field migration :)
vdemeester: > > How does it act on upgrade ? If I add the pac addon enabled, will it be migrated to this new field or do I need to do something ?
> 
> webhook will handle the field migration :)

Perfect 👍🏼 
/approve
tekton-robot: The following is the coverage report on the affected files.
Say `/test pull-tekton-operator-go-coverage` to re-run this coverage report

File | Old Coverage | New Coverage | Delta
---- |:------------:|:------------:|:-----:
[pkg/apis/operator/v1alpha1/tektonconfig_defaults.go](https://storage.cloud.google.com/tekton-prow/pr-logs/pull/tektoncd_operator/1125/pull-tekton-operator-go-coverage/1588196555129622528/artifacts/line-cov.html#file2) | 76.9% | 84.2% | 7.3
[pkg/reconciler/openshift/tektonconfig/extension/pipelinesascode.go](https://storage.cloud.google.com/tekton-prow/pr-logs/pull/tektoncd_operator/1125/pull-tekton-operator-go-coverage/1588196555129622528/artifacts/line-cov.html#file5) | Do not exist | 71.2% | 


Patch:
diff --git a/pkg/apis/operator/v1alpha1/openshift_platform.go b/pkg/apis/operator/v1alpha1/openshift_platform.go
new file mode 100644
index 000000000..2268f90b1
--- /dev/null
+++ b/pkg/apis/operator/v1alpha1/openshift_platform.go
@@ -0,0 +1,29 @@
+/*
+Copyright 2022 The Tekton Authors
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package v1alpha1
+
+type OpenShift struct {
+	// PipelinesAsCode allows configuring PipelinesAsCode configurations
+	// +optional
+	PipelinesAsCode *PipelinesAsCode `json:"pipelinesAsCode,omitempty"`
+}
+
+type PipelinesAsCode struct {
+	// Enable or disable pipelines as code by changing this bool
+	// +optional
+	Enable *bool `json:"enable,omitempty"`
+}
diff --git a/pkg/apis/operator/v1alpha1/tektonaddon_defaults.go b/pkg/apis/operator/v1alpha1/tektonaddon_defaults.go
index 02a72ccea..fc974b6be 100644
--- a/pkg/apis/operator/v1alpha1/tektonaddon_defaults.go
+++ b/pkg/apis/operator/v1alpha1/tektonaddon_defaults.go
@@ -18,8 +18,6 @@ package v1alpha1
 
 import (
 	"context"
-
-	"knative.dev/pkg/ptr"
 )
 
 func (ta *TektonAddon) SetDefaults(ctx context.Context) {
@@ -54,8 +52,7 @@ func setAddonDefaults(addon *Addon) {
 		}
 	}
 
-	// by default enable pac
-	if addon.EnablePAC == nil {
-		addon.EnablePAC = ptr.Bool(false)
-	}
+	// Deprecated, will be removed in further releases
+	// moved to OpenShift platform section
+	addon.EnablePAC = nil
 }
diff --git a/pkg/apis/operator/v1alpha1/tektonaddon_types.go b/pkg/apis/operator/v1alpha1/tektonaddon_types.go
index eea21c87e..8f5932f8a 100644
--- a/pkg/apis/operator/v1alpha1/tektonaddon_types.go
+++ b/pkg/apis/operator/v1alpha1/tektonaddon_types.go
@@ -76,6 +76,7 @@ type Addon struct {
 	// Params is the list of params passed for Addon customization
 	// +optional
 	Params []Param `json:"params,omitempty"`
+	// Deprecated, will be removed in further release
 	// EnablePAC field defines whether to install PAC
 	// +optional
 	EnablePAC *bool `json:"enablePipelinesAsCode,omitempty"`
diff --git a/pkg/apis/operator/v1alpha1/tektonconfig_defaults.go b/pkg/apis/operator/v1alpha1/tektonconfig_defaults.go
index 255ca5f85..36576bd27 100644
--- a/pkg/apis/operator/v1alpha1/tektonconfig_defaults.go
+++ b/pkg/apis/operator/v1alpha1/tektonconfig_defaults.go
@@ -18,6 +18,8 @@ package v1alpha1
 
 import (
 	"context"
+
+	"knative.dev/pkg/ptr"
 )
 
 func (tc *TektonConfig) SetDefaults(ctx context.Context) {
@@ -29,9 +31,23 @@ func (tc *TektonConfig) SetDefaults(ctx context.Context) {
 	tc.Spec.Trigger.setDefaults()
 
 	if IsOpenShiftPlatform() {
+		if tc.Spec.Platforms.OpenShift.PipelinesAsCode == nil {
+			tc.Spec.Platforms.OpenShift.PipelinesAsCode = &PipelinesAsCode{
+				Enable: ptr.Bool(true),
+			}
+		} else {
+			tc.Spec.Addon.EnablePAC = nil
+		}
+
+		// check if PAC is disabled through addon before enabling through OpenShiftPipelinesAsCode
+		if tc.Spec.Addon.EnablePAC != nil && !*tc.Spec.Addon.EnablePAC {
+			tc.Spec.Platforms.OpenShift.PipelinesAsCode.Enable = ptr.Bool(false)
+		}
+
 		setAddonDefaults(&tc.Spec.Addon)
 	} else {
 		tc.Spec.Addon = Addon{}
+		tc.Spec.Platforms.OpenShift = OpenShift{}
 	}
 
 	// before adding webhook we had default value for pruner's keep as 1
diff --git a/pkg/apis/operator/v1alpha1/tektonconfig_types.go b/pkg/apis/operator/v1alpha1/tektonconfig_types.go
index 61fc6a629..1d132dfee 100644
--- a/pkg/apis/operator/v1alpha1/tektonconfig_types.go
+++ b/pkg/apis/operator/v1alpha1/tektonconfig_types.go
@@ -95,6 +95,9 @@ type TektonConfigSpec struct {
 	// Params is the list of params passed for all platforms
 	// +optional
 	Params []Param `json:"params,omitempty"`
+	// Platforms allows configuring platform specific configurations
+	// +optional
+	Platforms Platforms `json:"platforms,omitempty"`
 }
 
 // TektonConfigStatus defines the observed state of TektonConfig
@@ -154,3 +157,9 @@ type Config struct {
 	// +optional
 	PriorityClassName string `json:"priorityClassName,omitempty"`
 }
+
+type Platforms struct {
+	// OpenShift allows configuring openshift specific components and configurations
+	// +optional
+	OpenShift OpenShift `json:"openshift,omitempty"`
+}
diff --git a/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go
index 7b075134d..c01836ed5 100644
--- a/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go
@@ -216,6 +216,27 @@ func (in *Hub) DeepCopy() *Hub {
 	return out
 }
 
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *OpenShift) DeepCopyInto(out *OpenShift) {
+	*out = *in
+	if in.PipelinesAsCode != nil {
+		in, out := &in.PipelinesAsCode, &out.PipelinesAsCode
+		*out = new(PipelinesAsCode)
+		(*in).DeepCopyInto(*out)
+	}
+	return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenShift.
+func (in *OpenShift) DeepCopy() *OpenShift {
+	if in == nil {
+		return nil
+	}
+	out := new(OpenShift)
+	in.DeepCopyInto(out)
+	return out
+}
+
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *OpenShiftPipelinesAsCode) DeepCopyInto(out *OpenShiftPipelinesAsCode) {
 	*out = *in
@@ -487,6 +508,44 @@ func (in *PipelineProperties) DeepCopy() *PipelineProperties {
 	return out
 }
 
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *PipelinesAsCode) DeepCopyInto(out *PipelinesAsCode) {
+	*out = *in
+	if in.Enable != nil {
+		in, out := &in.Enable, &out.Enable
+		*out = new(bool)
+		**out = **in
+	}
+	return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelinesAsCode.
+func (in *PipelinesAsCode) DeepCopy() *PipelinesAsCode {
+	if in == nil {
+		return nil
+	}
+	out := new(PipelinesAsCode)
+	in.DeepCopyInto(out)
+	return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *Platforms) DeepCopyInto(out *Platforms) {
+	*out = *in
+	in.OpenShift.DeepCopyInto(&out.OpenShift)
+	return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Platforms.
+func (in *Platforms) DeepCopy() *Platforms {
+	if in == nil {
+		return nil
+	}
+	out := new(Platforms)
+	in.DeepCopyInto(out)
+	return out
+}
+
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *Prune) DeepCopyInto(out *Prune) {
 	*out = *in
@@ -796,6 +855,7 @@ func (in *TektonConfigSpec) DeepCopyInto(out *TektonConfigSpec) {
 		*out = make([]Param, len(*in))
 		copy(*out, *in)
 	}
+	in.Platforms.DeepCopyInto(&out.Platforms)
 	return
 }
 
diff --git a/pkg/reconciler/kubernetes/tektoninstallerset/client/obsolete_sets.go b/pkg/reconciler/kubernetes/tektoninstallerset/client/obsolete_sets.go
new file mode 100644
index 000000000..6e374c15c
--- /dev/null
+++ b/pkg/reconciler/kubernetes/tektoninstallerset/client/obsolete_sets.go
@@ -0,0 +1,50 @@
+/*
+Copyright 2022 The Tekton Authors
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package client
+
+import (
+	"context"
+
+	"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/labels"
+	"k8s.io/apimachinery/pkg/selection"
+)
+
+func (i *InstallerSetClient) RemoveObsoleteSets(ctx context.Context) error {
+	var sets []string
+	if i.resourceKind == v1alpha1.KindTektonPipeline {
+		sets = []string{"pipeline", "PrePipeline", "PostPipeline"}
+	} else if i.resourceKind == v1alpha1.KindTektonTrigger {
+		sets = []string{"trigger"}
+	}
+	labelSelector := labels.NewSelector()
+	createdReq, _ := labels.NewRequirement(v1alpha1.CreatedByKey, selection.Equals, []string{i.resourceKind})
+	if createdReq != nil {
+		labelSelector = labelSelector.Add(*createdReq)
+	}
+	typeReq, _ := labels.NewRequirement(v1alpha1.InstallerSetType, selection.In, sets)
+	if typeReq != nil {
+		labelSelector = labelSelector.Add(*typeReq)
+	}
+	err := i.clientSet.DeleteCollection(ctx, metav1.DeleteOptions{},
+		metav1.ListOptions{LabelSelector: labelSelector.String()})
+	if err != nil {
+		return err
+	}
+	return nil
+}
diff --git a/pkg/reconciler/kubernetes/tektonpipeline/reconcile.go b/pkg/reconciler/kubernetes/tektonpipeline/reconcile.go
index 8512b61ae..6df44ab42 100644
--- a/pkg/reconciler/kubernetes/tektonpipeline/reconcile.go
+++ b/pkg/reconciler/kubernetes/tektonpipeline/reconcile.go
@@ -80,6 +80,11 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, tp *v1alpha1.TektonPipel
 		return err
 	}
 
+	if err := r.installerSetClient.RemoveObsoleteSets(ctx); err != nil {
+		logger.Error("failed to remove obsolete installer sets: %v", err)
+		return err
+	}
+
 	if err := r.extension.PreReconcile(ctx, tp); err != nil {
 		msg := fmt.Sprintf("PreReconciliation failed: %s", err.Error())
 		logger.Error(msg)
diff --git a/pkg/reconciler/kubernetes/tektontrigger/reconcile.go b/pkg/reconciler/kubernetes/tektontrigger/reconcile.go
index 5a8264b48..1056488c2 100644
--- a/pkg/reconciler/kubernetes/tektontrigger/reconcile.go
+++ b/pkg/reconciler/kubernetes/tektontrigger/reconcile.go
@@ -84,6 +84,11 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, tt *v1alpha1.TektonTrigg
 	// Pass the object through defaulting
 	tt.SetDefaults(ctx)
 
+	if err := r.installerSetClient.RemoveObsoleteSets(ctx); err != nil {
+		logger.Error("failed to remove obsolete installer sets: %v", err)
+		return err
+	}
+
 	if err := r.extension.PreReconcile(ctx, tt); err != nil {
 		msg := fmt.Sprintf("PreReconciliation failed: %s", err.Error())
 		logger.Error(msg)
diff --git a/pkg/reconciler/openshift/tektonconfig/extension.go b/pkg/reconciler/openshift/tektonconfig/extension.go
index 4fd9f9396..4af60365b 100644
--- a/pkg/reconciler/openshift/tektonconfig/extension.go
+++ b/pkg/reconciler/openshift/tektonconfig/extension.go
@@ -109,6 +109,18 @@ func (oe openshiftExtension) PreReconcile(ctx context.Context, tc v1alpha1.Tekto
 func (oe openshiftExtension) PostReconcile(ctx context.Context, comp v1alpha1.TektonComponent) error {
 	configInstance := comp.(*v1alpha1.TektonConfig)
 
+	pac := configInstance.Spec.Platforms.OpenShift.PipelinesAsCode
+	if pac != nil && *pac.Enable {
+		if _, err := extension.EnsureOpenShiftPipelinesAsCodeExists(ctx, oe.operatorClientSet.OperatorV1alpha1().OpenShiftPipelinesAsCodes(), configInstance); err != nil {
+			configInstance.Status.MarkComponentNotReady(fmt.Sprintf("OpenShiftPipelinesAsCode: %s", err.Error()))
+			return v1alpha1.REQUEUE_EVENT_AFTER
+		}
+	} else {
+		if err := extension.EnsureOpenShiftPipelinesAsCodeCRNotExists(ctx, oe.operatorClientSet.OperatorV1alpha1().OpenShiftPipelinesAsCodes()); err != nil {
+			return err
+		}
+	}
+
 	if configInstance.Spec.Profile == v1alpha1.ProfileAll {
 		if _, err := extension.EnsureTektonAddonExists(ctx, oe.operatorClientSet.OperatorV1alpha1().TektonAddons(), configInstance); err != nil {
 			configInstance.Status.MarkComponentNotReady(fmt.Sprintf("TektonAddon: %s", err.Error()))
@@ -117,7 +129,9 @@ func (oe openshiftExtension) PostReconcile(ctx context.Context, comp v1alpha1.Te
 	}
 
 	if configInstance.Spec.Profile == v1alpha1.ProfileLite || configInstance.Spec.Profile == v1alpha1.ProfileBasic {
-		return extension.EnsureTektonAddonCRNotExists(ctx, oe.operatorClientSet.OperatorV1alpha1().TektonAddons())
+		if err := extension.EnsureTektonAddonCRNotExists(ctx, oe.operatorClientSet.OperatorV1alpha1().TektonAddons()); err != nil {
+			return err
+		}
 	}
 
 	return nil
diff --git a/pkg/reconciler/openshift/tektonconfig/extension/pipelinesascode.go b/pkg/reconciler/openshift/tektonconfig/extension/pipelinesascode.go
new file mode 100644
index 000000000..ffb7f661a
--- /dev/null
+++ b/pkg/reconciler/openshift/tektonconfig/extension/pipelinesascode.go
@@ -0,0 +1,147 @@
+/*
+Copyright 2022 The Tekton Authors
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package extension
+
+import (
+	"context"
+	"fmt"
+	"reflect"
+	"strings"
+
+	"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
+	op "github.com/tektoncd/operator/pkg/client/clientset/versioned/typed/operator/v1alpha1"
+	apierrs "k8s.io/apimachinery/pkg/api/errors"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"knative.dev/pkg/apis"
+)
+
+func EnsureOpenShiftPipelinesAsCodeExists(ctx context.Context, clients op.OpenShiftPipelinesAsCodeInterface, config *v1alpha1.TektonConfig) (*v1alpha1.OpenShiftPipelinesAsCode, error) {
+	opacCR, err := GetPAC(ctx, clients, v1alpha1.OpenShiftPipelinesAsCodeName)
+	if err != nil {
+		if !apierrs.IsNotFound(err) {
+			return nil, err
+		}
+		if _, err = createOPAC(ctx, clients, config); err != nil {
+			return nil, err
+		}
+		return nil, v1alpha1.RECONCILE_AGAIN_ERR
+	}
+
+	opacCR, err = updateOPAC(ctx, opacCR, config, clients)
+	if err != nil {
+		return nil, err
+	}
+
+	ok, err := isOPACReady(opacCR, err)
+	if err != nil {
+		return nil, err
+	}
+	if !ok {
+		return nil, v1alpha1.RECONCILE_AGAIN_ERR
+	}
+
+	return opacCR, err
+}
+
+func createOPAC(ctx context.Context, clients op.OpenShiftPipelinesAsCodeInterface, config *v1alpha1.TektonConfig) (*v1alpha1.OpenShiftPipelinesAsCode, error) {
+	ownerRef := *metav1.NewControllerRef(config, config.GroupVersionKind())
+
+	opacCR := &v1alpha1.OpenShiftPipelinesAsCode{
+		ObjectMeta: metav1.ObjectMeta{
+			Name:            v1alpha1.OpenShiftPipelinesAsCodeName,
+			OwnerReferences: []metav1.OwnerReference{ownerRef},
+		},
+		Spec: v1alpha1.OpenShiftPipelinesAsCodeSpec{
+			CommonSpec: v1alpha1.CommonSpec{
+				TargetNamespace: config.Spec.TargetNamespace,
+			},
+			Config: config.Spec.Config,
+		},
+	}
+	if _, err := clients.Create(ctx, opacCR, metav1.CreateOptions{}); err != nil {
+		return nil, err
+	}
+	return opacCR, nil
+}
+
+func GetPAC(ctx context.Context, clients op.OpenShiftPipelinesAsCodeInterface, name string) (*v1alpha1.OpenShiftPipelinesAsCode, error) {
+	return clients.Get(ctx, name, metav1.GetOptions{})
+}
+
+func updateOPAC(ctx context.Context, opacCR *v1alpha1.OpenShiftPipelinesAsCode, config *v1alpha1.TektonConfig,
+	clients op.OpenShiftPipelinesAsCodeInterface) (*v1alpha1.OpenShiftPipelinesAsCode, error) {
+	// if the pac spec is changed then update the instance
+	updated := false
+
+	if config.Spec.TargetNamespace != opacCR.Spec.TargetNamespace {
+		opacCR.Spec.TargetNamespace = config.Spec.TargetNamespace
+		updated = true
+	}
+
+	if !reflect.DeepEqual(opacCR.Spec.Config, config.Spec.Config) {
+		opacCR.Spec.Config = config.Spec.Config
+		updated = true
+	}
+
+	if opacCR.ObjectMeta.OwnerReferences == nil {
+		ownerRef := *metav1.NewControllerRef(config, config.GroupVersionKind())
+		opacCR.ObjectMeta.OwnerReferences = []metav1.OwnerReference{ownerRef}
+		updated = true
+	}
+
+	if updated {
+		_, err := clients.Update(ctx, opacCR, metav1.UpdateOptions{})
+		if err != nil {
+			return nil, err
+		}
+		return nil, v1alpha1.RECONCILE_AGAIN_ERR
+	}
+
+	return opacCR, nil
+}
+
+// isOPACReady will check the status conditions of the OpenShiftPipelinesAsCode and return true if the OpenShiftPipelinesAsCode is ready.
+func isOPACReady(s *v1alpha1.OpenShiftPipelinesAsCode, err error) (bool, error) {
+	if s.GetStatus() != nil && s.GetStatus().GetCondition(apis.ConditionReady) != nil {
+		if strings.Contains(s.GetStatus().GetCondition(apis.ConditionReady).Message, v1alpha1.UpgradePending) {
+			return false, v1alpha1.DEPENDENCY_UPGRADE_PENDING_ERR
+		}
+	}
+	return s.Status.IsReady(), err
+}
+
+func EnsureOpenShiftPipelinesAsCodeCRNotExists(ctx context.Context, clients op.OpenShiftPipelinesAsCodeInterface) error {
+	if _, err := GetPAC(ctx, clients, v1alpha1.OpenShiftPipelinesAsCodeName); err != nil {
+		if apierrs.IsNotFound(err) {
+			// OpenShiftPipelinesAsCode CR is gone, hence return nil
+			return nil
+		}
+		return err
+	}
+	// if the Get was successful, try deleting the CR
+	if err := clients.Delete(ctx, v1alpha1.OpenShiftPipelinesAsCodeName, metav1.DeleteOptions{}); err != nil {
+		if apierrs.IsNotFound(err) {
+			// OpenShiftPipelinesAsCode CR is gone, hence return nil
+			return nil
+		}
+		return fmt.Errorf("OpenShiftPipelinesAsCode %q failed to delete: %v", v1alpha1.OpenShiftPipelinesAsCodeName, err)
+	}
+	// if the Delete API call was success,
+	// then return requeue_event
+	// so that in a subsequent reconcile call the absence of the CR is verified by one of the 2 checks above
+	return v1alpha1.RECONCILE_AGAIN_ERR
+}
diff --git a/third_party/github.com/hashicorp/golang-lru/simplelru/lru_interface.go b/third_party/github.com/hashicorp/golang-lru/simplelru/lru_interface.go
index 92d70934d..a0b97e3f7 100644
--- a/third_party/github.com/hashicorp/golang-lru/simplelru/lru_interface.go
+++ b/third_party/github.com/hashicorp/golang-lru/simplelru/lru_interface.go
@@ -34,6 +34,6 @@ type LRUCache interface {
 	// Clears all cache entries.
 	Purge()
 
-  // Resizes cache, returning number evicted
-  Resize(int) int
+	// Resizes cache, returning number evicted
+	Resize(int) int
 }
diff --git a/third_party/github.com/letsencrypt/boulder/core/proto/core.pb.go b/third_party/github.com/letsencrypt/boulder/core/proto/core.pb.go
index 02b3515bd..4793eac0f 100644
--- a/third_party/github.com/letsencrypt/boulder/core/proto/core.pb.go
+++ b/third_party/github.com/letsencrypt/boulder/core/proto/core.pb.go
@@ -7,10 +7,11 @@
 package proto
 
 import (
-	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	reflect "reflect"
 	sync "sync"
+
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 )
 
 const (
diff --git a/third_party/github.com/letsencrypt/boulder/sa/proto/sa.pb.go b/third_party/github.com/letsencrypt/boulder/sa/proto/sa.pb.go
index 044d5e07c..f657550e1 100644
--- a/third_party/github.com/letsencrypt/boulder/sa/proto/sa.pb.go
+++ b/third_party/github.com/letsencrypt/boulder/sa/proto/sa.pb.go
@@ -7,13 +7,14 @@
 package proto
 
 import (
+	reflect "reflect"
+	sync "sync"
+
 	proto "github.com/letsencrypt/boulder/core/proto"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	emptypb "google.golang.org/protobuf/types/known/emptypb"
 	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
diff --git a/third_party/github.com/letsencrypt/boulder/sa/proto/sa_grpc.pb.go b/third_party/github.com/letsencrypt/boulder/sa/proto/sa_grpc.pb.go
index ad28ec471..ef3255892 100644
--- a/third_party/github.com/letsencrypt/boulder/sa/proto/sa_grpc.pb.go
+++ b/third_party/github.com/letsencrypt/boulder/sa/proto/sa_grpc.pb.go
@@ -8,6 +8,7 @@ package proto
 
 import (
 	context "context"
+
 	proto "github.com/letsencrypt/boulder/core/proto"
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
diff --git a/third_party/github.com/tektoncd/operator/LICENSE b/third_party/github.com/tektoncd/operator/LICENSE
new file mode 100644
index 000000000..261eeb9e9
--- /dev/null
+++ b/third_party/github.com/tektoncd/operator/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.


Test patch:
diff --git a/pkg/apis/operator/v1alpha1/tektonconfig_default_test.go b/pkg/apis/operator/v1alpha1/tektonconfig_default_test.go
index 4aebfb1da..315bc56bd 100644
--- a/pkg/apis/operator/v1alpha1/tektonconfig_default_test.go
+++ b/pkg/apis/operator/v1alpha1/tektonconfig_default_test.go
@@ -120,3 +120,57 @@ func Test_SetDefaults_Triggers_Properties(t *testing.T) {
 		t.Error("Setting default failed for TektonConfig (spec.trigger.triggersProperties)")
 	}
 }
+
+func Test_SetDefaults_PipelineAsCode(t *testing.T) {
+	assert.NilError(t, os.Setenv("PLATFORM", "openshift"))
+	defer os.Clearenv()
+
+	// PAC disabled through addon
+	tc := &TektonConfig{
+		Spec: TektonConfigSpec{
+			Addon: Addon{
+				EnablePAC: ptr.Bool(false),
+			},
+		},
+	}
+	tc.SetDefaults(context.TODO())
+	assert.Equal(t, *tc.Spec.Platforms.OpenShift.PipelinesAsCode.Enable, false)
+	assert.Assert(t, tc.Spec.Addon.EnablePAC == nil)
+
+	// PAC enabled through addon, moving to openshiftPipelinesAsCode
+	tc = &TektonConfig{
+		Spec: TektonConfigSpec{
+			Addon: Addon{
+				EnablePAC: ptr.Bool(true),
+			},
+		},
+	}
+	tc.SetDefaults(context.TODO())
+	assert.Equal(t, *tc.Spec.Platforms.OpenShift.PipelinesAsCode.Enable, true)
+	assert.Assert(t, tc.Spec.Addon.EnablePAC == nil)
+
+	// New installation
+	tc = &TektonConfig{}
+	tc.SetDefaults(context.TODO())
+	assert.Equal(t, *tc.Spec.Platforms.OpenShift.PipelinesAsCode.Enable, true)
+	assert.Assert(t, tc.Spec.Addon.EnablePAC == nil)
+
+	// if PAC is enabled already then ignore addon pac field
+	tc = &TektonConfig{
+		Spec: TektonConfigSpec{
+			Addon: Addon{
+				EnablePAC: ptr.Bool(false),
+			},
+			Platforms: Platforms{
+				OpenShift: OpenShift{
+					PipelinesAsCode: &PipelinesAsCode{
+						Enable: ptr.Bool(true),
+					},
+				},
+			},
+		},
+	}
+	tc.SetDefaults(context.TODO())
+	assert.Equal(t, *tc.Spec.Platforms.OpenShift.PipelinesAsCode.Enable, true)
+	assert.Assert(t, tc.Spec.Addon.EnablePAC == nil)
+}
diff --git a/pkg/reconciler/openshift/tektonconfig/extension/pipelinesascode_test.go b/pkg/reconciler/openshift/tektonconfig/extension/pipelinesascode_test.go
new file mode 100644
index 000000000..0a1604081
--- /dev/null
+++ b/pkg/reconciler/openshift/tektonconfig/extension/pipelinesascode_test.go
@@ -0,0 +1,98 @@
+/*
+Copyright 2022 The Tekton Authors
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package extension
+
+import (
+	"context"
+	"testing"
+
+	"github.com/tektoncd/operator/pkg/reconciler/shared/tektonconfig/pipeline"
+
+	op "github.com/tektoncd/operator/pkg/client/clientset/versioned/typed/operator/v1alpha1"
+
+	"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
+	"github.com/tektoncd/operator/pkg/client/injection/client/fake"
+	util "github.com/tektoncd/operator/pkg/reconciler/common/testing"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	ts "knative.dev/pkg/reconciler/testing"
+)
+
+func TestEnsureOpenShiftPipelinesAsCodeExists(t *testing.T) {
+	ctx, _, _ := ts.SetupFakeContextWithCancel(t)
+	c := fake.Get(ctx)
+	tConfig := pipeline.GetTektonConfig()
+
+	// first invocation should create instance as it is non-existent and return RECONCILE_AGAIN_ERR
+	_, err := EnsureOpenShiftPipelinesAsCodeExists(ctx, c.OperatorV1alpha1().OpenShiftPipelinesAsCodes(), tConfig)
+	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 = EnsureOpenShiftPipelinesAsCodeExists(ctx, c.OperatorV1alpha1().OpenShiftPipelinesAsCodes(), tConfig)
+	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
+
+	// mark the instance ready
+	markOPACReady(t, ctx, c.OperatorV1alpha1().OpenShiftPipelinesAsCodes())
+
+	// next invocation should return nil error as the instance is ready
+	_, err = EnsureOpenShiftPipelinesAsCodeExists(ctx, c.OperatorV1alpha1().OpenShiftPipelinesAsCodes(), tConfig)
+	util.AssertEqual(t, err, nil)
+
+	// test update propagation from tektonConfig
+	tConfig.Spec.TargetNamespace = "foobar"
+	_, err = EnsureOpenShiftPipelinesAsCodeExists(ctx, c.OperatorV1alpha1().OpenShiftPipelinesAsCodes(), tConfig)
+	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
+
+	_, err = EnsureOpenShiftPipelinesAsCodeExists(ctx, c.OperatorV1alpha1().OpenShiftPipelinesAsCodes(), tConfig)
+	util.AssertEqual(t, err, nil)
+}
+
+func TestEnsureOpenShiftPipelinesAsCodeCRNotExists(t *testing.T) {
+	ctx, _, _ := ts.SetupFakeContextWithCancel(t)
+	c := fake.Get(ctx)
+
+	// when no instance exists, nil error is returned immediately
+	err := EnsureOpenShiftPipelinesAsCodeCRNotExists(ctx, c.OperatorV1alpha1().OpenShiftPipelinesAsCodes())
+	util.AssertEqual(t, err, nil)
+
+	// create an instance for testing other cases
+	tConfig := pipeline.GetTektonConfig()
+	_, err = EnsureOpenShiftPipelinesAsCodeExists(ctx, c.OperatorV1alpha1().OpenShiftPipelinesAsCodes(), tConfig)
+	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
+
+	// when an instance exists the first invoacation should make the delete API call and
+	// return RECONCILE_AGAI_ERROR. So that the deletion can be confirmed in a subsequent invocation
+	err = EnsureOpenShiftPipelinesAsCodeCRNotExists(ctx, c.OperatorV1alpha1().OpenShiftPipelinesAsCodes())
+	util.AssertEqual(t, err, v1alpha1.RECONCILE_AGAIN_ERR)
+
+	// when the instance is completely removed from a cluster, the function should return nil error
+	err = EnsureOpenShiftPipelinesAsCodeCRNotExists(ctx, c.OperatorV1alpha1().OpenShiftPipelinesAsCodes())
+	util.AssertEqual(t, err, nil)
+}
+
+func markOPACReady(t *testing.T, ctx context.Context, c op.OpenShiftPipelinesAsCodeInterface) {
+	t.Helper()
+	opac, err := c.Get(ctx, v1alpha1.OpenShiftPipelinesAsCodeName, metav1.GetOptions{})
+	util.AssertEqual(t, err, nil)
+	opac.Status.MarkDependenciesInstalled()
+	opac.Status.MarkPreReconcilerComplete()
+	opac.Status.MarkInstallerSetAvailable()
+	opac.Status.MarkInstallerSetReady()
+	opac.Status.MarkPostReconcilerComplete()
+	_, err = c.UpdateStatus(ctx, opac, metav1.UpdateOptions{})
+	util.AssertEqual(t, err, nil)
+}