Repository: tektoncd/operator
Pull request #1221 (2022-12-15 04:43:15)

[release-v0.63.x] Installerset client: fixes custom set update case
This is an automated cherry-pick of #1220

/assign sm43

```release-note
Your release note here
```

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 **nikhil-thomas** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @nikhil-thomas` in a comment when ready.

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/release-v0.63.x/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":["nikhil-thomas"]} -->
sm43: /lgtm
/approve
tekton-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/tektoncd/operator/pull/1221#issuecomment-1352552564" title="Approved">sm43</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/release-v0.63.x/OWNERS)~~ [sm43]

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/pkg/reconciler/kubernetes/tektoninstallerset/client/update.go b/pkg/reconciler/kubernetes/tektoninstallerset/client/update.go
index 69fc0f684..81e2b3c46 100644
--- a/pkg/reconciler/kubernetes/tektoninstallerset/client/update.go
+++ b/pkg/reconciler/kubernetes/tektoninstallerset/client/update.go
@@ -32,32 +32,22 @@ import (
 func (i *InstallerSetClient) update(ctx context.Context, comp v1alpha1.TektonComponent, toBeUpdatedIS []v1alpha1.TektonInstallerSet, manifest *mf.Manifest, filterAndTransform FilterAndTransform, isType string) ([]v1alpha1.TektonInstallerSet, error) {
 	logger := logging.FromContext(ctx).With("kind", i.resourceKind, "type", isType)
 
-	switch isType {
-	case InstallerTypeMain:
+	if isType == InstallerTypeMain {
 		sets, err := i.updateMainSets(ctx, comp, toBeUpdatedIS, manifest, filterAndTransform)
 		if err != nil {
 			logger.Errorf("installer set update failed for main type: %v", err)
 			return sets, err
 		}
 		return sets, nil
-
-	case InstallerTypePre, InstallerTypePost:
-		logger.Infof("updating installer set: %v", toBeUpdatedIS[0].GetName())
-		updatedSet, err := i.updateSet(ctx, comp, toBeUpdatedIS[0], manifest, filterAndTransform)
-		if err != nil {
-			return nil, fmt.Errorf("failed to update installerset : %v", err)
-		}
-		logger.Infof("updated installer set: %v", toBeUpdatedIS[0].GetName())
-		return []v1alpha1.TektonInstallerSet{*updatedSet}, nil
-
-	case InstallerTypeCustom:
-	// TODO
-
-	default:
-		return nil, fmt.Errorf("invalid installer set type")
 	}
 
-	return nil, nil
+	logger.Infof("updating installer set: %v", toBeUpdatedIS[0].GetName())
+	updatedSet, err := i.updateSet(ctx, comp, toBeUpdatedIS[0], manifest, filterAndTransform)
+	if err != nil {
+		return nil, fmt.Errorf("failed to update installerset : %v", err)
+	}
+	logger.Infof("updated installer set: %v", toBeUpdatedIS[0].GetName())
+	return []v1alpha1.TektonInstallerSet{*updatedSet}, nil
 }
 
 func (i *InstallerSetClient) updateMainSets(ctx context.Context, comp v1alpha1.TektonComponent, toBeUpdatedIS []v1alpha1.TektonInstallerSet, manifest *mf.Manifest, filterAndTransform FilterAndTransform) ([]v1alpha1.TektonInstallerSet, error) {


Test patch:
diff --git a/pkg/reconciler/kubernetes/tektoninstallerset/client/update_test.go b/pkg/reconciler/kubernetes/tektoninstallerset/client/update_test.go
index a6ce02dd6..1b5e13837 100644
--- a/pkg/reconciler/kubernetes/tektoninstallerset/client/update_test.go
+++ b/pkg/reconciler/kubernetes/tektoninstallerset/client/update_test.go
@@ -65,6 +65,27 @@ func TestInstallerSetClient_Update(t *testing.T) {
 		wantIS     int
 		wantErr    error
 	}{
+		{
+			name:    "update custom set",
+			setType: InstallerTypeCustom,
+			existingIS: []v1alpha1.TektonInstallerSet{
+				{
+					ObjectMeta: metav1.ObjectMeta{
+						Name: "addon-custom-set-asdas",
+						Annotations: map[string]string{
+							v1alpha1.LastAppliedHashKey: "custom",
+						},
+					},
+					Spec: v1alpha1.TektonInstallerSetSpec{
+						Manifests: []unstructured.Unstructured{
+							serviceAccount, deployment,
+						},
+					},
+				},
+			},
+			resources: []unstructured.Unstructured{serviceAccount, deployment},
+			wantErr:   nil,
+		},
 		{
 			name:    "update pre set",
 			setType: InstallerTypePre,