Repository: tektoncd/operator
Pull request #661 (2022-03-08 08:43:10)

Fixes the db name in transformer in case of openshift
As we are adding `tekton-hub` as prefix so in the transformer
we need to check with name as `tekton-hub-db` instead of db,
so this patch changes check with name as `tekton-hub-db`

Signed-off-by: Puneet Punamiya <ppunamiy@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:

- [ ] 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

<!--
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
```
-->
```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 **vdemeester**
You can assign the PR to them by writing `/assign @vdemeester` 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":["vdemeester"]} -->
piyush-garg: /lgtm
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/reconciler/openshift/tektonhub/extension.go](https://storage.cloud.google.com/tekton-prow/pr-logs/pull/tektoncd_operator/661/pull-tekton-operator-go-coverage/1501116367187742721/artifacts/line-cov.html#file0) | 23.8% | 6.7% | -17.1

tekton-robot: @PuneetPunamiya: The following test **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-tekton-operator-unit-tests | b97852259abc4ef4f2a5820c856d565ffdaf18c6 | [link](https://tekton-releases.appspot.com/build/tekton-prow/pr-logs/pull/tektoncd_operator/661/pull-tekton-operator-unit-tests/1501116367187742723/) | `/test pull-tekton-operator-unit-tests`

[Full PR test history](https://tekton-releases.appspot.com/pr/tektoncd_operator/661). [Your PR dashboard](https://prow.tekton.dev/pr/PuneetPunamiya).

<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: @PuneetPunamiya: The following test **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-tekton-operator-unit-tests | b97852259abc4ef4f2a5820c856d565ffdaf18c6 | [link](https://tekton-releases.appspot.com/build/tekton-prow/pr-logs/pull/tektoncd_operator/661/pull-tekton-operator-unit-tests/1501116367187742723/) | `/test pull-tekton-operator-unit-tests`

[Full PR test history](https://tekton-releases.appspot.com/pr/tektoncd_operator/661). [Your PR dashboard](https://prow.tekton.dev/pr/PuneetPunamiya).

<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: New changes are detected. LGTM label has been removed.

Patch:
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/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