Repository: tektoncd/operator (go)

Issue:
TektonInstallerSet created have each resource twice 
When we read resources from ko data and create installer set, the installer set has 2 copies of each resource.

for eg,
In addons, for clustertasks, when we read clustertasks from kodata [here](https://github.com/tektoncd/operator/blob/3c77c775a7464cb8fd42e4addace86298d5d39df/pkg/reconciler/openshift/tektonaddon/tektonaddon.go#L329) -> it calls [`applyAddons`](https://github.com/tektoncd/operator/blob/3c77c775a7464cb8fd42e4addace86298d5d39df/pkg/reconciler/openshift/tektonaddon/tektonaddon.go#L481)
in apply addon we pass the path of the directory to ` common.AppendManifest(manifest, addonLocation)` and it
reads all the resources at the location and returns inside the manifest obj
but the manifest has 2 copies of each resource so manifest is getting bigger.

It is probably issue with [AppendManifest](https://github.com/tektoncd/operator/blob/3c77c775a7464cb8fd42e4addace86298d5d39df/pkg/reconciler/common/releases.go#L176)

To reproduce the issue
1. install operator using `make TARGET=openshfit` apply` on Openshift
2. let `all` profile install all components
3. for addons there would 4 installler set created
4. check any installer set if there are 2 instances of each resource eg. in clustertask `addon-clustertask- ` installerset there would be 2 buildah clustertask which are same. 


Pull request:
Fixes AppendManifest used to read files from kodata
Previously, if we pass a path to AppendManifest
for ex. `/kodata/tekton/abc.yaml` and later
        `/kodata/tekton/`
both use to read the file and add in the manifest, which
would make manifest to have the same resource twice.

This patch updates the AppendManifest func to use mf.ManifestFrom
    which will recursively read all files from a location by passing
    the path to it.

Closes #425 

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:

- [ ] 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
```
-->


Patch:
diff --git a/pkg/reconciler/common/releases.go b/pkg/reconciler/common/releases.go
index 1cdbbdf71..f3b79d341 100644
--- a/pkg/reconciler/common/releases.go
+++ b/pkg/reconciler/common/releases.go
@@ -174,19 +174,10 @@ func latestRelease(instance v1alpha1.TektonComponent) string {
 }
 
 func AppendManifest(manifest *mf.Manifest, yamlLocation string) error {
-	var files []string
-	if err := filepath.Walk(yamlLocation, func(path string, info os.FileInfo, err error) error {
-		files = append(files, path)
-		return nil
-	}); err != nil {
+	m, err := mf.ManifestFrom(mf.Recursive(yamlLocation))
+	if err != nil {
 		return err
 	}
-	for i := range files {
-		m, err := Fetch(files[i])
-		if err != nil {
-			return err
-		}
-		*manifest = manifest.Append(m)
-	}
+	*manifest = manifest.Append(m)
 	return nil
 }


Test patch:
diff --git a/pkg/reconciler/common/releases_test.go b/pkg/reconciler/common/releases_test.go
index e757a28cf..f3d2bfd34 100644
--- a/pkg/reconciler/common/releases_test.go
+++ b/pkg/reconciler/common/releases_test.go
@@ -20,6 +20,7 @@ import (
 	"os"
 	"testing"
 
+	mf "github.com/manifestival/manifestival"
 	"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
 	util "github.com/tektoncd/operator/pkg/reconciler/common/testing"
 )
@@ -47,3 +48,28 @@ func TestListReleases(t *testing.T) {
 	util.AssertEqual(t, err, nil)
 	util.AssertDeepEqual(t, version, expectedVersionList)
 }
+
+func TestAppendManifest(t *testing.T) {
+
+	// Case 1
+	var manifest mf.Manifest
+	err := AppendManifest(&manifest, "testdata/kodata/tekton-addon")
+	if err != nil {
+		t.Fatal("failed to read yaml: ", err)
+	}
+
+	if len(manifest.Resources()) != 3 {
+		t.Fatalf("failed to find expected number of resource: %d found, expected 3", len(manifest.Resources()))
+	}
+
+	// Case 2
+	var newManifest mf.Manifest
+	err = AppendManifest(&newManifest, "testdata/kodata/tekton-addon/0.0.1")
+	if err != nil {
+		t.Fatal("failed to read yaml: ", err)
+	}
+
+	if len(newManifest.Resources()) != 1 {
+		t.Fatalf("failed to find expected number of resource: %d found, expected 3", len(newManifest.Resources()))
+	}
+}
diff --git a/pkg/reconciler/common/testdata/kodata/tekton-addon/0.0.2/01-clustertriggerbindings/bitbucket.yaml b/pkg/reconciler/common/testdata/kodata/tekton-addon/0.0.2/01-clustertriggerbindings/bitbucket.yaml
new file mode 100644
index 000000000..e338a4da1
--- /dev/null
+++ b/pkg/reconciler/common/testdata/kodata/tekton-addon/0.0.2/01-clustertriggerbindings/bitbucket.yaml
@@ -0,0 +1,22 @@
+apiVersion: triggers.tekton.dev/v1alpha1
+kind: ClusterTriggerBinding
+metadata:
+  name: bitbucket-pullreq-0.0.2
+spec:
+  params:
+    - name: gitrepo-url
+      value: $(body.pullRequest.fromRef.repository.links.clone[0].href)
+    - name: pullreq-sha
+      value: $(body.pullRequest.fromRef.latestCommit)
+    - name: pullreq-state
+      value: $(body.pullRequest.state)
+    - name: pullreq-number
+      value: $(body.pullRequest.id)
+    - name: pullreq-repo-name
+      value: $(body.pullRequest.toRef.repository.name)
+    - name: pullreq-html-url
+      value: $(body.pullRequest.links.self[0].href)
+    - name: pullreq-title
+      value: $(body.pullRequest.title)
+    - name: user-type
+      value: $(body.pullRequest.author.user.type)
diff --git a/pkg/reconciler/common/testdata/kodata/tekton-addon/bitbucket-1.yaml b/pkg/reconciler/common/testdata/kodata/tekton-addon/bitbucket-1.yaml
new file mode 100644
index 000000000..eafb7e1e6
--- /dev/null
+++ b/pkg/reconciler/common/testdata/kodata/tekton-addon/bitbucket-1.yaml
@@ -0,0 +1,22 @@
+apiVersion: triggers.tekton.dev/v1alpha1
+kind: ClusterTriggerBinding
+metadata:
+  name: bitbucket-pullreq-no-version
+spec:
+  params:
+    - name: gitrepo-url
+      value: $(body.pullRequest.fromRef.repository.links.clone[0].href)
+    - name: pullreq-sha
+      value: $(body.pullRequest.fromRef.latestCommit)
+    - name: pullreq-state
+      value: $(body.pullRequest.state)
+    - name: pullreq-number
+      value: $(body.pullRequest.id)
+    - name: pullreq-repo-name
+      value: $(body.pullRequest.toRef.repository.name)
+    - name: pullreq-html-url
+      value: $(body.pullRequest.links.self[0].href)
+    - name: pullreq-title
+      value: $(body.pullRequest.title)
+    - name: user-type
+      value: $(body.pullRequest.author.user.type)