Repository: tektoncd/operator
Pull request #660 (2022-03-08 05:48:00)

Add hub image env for openshift
This will add hub imahe env for db-migration, ui and api
in csv generation config and also add the hub db env in config.yaml
and fix the env name in operator.yaml

Also fixed the image value by putting a specific sha

# Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

- [ ] 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

```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 assign **sm43**
You can assign the PR to them by writing `/assign @sm43` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?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"]} -->
piyush-garg: /hold
nikhil-thomas: /approve
/lgtm
tekton-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/tektoncd/operator/pull/660#issuecomment-1061429856" title="LGTM">nikhil-thomas</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?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)~~ [nikhil-thomas]

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":[]} -->
tekton-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/tektoncd/operator/pull/660#issuecomment-1061429856" title="LGTM">nikhil-thomas</a>*, *<a href="https://github.com/tektoncd/operator/pull/660#pullrequestreview-902653338" title="Approved">vdemeester</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?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)~~ [nikhil-thomas,vdemeester]

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":[]} -->

Patch:
diff --git a/config/openshift/base/operator.yaml b/config/openshift/base/operator.yaml
index 9f7093810..1b9d27402 100644
--- a/config/openshift/base/operator.yaml
+++ b/config/openshift/base/operator.yaml
@@ -64,8 +64,8 @@ spec:
               key: DEFAULT_TARGET_NAMESPACE
         - name: CONFIG_OBSERVABILITY_NAME
           value: tekton-config-observability
-        - name: IMAGE_HUB_DB
-          value: registry.redhat.io/rhel8/postgresql-13:1-18
+        - name: IMAGE_HUB_TEKTON_HUB_DB
+          value: registry.redhat.io/rhel8/postgresql-13@sha256:6032adb3eac903ee8aa61f296ca9aaa57f5709e5673504b609222e042823f195
 #          - name: IMAGE_ADDONS_TKN_CLI_SERVE
 #            value: docker.io/rupali/serve-tkn:v2
 #          - name: IMAGE_ADDONS_PARAM_TKN_IMAGE
diff --git a/hack/fetch-releases.sh b/hack/fetch-releases.sh
index a7ce00d59..a0b619083 100755
--- a/hack/fetch-releases.sh
+++ b/hack/fetch-releases.sh
@@ -147,7 +147,7 @@ release_yaml_hub() {
     http_response=$(curl -s -L -o ${dest}/${fileName} -w "%{http_code}" ${url})
     echo url: ${url}
     if [[ $http_response != "200" ]]; then
-      echo "Error: failed to get $comp yaml, status code: $http_response"
+      echo "Error: failed to get ${component} yaml, status code: $http_response"
       exit 1
     fi
     echo "Info: Added Hub/$fileName:$version release yaml !!"
diff --git a/operatorhub/openshift/config.yaml b/operatorhub/openshift/config.yaml
index e42fb17d1..3844cf624 100644
--- a/operatorhub/openshift/config.yaml
+++ b/operatorhub/openshift/config.yaml
@@ -160,6 +160,35 @@ image-substitutions:
         containerName: openshift-pipelines-operator
         envKeys:
           - IMAGE_CHAINS_TEKTON_CHAINS_CONTROLLER
+- image: registry.redhat.io/rhel8/postgresql-13@sha256:6032adb3eac903ee8aa61f296ca9aaa57f5709e5673504b609222e042823f195
+  replaceLocations:
+    envTargets:
+      - deploymentName: openshift-pipelines-operator
+        containerName: openshift-pipelines-operator
+        envKeys:
+          - IMAGE_HUB_TEKTON_HUB_DB
+- image: registry.redhat.io/openshift-pipelines/pipelines-hub-db-migration-rhel8@
+  replaceLocations:
+    envTargets:
+      - deploymentName: openshift-pipelines-operator
+        containerName: openshift-pipelines-operator
+        envKeys:
+          - IMAGE_HUB_TEKTON_HUB_DB_MIGRATION
+- image: registry.redhat.io/openshift-pipelines/pipelines-hub-api-rhel8@
+  replaceLocations:
+    envTargets:
+      - deploymentName: openshift-pipelines-operator
+        containerName: openshift-pipelines-operator
+        envKeys:
+          - IMAGE_HUB_TEKTON_HUB_API
+- image: registry.redhat.io/openshift-pipelines/pipelines-hub-ui-rhel8@
+  replaceLocations:
+    envTargets:
+      - deploymentName: openshift-pipelines-operator
+        containerName: openshift-pipelines-operator
+        envKeys:
+          - IMAGE_HUB_TEKTON_HUB_UI
+
 # add thrid party images which are not replaced by operator
 # but pulled directly by tasks here
 defaultRelatedImages: []
diff --git a/pkg/reconciler/common/transformers.go b/pkg/reconciler/common/transformers.go
index e46af0025..4d3c84a4e 100644
--- a/pkg/reconciler/common/transformers.go
+++ b/pkg/reconciler/common/transformers.go
@@ -41,7 +41,7 @@ const (
 	TriggersImagePrefix           = "IMAGE_TRIGGERS_"
 	AddonsImagePrefix             = "IMAGE_ADDONS_"
 	ChainsImagePrefix             = "IMAGE_CHAINS_"
-	HubDbImagePrefix              = "IMAGE_HUB_"
+	HubImagePrefix                = "IMAGE_HUB_"
 
 	ArgPrefix   = "arg_"
 	ParamPrefix = "param_"
diff --git a/pkg/reconciler/kubernetes/tektonhub/tektonhub.go b/pkg/reconciler/kubernetes/tektonhub/tektonhub.go
index cea2baf4e..71732be69 100644
--- a/pkg/reconciler/kubernetes/tektonhub/tektonhub.go
+++ b/pkg/reconciler/kubernetes/tektonhub/tektonhub.go
@@ -440,7 +440,7 @@ func (r *Reconciler) setupAndCreateInstallerSet(ctx context.Context, manifestLoc
 
 	manifest = manifest.Filter(mf.Not(mf.Any(mf.ByKind("Secret"), mf.ByKind("Namespace"), mf.ByKind("ConfigMap"))))
 
-	images := common.ToLowerCaseKeys(common.ImagesFromEnv(common.HubDbImagePrefix))
+	images := common.ToLowerCaseKeys(common.ImagesFromEnv(common.HubImagePrefix))
 	trans := r.extension.Transformers(th)
 	extra := []mf.Transformer{
 		mf.InjectOwner(th),
diff --git a/pkg/reconciler/openshift/tektonhub/extension.go b/pkg/reconciler/openshift/tektonhub/extension.go
index ef89f910c..8eddeea06 100644
--- a/pkg/reconciler/openshift/tektonhub/extension.go
+++ b/pkg/reconciler/openshift/tektonhub/extension.go
@@ -56,6 +56,7 @@ var replaceVal = map[string]string{
 }
 
 var (
+	db  string = fmt.Sprintf("%s-%s", hubprefix, "db")
 	api string = fmt.Sprintf("%s-%s", hubprefix, "api")
 	ui  string = fmt.Sprintf("%s-%s", hubprefix, "ui")
 )
@@ -227,7 +228,7 @@ func UpdateDbDeployment() mf.Transformer {
 			return err
 		}
 
-		if d.Name == "db" {
+		if d.Name == db {
 			env := d.Spec.Template.Spec.Containers[0].Env
 
 			replaceEnv(env)


Test patch:
diff --git a/pkg/reconciler/openshift/tektonhub/testdata/update-db-deployment.yaml b/pkg/reconciler/openshift/tektonhub/testdata/update-db-deployment.yaml
index bec88c0bf..6f16a521f 100644
--- a/pkg/reconciler/openshift/tektonhub/testdata/update-db-deployment.yaml
+++ b/pkg/reconciler/openshift/tektonhub/testdata/update-db-deployment.yaml
@@ -15,21 +15,21 @@
 apiVersion: apps/v1
 kind: Deployment
 metadata:
-  name: db
+  name: tekton-hub-db
   labels:
-    app: db
+    app: tekton-hub-db
 spec:
   replicas: 1
   selector:
     matchLabels:
-      app: db
+      app: tekton-hub-db
   template:
     metadata:
       labels:
-        app: db
+        app: tekton-hub-db
     spec:
       containers:
-        - name: db
+        - name: tekton-hub-db
           image: postgres:13@sha256:260a98d976574b439712c35914fdcb840755233f79f3e27ea632543f78b7a21e
           imagePullPolicy: IfNotPresent
           ports:
@@ -39,22 +39,22 @@ spec:
             - name: POSTGRES_DB
               valueFrom:
                 secretKeyRef:
-                  name: db
+                  name: tekton-hub-db
                   key: POSTGRES_DB
             - name: POSTGRES_USER
               valueFrom:
                 secretKeyRef:
-                  name: db
+                  name: tekton-hub-db
                   key: POSTGRES_USER
             - name: POSTGRES_PASSWORD
               valueFrom:
                 secretKeyRef:
-                  name: db
+                  name: tekton-hub-db
                   key: POSTGRES_PASSWORD
             - name: PGDATA
               value: /var/lib/postgresql/data/pgdata
           volumeMounts:
-            - name: db
+            - name: tekton-hub-db
               mountPath: /var/lib/postgresql/data
           readinessProbe:
             exec:
@@ -69,7 +69,7 @@ spec:
             timeoutSeconds: 2
             periodSeconds: 15
       volumes:
-        - name: db
+        - name: tekton-hub-db
           persistentVolumeClaim:
-            claimName: db
+            claimName: tekton-hub-db
       restartPolicy: Always
\ No newline at end of file