Repository: tektoncd/operator
Pull request #371 (2021-07-29 13:33:54)

[OpenShift] Removes external reference in openshift payload
This removes external reference for one of pipelines images in
the payload. this removes it and add no image available instead
of a gcr image.

Signed-off-by: Shivam Mukhade <smukhade@redhat.com>

# Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

- [x] 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 assign **sthaha**
You can assign the PR to them by writing `/assign @sthaha` 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":["sthaha"]} -->
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/common/transformer.go](https://storage.cloud.google.com/tekton-prow/pr-logs/pull/tektoncd_operator/371/pull-tekton-operator-go-coverage/1420739487998152706/artifacts/line-cov.html#file0) | 87.8% | 78.3% | -9.5

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

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

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

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

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

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

<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/reconciler/openshift/common/transformer.go](https://storage.cloud.google.com/tekton-prow/pr-logs/pull/tektoncd_operator/371/pull-tekton-operator-go-coverage/1420931251639947267/artifacts/line-cov.html#file0) | 87.8% | 85.7% | -2.0

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

This pull-request has been approved by: *<a href="https://github.com/tektoncd/operator/pull/371#pullrequestreview-718936738" 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)~~ [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":[]} -->
nikhil-thomas: /lgtm

Patch:
diff --git a/pkg/reconciler/openshift/common/transformer.go b/pkg/reconciler/openshift/common/transformer.go
index 33caacc1f..8b8a4b874 100644
--- a/pkg/reconciler/openshift/common/transformer.go
+++ b/pkg/reconciler/openshift/common/transformer.go
@@ -39,7 +39,7 @@ import (
 
 // UpdateDeployments will also remove runAsUser from container
 
-func UpdateDeployments(prefix string, replaceImg map[string]string, skipImages []string) mf.Transformer {
+func UpdateDeployments(prefix string, replaceImg map[string]string) mf.Transformer {
 	return func(u *unstructured.Unstructured) error {
 		if u.GetKind() != "Deployment" {
 			return nil
@@ -59,10 +59,6 @@ func UpdateDeployments(prefix string, replaceImg map[string]string, skipImages [
 
 			// Prefix Images in Args if there
 			for i := 0; i < len(c.Args); i++ {
-				if valueInArr(skipImages, c.Args[i]) {
-					i++
-					continue
-				}
 				val, ok := replaceImg[c.Args[i]]
 				if ok {
 					c.Args[i+1] = val
@@ -94,15 +90,6 @@ func prefixImage(prefix, img string) string {
 	return prefix + arr[len(arr)-1]
 }
 
-func valueInArr(arr []string, val string) bool {
-	for _, v := range arr {
-		if v == val {
-			return true
-		}
-	}
-	return false
-}
-
 // RemoveRunAsGroup will remove runAsGroup from all container in a deployment
 func RemoveRunAsGroup() mf.Transformer {
 	return func(u *unstructured.Unstructured) error {
diff --git a/pkg/reconciler/openshift/tektonpipeline/extension.go b/pkg/reconciler/openshift/tektonpipeline/extension.go
index 93b315ffc..32cc0059b 100644
--- a/pkg/reconciler/openshift/tektonpipeline/extension.go
+++ b/pkg/reconciler/openshift/tektonpipeline/extension.go
@@ -49,9 +49,9 @@ const (
 
 var (
 	replaceImgs = map[string]string{
-		"-shell-image": "registry.access.redhat.com/ubi8/ubi-minimal:latest",
+		"-shell-image":  "registry.access.redhat.com/ubi8/ubi-minimal:latest",
+		"-gsutil-image": "no-image-available",
 	}
-	skipImgs = []string{"-gsutil-image"}
 )
 
 func OpenShiftExtension(ctx context.Context) common.Extension {
@@ -81,7 +81,7 @@ func (oe openshiftExtension) Transformers(comp v1alpha1.TektonComponent) []mf.Tr
 	return []mf.Transformer{
 		common.InjectLabelOnNamespace(monitoringLabel),
 		occommon.ApplyCABundles,
-		occommon.UpdateDeployments(pipelinesPrefix, replaceImgs, skipImgs),
+		occommon.UpdateDeployments(pipelinesPrefix, replaceImgs),
 	}
 }
 func (oe openshiftExtension) PreReconcile(ctx context.Context, tc v1alpha1.TektonComponent) error {
diff --git a/pkg/reconciler/openshift/tektontrigger/extension.go b/pkg/reconciler/openshift/tektontrigger/extension.go
index 976c84028..1f71d76f4 100644
--- a/pkg/reconciler/openshift/tektontrigger/extension.go
+++ b/pkg/reconciler/openshift/tektontrigger/extension.go
@@ -35,7 +35,7 @@ type openshiftExtension struct{}
 
 func (oe openshiftExtension) Transformers(comp v1alpha1.TektonComponent) []mf.Transformer {
 	return []mf.Transformer{
-		occommon.UpdateDeployments(triggersPrefix, map[string]string{}, []string{}),
+		occommon.UpdateDeployments(triggersPrefix, map[string]string{}),
 		occommon.RemoveRunAsGroup(),
 		occommon.ApplyCABundles,
 	}


Test patch:
diff --git a/pkg/reconciler/openshift/common/testdata/test-prefix-images-expected.yaml b/pkg/reconciler/openshift/common/testdata/test-prefix-images-expected.yaml
index a5262bf52..6a4f2ca5c 100644
--- a/pkg/reconciler/openshift/common/testdata/test-prefix-images-expected.yaml
+++ b/pkg/reconciler/openshift/common/testdata/test-prefix-images-expected.yaml
@@ -63,7 +63,7 @@ spec:
             "-pr-image", "quay.io/openshift-pipeline/tektoncd-pipeline-pullrequest-init:v0.24.3",
 
             # This is gcr.io/google.com/cloudsdktool/cloud-sdk:302.0.0-slim
-            "-gsutil-image", "gcr.io/google.com/cloudsdktool/cloud-sdk@sha256:27b2c22bf259d9bc1a291e99c63791ba0c27a04d2db0a43241ba0f1f20f4067f",
+            "-gsutil-image", "no-image-available",
             # The shell image must be root in order to create directories and copy files to PVCs.
             # gcr.io/distroless/base:debug as of Apirl 17, 2021
             # image shall not contains tag, so it will be supported on a runtime like cri-o
diff --git a/pkg/reconciler/openshift/common/transformer_test.go b/pkg/reconciler/openshift/common/transformer_test.go
index d44f6c678..18bf0a46b 100644
--- a/pkg/reconciler/openshift/common/transformer_test.go
+++ b/pkg/reconciler/openshift/common/transformer_test.go
@@ -39,12 +39,11 @@ func TestUpdateDeployments(t *testing.T) {
 	pipelinesPrefix := "quay.io/openshift-pipeline/tektoncd-pipeline-"
 
 	replaceImages := map[string]string{
-		"-shell-image": "registry.access.redhat.com/ubi8/ubi-minimal:latest",
+		"-shell-image":  "registry.access.redhat.com/ubi8/ubi-minimal:latest",
+		"-gsutil-image": "no-image-available",
 	}
-	skip := []string{
-		"-gsutil-image",
-	}
-	newManifest, err := manifest.Transform(UpdateDeployments(pipelinesPrefix, replaceImages, skip))
+
+	newManifest, err := manifest.Transform(UpdateDeployments(pipelinesPrefix, replaceImages))
 	assert.NilError(t, err)
 
 	got := &appsv1.Deployment{}
@@ -75,7 +74,7 @@ func TestUpdateDeploymentsTriggers(t *testing.T) {
 
 	triggersPrefix := "quay.io/openshift-pipeline/tektoncd-triggers-"
 
-	newManifest, err := manifest.Transform(UpdateDeployments(triggersPrefix, map[string]string{}, []string{}))
+	newManifest, err := manifest.Transform(UpdateDeployments(triggersPrefix, map[string]string{}))
 	assert.NilError(t, err)
 	newManifest, err = newManifest.Transform(RemoveRunAsGroup())
 	assert.NilError(t, err)
@@ -108,7 +107,7 @@ func TestUpdateDeploymentsInterceptor(t *testing.T) {
 
 	triggersPrefix := "quay.io/openshift-pipeline/tektoncd-triggers-"
 
-	newManifest, err := manifest.Transform(UpdateDeployments(triggersPrefix, map[string]string{}, []string{}))
+	newManifest, err := manifest.Transform(UpdateDeployments(triggersPrefix, map[string]string{}))
 	assert.NilError(t, err)
 	newManifest, err = newManifest.Transform(RemoveRunAsGroup())
 	assert.NilError(t, err)