Repository: shipwright-io/build
Pull request #629 (2021-03-01 08:25:14)

Add make target for generating crds through controller-gen
# Changes

This PR is for changing to use [controller-gen tool](https://github.com/kubernetes-sigs/controller-tools) from kubebuilder to generate CRDs 

Fixes https://github.com/shipwright-io/build/issues/579

-->

# Submitter Checklist

- [ ] Includes tests if functionality changed/was added
- [x] Includes docs if changes are user-facing
- [ ] [Set a kind label on this PR](https://prow.k8s.io/command-help#kind)  
- [ ] Release notes block has been filled in, or marked NONE

See [the contributor guide](https://github.com/shipwright-io/build/blob/master/CONTRIBUTING.md)
for details on coding conventions, github and prow interactions, and the code review process.

# Release Notes
Added a script and make target to install controller-gen tool and generate CRDs with this tool

<!--

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
```
-->


openshift-ci-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 **zhangtbj** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @zhangtbj` 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=shipwright-io%2Fbuild).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/shipwright-io/build/blob/master/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":["zhangtbj"]} -->
openshift-ci-robot: Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with `/test all`
mattcui: I am able to use controller-gen tool to generate CRDs successfully, the name of generated manifests is different with existing ones, the generated name has `shipwright.io_` prefix and plural noun like below: 

```
deploy/crds# ls
build.yaml     buildstrategy.yaml         shipwright.io_buildruns.yaml  shipwright.io_buildstrategies.yaml
buildrun.yaml  clusterbuildstrategy.yaml  shipwright.io_builds.yaml     shipwright.io_clusterbuildstrategies.yaml
```

So the 1st question is whether we need to use these generated names or rename to existing ones? Also there lead to another question about the location/directory where to save these crd files. The [operator-sdk 1.x migration doc](https://sdk.operatorframework.io/docs/building-operators/golang/migration/#what-was-changed) recommends to follow kubebuilder's convention to save these crds under `config/crd/bases`, we may still keep as it's for now or move to `config/crd/bases` for future to moving to operator-sdk 1.x.

I also compared the content of generated manifests with existing ones. There is not much different, there added a new annotation for `controller-gen.kubebuilder.io/version` in newly generated ones by controller-gen, and an empty `status` section at the bottom the file (Need to see if it's harmless to us).

```
# diff build.yaml shipwright.io_builds.yaml
0a1,2
>
> ---
3a6,8
>   annotations:
>     controller-gen.kubebuilder.io/version: v0.4.1
>   creationTimestamp: null
270a276,281
> status:
>   acceptedNames:
>     kind: ""
>     plural: ""
>   conditions: []
>   storedVersions: []
```

zhangtbj: Thanks Matt!

> So the 1st question is whether we need to use these generated names or rename to existing ones?

Can controller-gen tool  generate CRD name as our original name by leverage its command parameter directly? If no, I suggest to switch to the new name directly. The second folder problem is similar. I prefer to use a native/default way of the tool (no patch).

BTW, can we add our `DEVELOPMENT.md` document to tell new developer how to use it?
https://github.com/shipwright-io/build/blob/master/DEVELOPMENT.md
openshift-ci-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 **sbose78** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @sbose78` 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=shipwright-io%2Fbuild).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/shipwright-io/build/blob/master/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":["sbose78"]} -->
mattcui: > Thanks Matt!
> 
> > So the 1st question is whether we need to use these generated names or rename to existing ones?
> 
> Can controller-gen tool generate CRD name as our original name by leverage its command parameter directly? If no, I suggest to switch to the new name directly. The second folder problem is similar. I prefer to use a native/default way of the tool (no patch).
> 
> BTW, can we add our `DEVELOPMENT.md` document to tell new developer how to use it?
> https://github.com/shipwright-io/build/blob/master/DEVELOPMENT.md

Yes, I added a simple instruction in this doc.
qu1queee: @mattcui @HeavyWombat the names where changed in [here](https://github.com/shipwright-io/build/commit/d65ef2f3520406f90346c7427f6054202707017e#diff-b5e47b4c68801147f65c19616325c15f1d4f18357e2093a4ffbec8824a980063R3-R9) . I think also the operator-sdk (_when doing an `operator-sdk generate crds`_) usually tries to create the files with the same syntax `<scheme group>_<crd plural name>.yaml` . I´m wondering it those files renames are wrong and if this syntax is a best practice. @ImJasonH any opinions on this?, this files rename went via the PR where we change the domain name.


@mattcui one more thing, so I compared the files and I see this will introduce new fields in the CRD definition, as follows:

```yaml
$ dyff between build.yaml shipwright.io_builds.yaml
     _        __  __
   _| |_   _ / _|/ _|  between github.com/shipwright-io/build/deploy/crds/build.yaml
 / _' | | | | |_| |_       and github.com/shipwright-io/build/deploy/crds/shipwright.io_builds.yaml
| (_| | |_| |  _|  _|
 \__,_|\__, |_| |_|   returned two differences
        |___/

(root level)
+ one map entry added:
  status:
  │ acceptedNames:
  │ │ kind:
  │ │ plural:
  │ conditions: []
  │ storedVersions: []

metadata
  + two map entries added:
    annotations:
    │ controller-gen.kubebuilder.io/version: v0.4.1
    creationTimestamp: null
```


```yaml
$ dyff between buildrun.yaml shipwright.io_buildruns.yaml
     _        __  __
   _| |_   _ / _|/ _|  between github.com/shipwright-io/build/deploy/crds/buildrun.yaml
 / _' | | | | |_| |_       and github.com/shipwright-io/build/deploy/crds/shipwright.io_buildruns.yaml
| (_| | |_| |  _|  _|
 \__,_|\__, |_| |_|   returned two differences
        |___/

(root level)
+ one map entry added:
  status:
  │ acceptedNames:
  │ │ kind:
  │ │ plural:
  │ conditions: []
  │ storedVersions: []

metadata
  + two map entries added:
    annotations:
    │ controller-gen.kubebuilder.io/version: v0.4.1
    creationTimestamp: null

```


```yaml
$ dyff between buildstrategy.yaml shipwright.io_buildstrategies.yaml
     _        __  __
   _| |_   _ / _|/ _|  between github.com/shipwright-io/build/deploy/crds/buildstrategy.yaml
 / _' | | | | |_| |_       and github.com/shipwright-io/build/deploy/crds/shipwright.io_buildstrategies.yaml
| (_| | |_| |  _|  _|
 \__,_|\__, |_| |_|   returned two differences
        |___/

(root level)
+ one map entry added:
  status:
  │ acceptedNames:
  │ │ kind:
  │ │ plural:
  │ conditions: []
  │ storedVersions: []

metadata
  + two map entries added:
    annotations:
    │ controller-gen.kubebuilder.io/version: v0.4.1
    creationTimestamp: null
```


```yaml
$ dyff between clusterbuildstrategy.yaml shipwright.io_clusterbuildstrategies.yaml
     _        __  __
   _| |_   _ / _|/ _|  between github.com/shipwright-io/build/deploy/crds/clusterbuildstrategy.yaml
 / _' | | | | |_| |_       and github.com/shipwright-io/build/deploy/crds/shipwright.io_clusterbuildstrategies.yaml
| (_| | |_| |  _|  _|
 \__,_|\__, |_| |_|   returned two differences
        |___/

(root level)
+ one map entry added:
  status:
  │ acceptedNames:
  │ │ kind:
  │ │ plural:
  │ conditions: []
  │ storedVersions: []

metadata
  + two map entries added:
    annotations:
    │ controller-gen.kubebuilder.io/version: v0.4.1
    creationTimestamp: null
```

any ideas on why this is happening?
mattcui: > @mattcui @HeavyWombat the names where changed in [here](https://github.com/shipwright-io/build/commit/d65ef2f3520406f90346c7427f6054202707017e#diff-b5e47b4c68801147f65c19616325c15f1d4f18357e2093a4ffbec8824a980063R3-R9) . I think also the operator-sdk (_when doing an `operator-sdk generate crds`_) usually tries to create the files with the same syntax `<scheme group>_<crd plural name>.yaml` . I´m wondering it those files renames are wrong and if this syntax is a best practice. @ImJasonH any opinions on this?, this files rename went via the PR where we change the domain name.
> 
> @mattcui one more thing, so I compared the files and I see this will introduce new fields in the CRD definition, as follows:
> 
> ```yaml
> $ dyff between build.yaml shipwright.io_builds.yaml
>      _        __  __
>    _| |_   _ / _|/ _|  between github.com/shipwright-io/build/deploy/crds/build.yaml
>  / _' | | | | |_| |_       and github.com/shipwright-io/build/deploy/crds/shipwright.io_builds.yaml
> | (_| | |_| |  _|  _|
>  \__,_|\__, |_| |_|   returned two differences
>         |___/
> 
> (root level)
> + one map entry added:
>   status:
>   │ acceptedNames:
>   │ │ kind:
>   │ │ plural:
>   │ conditions: []
>   │ storedVersions: []
> 
> metadata
>   + two map entries added:
>     annotations:
>     │ controller-gen.kubebuilder.io/version: v0.4.1
>     creationTimestamp: null
> ```
> 
> ```yaml
> $ dyff between buildrun.yaml shipwright.io_buildruns.yaml
>      _        __  __
>    _| |_   _ / _|/ _|  between github.com/shipwright-io/build/deploy/crds/buildrun.yaml
>  / _' | | | | |_| |_       and github.com/shipwright-io/build/deploy/crds/shipwright.io_buildruns.yaml
> | (_| | |_| |  _|  _|
>  \__,_|\__, |_| |_|   returned two differences
>         |___/
> 
> (root level)
> + one map entry added:
>   status:
>   │ acceptedNames:
>   │ │ kind:
>   │ │ plural:
>   │ conditions: []
>   │ storedVersions: []
> 
> metadata
>   + two map entries added:
>     annotations:
>     │ controller-gen.kubebuilder.io/version: v0.4.1
>     creationTimestamp: null
> ```
> 
> ```yaml
> $ dyff between buildstrategy.yaml shipwright.io_buildstrategies.yaml
>      _        __  __
>    _| |_   _ / _|/ _|  between github.com/shipwright-io/build/deploy/crds/buildstrategy.yaml
>  / _' | | | | |_| |_       and github.com/shipwright-io/build/deploy/crds/shipwright.io_buildstrategies.yaml
> | (_| | |_| |  _|  _|
>  \__,_|\__, |_| |_|   returned two differences
>         |___/
> 
> (root level)
> + one map entry added:
>   status:
>   │ acceptedNames:
>   │ │ kind:
>   │ │ plural:
>   │ conditions: []
>   │ storedVersions: []
> 
> metadata
>   + two map entries added:
>     annotations:
>     │ controller-gen.kubebuilder.io/version: v0.4.1
>     creationTimestamp: null
> ```
> 
> ```yaml
> $ dyff between clusterbuildstrategy.yaml shipwright.io_clusterbuildstrategies.yaml
>      _        __  __
>    _| |_   _ / _|/ _|  between github.com/shipwright-io/build/deploy/crds/clusterbuildstrategy.yaml
>  / _' | | | | |_| |_       and github.com/shipwright-io/build/deploy/crds/shipwright.io_clusterbuildstrategies.yaml
> | (_| | |_| |  _|  _|
>  \__,_|\__, |_| |_|   returned two differences
>         |___/
> 
> (root level)
> + one map entry added:
>   status:
>   │ acceptedNames:
>   │ │ kind:
>   │ │ plural:
>   │ conditions: []
>   │ storedVersions: []
> 
> metadata
>   + two map entries added:
>     annotations:
>     │ controller-gen.kubebuilder.io/version: v0.4.1
>     creationTimestamp: null
> ```
> 
> any ideas on why this is happening?

I also posted the diff in [my comment](https://github.com/shipwright-io/build/pull/629#issuecomment-787936443) , the 1st difference, I think, it's controller-gen that adds itself `controller-gen.kubebuilder.io/version: v0.4.1` in the annotation. For the 2nd difference, the code and explanation are here -> https://github.com/kubernetes-sigs/controller-tools/blob/master/pkg/crd/spec.go#L167-L173, I think it's Ok if it's harmless to us.

Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a30982fe..22b381ec 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -125,16 +125,12 @@ jobs:
           run: |
             echo "# Pods:"
             kubectl -n shipwright-build get pod
-            PODS=$(kubectl -n shipwright-build get pod -o json)
+            PODS=$(kubectl -n build-operator get pod -o json)
             POD_NAME=$(echo "${PODS}" | jq -r '.items[] | select(.metadata.name | startswith("shipwright-build-controller-")) | .metadata.name')
-            if [ "${POD_NAME}" != "" ]; then
-              RESTART_COUNT=$(echo "${PODS}" | jq -r ".items[] | select(.metadata.name == \"${POD_NAME}\") | .status.containerStatuses[0].restartCount")
-              if [ "${RESTART_COUNT}" != "0" ]; then
-                echo "# Previous logs:"
-                kubectl -n shipwright-build logs "${POD_NAME}" --previous || true
-              fi
-              echo "# Logs:"
-              kubectl -n shipwright-build logs "${POD_NAME}"
-            else
-              echo "# Pod is missing, there are no logs to retrieve, bailing out..."
+            RESTART_COUNT=$(echo "${PODS}" | jq -r ".items[] | select(.metadata.name == \"${POD_NAME}\") | .status.containerStatuses[0].restartCount")
+            if [ "${RESTART_COUNT}" != "0" ]; then
+              echo "# Previous logs:"
+              kubectl -n build-operator logs "${POD_NAME}" --previous || true
             fi
+            echo "# Logs:"
+            kubectl -n shipwright-build logs "${POD_NAME}"
diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml
deleted file mode 100644
index 23e8f011..00000000
--- a/.github/workflows/nightly.yaml
+++ /dev/null
@@ -1,67 +0,0 @@
-name: Nightly Release
-
-on:
-  workflow_dispatch:  # Manual trigger
-
-  schedule:
-  - cron: '0 5 * * *' # 5 AM UTC = Midnight EST
-
-jobs:
-  nightly:
-    if: github.repository == "shipwright-io/build"
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@v2
-
-    - name: Get current date
-      id: date
-      run: echo "::set-output name=date::$(date +'%Y-%m-%d-%s')"
-
-    - name: Get latest nightly release upload_url
-      id: get_release
-      run: |
-        UPLOAD_URL=$(curl https://api.github.com/repos/${GITHUB_REPOSITORY}/releases | jq -r '.[] | select(.name | startswith("Nightly Releases")).upload_url' | tail -n 1 | cut -d"{" -f1)
-        echo "Latest nightly release upload URL is ${UPLOAD_URL}"
-        echo "::set-output name=upload_url::${UPLOAD_URL}"
-
-    - name: Install Go
-      uses: actions/setup-go@v2
-    - name: Install Ko
-      run: |
-        echo '::group:: install ko'
-        curl -L https://github.com/google/ko/releases/download/v0.8.0/ko_0.8.0_Linux_x86_64.tar.gz | tar xzf - ko
-        chmod +x ./ko
-        sudo mv ko /usr/local/bin
-        echo '::endgroup::'
-
-    - name: Ko resolve nightly.yaml
-      env:
-        REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
-        REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
-        IMAGE_HOST: quay.io
-        IMAGE: shipwright/shipwright-operator
-      run: |
-        make release
-        mv release.yaml nightly-${{ steps.date.outputs.date }}.yaml
-        mv release-debug.yaml nightly-${{ steps.date.outputs.date }}-debug.yaml
-
-    - name: Upload Release Asset
-      id: upload_release_asset 
-      uses: actions/upload-release-asset@v1
-      env:
-        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-      with:
-        upload_url: ${{ steps.get_release.outputs.upload_url }}?name=nightly-${{ steps.date.outputs.date }}.yaml
-        asset_path: ./nightly-${{ steps.date.outputs.date }}.yaml
-        asset_name: nightly-${{ steps.date.outputs.date}}.yaml
-        asset_content_type: application/x-yaml
-    - name: Upload Release Asset
-      id: upload_release_asset-debug
-      uses: actions/upload-release-asset@v1
-      env:
-        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-      with:
-        upload_url: ${{ steps.get_release.outputs.upload_url }}?name=nightly-${{ steps.date.outputs.date }}-debug.yaml
-        asset_path: ./nightly-${{ steps.date.outputs.date }}-debug.yaml
-        asset_name: nightly-${{ steps.date.outputs.date}}-debug.yaml
-        asset_content_type: application/x-yaml
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 71444ff0..ebd3da76 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -12,7 +12,6 @@ on:
 
 jobs:
   release:
-    if: github.repository == "shipwright-io/build"
     runs-on: ubuntu-latest
     steps:
     - name: Checkout code
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
index 2286bf4b..93c9c8f5 100644
--- a/DEVELOPMENT.md
+++ b/DEVELOPMENT.md
@@ -145,6 +145,10 @@ As you make changes to the code, you can redeploy your controller with:
    ```sh
    ko apply -P -R -f deploy/
    ```
+You may use the following command to re-generate CRDs of build and buildrun if you change their spec:
+   ```sh
+   make generate-crds
+   ```
 
 ### Tear it down
 
diff --git a/Makefile b/Makefile
index 65c9e3e7..67d9d26c 100644
--- a/Makefile
+++ b/Makefile
@@ -71,6 +71,10 @@ IMAGE_HOST ?= quay.io
 IMAGE ?= shipwright/shipwright-operator
 TAG ?= latest
 
+# options for generating crds with controller-gen
+CONTROLLER_GEN="${GOBIN}/controller-gen"
+CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
+
 .EXPORT_ALL_VARIABLES:
 
 default: build
@@ -279,3 +283,7 @@ kind-tekton:
 kind:
 	./hack/install-kind.sh
 	./hack/install-registry.sh
+
+generate-crds:
+	./hack/install-controller-gen.sh
+	"$(CONTROLLER_GEN)" "$(CRD_OPTIONS)" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=deploy/crds
diff --git a/OWNERS b/OWNERS
index d554897b..f5c3ebca 100644
--- a/OWNERS
+++ b/OWNERS
@@ -8,7 +8,6 @@ approvers:
 - adambkaplan
 - gabemontero
 - SaschaSchwarze0
-- HeavyWombat
 
 reviewers:
 - sbose78
@@ -25,5 +24,3 @@ reviewers:
 - adambkaplan
 - gabemontero
 - HeavyWombat
-- ImJasonH
-- mattcui
diff --git a/docs/build.md b/docs/build.md
index 7da92e23..c18a440e 100644
--- a/docs/build.md
+++ b/docs/build.md
@@ -83,7 +83,7 @@ The `Build` definition supports the following fields:
 A `Build` resource can specify a Git source, together with other parameters like:
 
 - `source.credentials.name` - For private repositories, the name is a reference to an existing secret on the same namespace containing the `ssh` data.
-- `source.revision` - An specific revision to select from the source repository, this can be a commit or branch name. If not defined, it will fallback to the git repository default branch.
+- `source.revision` - An specific revision to select from the source repository, this can be a commit or branch name.
 - `source.contextDir` - For repositories where the source code is not located at the root folder, you can specify this path here. Currently, only supported by `buildah`, `kaniko` and `buildpacks` build strategies.
 
 By default, the Build controller will validate that the Git repository exists. If the validation is not desired, users can define the `build.shipwright.io/verify.repository` annotation with `false`. For example:
diff --git a/docs/configuration.md b/docs/configuration.md
index d64d3d71..970ef557 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -18,7 +18,3 @@ The following environment variables are available:
 | `BUILD_CONTROLLER_LEASE_DURATION` |  Override the `LeaseDuration`, which is the duration that non-leader candidates will wait to force acquire leadership. |
 | `BUILD_CONTROLLER_RENEW_DEADLINE` |  Override the `RenewDeadline`, which is the duration that the acting master will retry refreshing leadership before giving up. |
 | `BUILD_CONTROLLER_RETRY_PERIOD` |  Override the `RetryPeriod`, which is the duration the LeaderElector clients should wait between tries of actions. |
-| `BUILD_MAX_CONCURRENT_RECONCILES` | The number of concurrent reconciles by the build controller. A value of 0 or lower will use the default from the [controller-runtime controller Options](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/controller#Options). Default is 0. |
-| `BUILDRUN_MAX_CONCURRENT_RECONCILES` | The number of concurrent reconciles by the buildrun controller. A value of 0 or lower will use the default from the [controller-runtime controller Options](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/controller#Options). Default is 0. |
-| `BUILDSTRATEGY_MAX_CONCURRENT_RECONCILES` | The number of concurrent reconciles by the buildstrategy controller. A value of 0 or lower will use the default from the [controller-runtime controller Options](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/controller#Options). Default is 0. |
-| `CLUSTERBUILDSTRATEGY_MAX_CONCURRENT_RECONCILES` | The number of concurrent reconciles by the clusterbuildstrategy controller. A value of 0 or lower will use the default from the [controller-runtime controller Options](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/controller#Options). Default is 0. |
diff --git a/hack/install-controller-gen.sh b/hack/install-controller-gen.sh
new file mode 100755
index 00000000..e4ae645b
--- /dev/null
+++ b/hack/install-controller-gen.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# Copyright The Shipwright Contributors
+# 
+# SPDX-License-Identifier: Apache-2.0
+
+#
+# Installs controller-gen utility via "go get".
+#
+
+set -eu
+
+# controller-gen version
+CONTROLLER_GEN_VERSION="${CONTROLLER_GEN_VERSION:-v0.4.1}"
+
+if [ ! -f "${GOPATH}/bin/controller-gen" ] ; then
+    echo "# Installing controller-gen..."
+    pushd "$(mktemp -d)" >/dev/null 2>&1
+    GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@"${CONTROLLER_GEN_VERSION}"
+    popd >/dev/null 2>&1
+fi
+
+# print controller-gen version
+controller-gen --version
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 98e30b3b..b49cd135 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -36,12 +36,6 @@ const (
 	leaseDurationEnvVar = "BUILD_CONTROLLER_LEASE_DURATION"
 	renewDeadlineEnvVar = "BUILD_CONTROLLER_RENEW_DEADLINE"
 	retryPeriodEnvVar   = "BUILD_CONTROLLER_RETRY_PERIOD"
-
-	// environment variable for the controllers
-	controllerBuildMaxConcurrentReconciles                = "BUILD_MAX_CONCURRENT_RECONCILES"
-	controllerBuildRunMaxConcurrentReconciles             = "BUILDRUN_MAX_CONCURRENT_RECONCILES"
-	controllerBuildStrategyMaxConcurrentReconciles        = "BUILDSTRATEGY_MAX_CONCURRENT_RECONCILES"
-	controllerClusterBuildStrategyMaxConcurrentReconciles = "CLUSTERBUILDSTRATEGY_MAX_CONCURRENT_RECONCILES"
 )
 
 var (
@@ -58,7 +52,6 @@ type Config struct {
 	KanikoContainerImage string
 	Prometheus           PrometheusConfig
 	ManagerOptions       ManagerOptions
-	Controllers          Controllers
 }
 
 // PrometheusConfig contains the specific configuration for the
@@ -77,19 +70,6 @@ type ManagerOptions struct {
 	RetryPeriod             *time.Duration
 }
 
-// Controllers contains the options for the different controllers
-type Controllers struct {
-	Build                ControllerOptions
-	BuildRun             ControllerOptions
-	BuildStrategy        ControllerOptions
-	ClusterBuildStrategy ControllerOptions
-}
-
-// ControllerOptions contains configurable options for a controller
-type ControllerOptions struct {
-	MaxConcurrentReconciles int
-}
-
 // NewDefaultConfig returns a new Config, with context timeout and default Kaniko image.
 func NewDefaultConfig() *Config {
 	return &Config{
@@ -103,20 +83,6 @@ func NewDefaultConfig() *Config {
 		ManagerOptions: ManagerOptions{
 			LeaderElectionNamespace: leaderElectionNamespaceDefault,
 		},
-		Controllers: Controllers{
-			Build: ControllerOptions{
-				MaxConcurrentReconciles: 0,
-			},
-			BuildRun: ControllerOptions{
-				MaxConcurrentReconciles: 0,
-			},
-			BuildStrategy: ControllerOptions{
-				MaxConcurrentReconciles: 0,
-			},
-			ClusterBuildStrategy: ControllerOptions{
-				MaxConcurrentReconciles: 0,
-			},
-		},
 	}
 }
 
@@ -164,19 +130,6 @@ func (c *Config) SetConfigFromEnv() error {
 		return err
 	}
 
-	if err := updateIntOption(&c.Controllers.Build.MaxConcurrentReconciles, controllerBuildMaxConcurrentReconciles); err != nil {
-		return err
-	}
-	if err := updateIntOption(&c.Controllers.BuildRun.MaxConcurrentReconciles, controllerBuildRunMaxConcurrentReconciles); err != nil {
-		return err
-	}
-	if err := updateIntOption(&c.Controllers.BuildStrategy.MaxConcurrentReconciles, controllerBuildStrategyMaxConcurrentReconciles); err != nil {
-		return err
-	}
-	if err := updateIntOption(&c.Controllers.ClusterBuildStrategy.MaxConcurrentReconciles, controllerClusterBuildStrategyMaxConcurrentReconciles); err != nil {
-		return err
-	}
-
 	return nil
 }
 
@@ -219,15 +172,3 @@ func updateBuildOperatorDurationOption(d **time.Duration, envVarName string) err
 
 	return nil
 }
-
-func updateIntOption(i *int, envVarName string) error {
-	if value := os.Getenv(envVarName); value != "" {
-		intValue, err := strconv.ParseInt(value, 10, 0)
-		if err != nil {
-			return err
-		}
-		*i = int(intValue)
-	}
-
-	return nil
-}
diff --git a/pkg/reconciler/build/controller.go b/pkg/reconciler/build/controller.go
index 671f8d5e..1acfce0d 100644
--- a/pkg/reconciler/build/controller.go
+++ b/pkg/reconciler/build/controller.go
@@ -38,21 +38,13 @@ type setOwnerReferenceFunc func(owner, object metav1.Object, scheme *runtime.Sch
 // and Start it when the Manager is Started.
 func Add(ctx context.Context, c *config.Config, mgr manager.Manager) error {
 	ctx = ctxlog.NewContext(ctx, "build-controller")
-	return add(ctx, mgr, NewReconciler(ctx, c, mgr, controllerutil.SetControllerReference), c.Controllers.Build.MaxConcurrentReconciles)
+	return add(ctx, mgr, NewReconciler(ctx, c, mgr, controllerutil.SetControllerReference))
 }
 
 // add adds a new Controller to mgr with r as the reconcile.Reconciler
-func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
-	// Create the controller options
-	options := controller.Options{
-		Reconciler: r,
-	}
-	if maxConcurrentReconciles > 0 {
-		options.MaxConcurrentReconciles = maxConcurrentReconciles
-	}
-
+func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler) error {
 	// Create a new controller
-	c, err := controller.New("build-controller", mgr, options)
+	c, err := controller.New("build-controller", mgr, controller.Options{Reconciler: r})
 	if err != nil {
 		return err
 	}
@@ -88,7 +80,8 @@ func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxCo
 	}
 
 	// Watch for changes to primary resource Build
-	if err = c.Watch(&source.Kind{Type: &build.Build{}}, &handler.EnqueueRequestForObject{}, pred); err != nil {
+	err = c.Watch(&source.Kind{Type: &build.Build{}}, &handler.EnqueueRequestForObject{}, pred)
+	if err != nil {
 		return err
 	}
 
diff --git a/pkg/reconciler/buildrun/controller.go b/pkg/reconciler/buildrun/controller.go
index de3b350e..e4aec599 100644
--- a/pkg/reconciler/buildrun/controller.go
+++ b/pkg/reconciler/buildrun/controller.go
@@ -33,21 +33,13 @@ type setOwnerReferenceFunc func(owner, object metav1.Object, scheme *runtime.Sch
 // and Start it when the Manager is Started.
 func Add(ctx context.Context, c *config.Config, mgr manager.Manager) error {
 	ctx = ctxlog.NewContext(ctx, "buildrun-controller")
-	return add(ctx, mgr, NewReconciler(ctx, c, mgr, controllerutil.SetControllerReference), c.Controllers.BuildRun.MaxConcurrentReconciles)
+	return add(ctx, mgr, NewReconciler(ctx, c, mgr, controllerutil.SetControllerReference))
 }
 
 // add adds a new Controller to mgr with r as the reconcile.Reconciler
-func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
-	// Create the controller options
-	options := controller.Options{
-		Reconciler: r,
-	}
-	if maxConcurrentReconciles > 0 {
-		options.MaxConcurrentReconciles = maxConcurrentReconciles
-	}
-
+func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler) error {
 	// Create a new controller
-	c, err := controller.New("buildrun-controller", mgr, options)
+	c, err := controller.New("buildrun-controller", mgr, controller.Options{Reconciler: r})
 	if err != nil {
 		return err
 	}
@@ -106,7 +98,8 @@ func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxCo
 	}
 
 	// Watch for changes to primary resource BuildRun
-	if err = c.Watch(&source.Kind{Type: &buildv1alpha1.BuildRun{}}, &handler.EnqueueRequestForObject{}, predBuildRun); err != nil {
+	err = c.Watch(&source.Kind{Type: &buildv1alpha1.BuildRun{}}, &handler.EnqueueRequestForObject{}, predBuildRun)
+	if err != nil {
 		return err
 	}
 
diff --git a/pkg/reconciler/buildrun/resources/taskrun.go b/pkg/reconciler/buildrun/resources/taskrun.go
index 0cac7346..f38ba9d2 100644
--- a/pkg/reconciler/buildrun/resources/taskrun.go
+++ b/pkg/reconciler/buildrun/resources/taskrun.go
@@ -180,10 +180,7 @@ func GenerateTaskRun(
 	strategy buildv1alpha1.BuilderStrategy,
 ) (*v1beta1.TaskRun, error) {
 
-	// Set revision to empty if the field is not specified in the Build.
-	// This will force Tekton Controller to do a git symbolic-link to HEAD
-	// giving back the default branch of the repository
-	revision := ""
+	revision := "master"
 	if build.Spec.Source.Revision != nil {
 		revision = *build.Spec.Source.Revision
 	}
diff --git a/pkg/reconciler/buildstrategy/controller.go b/pkg/reconciler/buildstrategy/controller.go
index 61394e49..95ff5521 100644
--- a/pkg/reconciler/buildstrategy/controller.go
+++ b/pkg/reconciler/buildstrategy/controller.go
@@ -22,25 +22,22 @@ import (
 // and Start it when the Manager is Started.
 func Add(ctx context.Context, c *config.Config, mgr manager.Manager) error {
 	ctx = ctxlog.NewContext(ctx, "buildstrategy-controller")
-	return add(ctx, mgr, NewReconciler(ctx, c, mgr), c.Controllers.BuildStrategy.MaxConcurrentReconciles)
+	return add(ctx, mgr, NewReconciler(ctx, c, mgr))
 }
 
 // add adds a new Controller to mgr with r as the reconcile.Reconciler
-func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
-	// Create the controller options
-	options := controller.Options{
-		Reconciler: r,
-	}
-	if maxConcurrentReconciles > 0 {
-		options.MaxConcurrentReconciles = maxConcurrentReconciles
-	}
-
+func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler) error {
 	// Create a new controller
-	c, err := controller.New("buildstrategy-controller", mgr, options)
+	c, err := controller.New("buildstrategy-controller", mgr, controller.Options{Reconciler: r})
 	if err != nil {
 		return err
 	}
 
 	// Watch for changes to primary resource BuildStrategy
-	return c.Watch(&source.Kind{Type: &buildv1alpha1.BuildStrategy{}}, &handler.EnqueueRequestForObject{})
+	err = c.Watch(&source.Kind{Type: &buildv1alpha1.BuildStrategy{}}, &handler.EnqueueRequestForObject{})
+	if err != nil {
+		return err
+	}
+
+	return nil
 }
diff --git a/pkg/reconciler/clusterbuildstrategy/controller.go b/pkg/reconciler/clusterbuildstrategy/controller.go
index 7508dfe8..363b9cf0 100644
--- a/pkg/reconciler/clusterbuildstrategy/controller.go
+++ b/pkg/reconciler/clusterbuildstrategy/controller.go
@@ -22,25 +22,22 @@ import (
 // and Start it when the Manager is Started.
 func Add(ctx context.Context, c *config.Config, mgr manager.Manager) error {
 	ctx = ctxlog.NewContext(ctx, "clusterbuildstrategy-controller")
-	return add(ctx, mgr, NewReconciler(ctx, c, mgr), c.Controllers.ClusterBuildStrategy.MaxConcurrentReconciles)
+	return add(ctx, mgr, NewReconciler(ctx, c, mgr))
 }
 
 // add adds a new Controller to mgr with r as the reconcile.Reconciler
-func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler, maxConcurrentReconciles int) error {
-	// Create the controller options
-	options := controller.Options{
-		Reconciler: r,
-	}
-	if maxConcurrentReconciles > 0 {
-		options.MaxConcurrentReconciles = maxConcurrentReconciles
-	}
-
+func add(ctx context.Context, mgr manager.Manager, r reconcile.Reconciler) error {
 	// Create a new controller
-	c, err := controller.New("clusterbuildstrategy-controller", mgr, options)
+	c, err := controller.New("clusterbuildstrategy-controller", mgr, controller.Options{Reconciler: r})
 	if err != nil {
 		return err
 	}
 
 	// Watch for changes to primary resource ClusterBuildStrategy
-	return c.Watch(&source.Kind{Type: &buildv1alpha1.ClusterBuildStrategy{}}, &handler.EnqueueRequestForObject{})
+	err = c.Watch(&source.Kind{Type: &buildv1alpha1.ClusterBuildStrategy{}}, &handler.EnqueueRequestForObject{})
+	if err != nil {
+		return err
+	}
+
+	return nil
 }
diff --git a/samples/build/build_ko_cr.yaml b/samples/build/build_ko_cr.yaml
index 63e55283..1f027ed0 100644
--- a/samples/build/build_ko_cr.yaml
+++ b/samples/build/build_ko_cr.yaml
@@ -1,5 +1,5 @@
 ---
-apiVersion: shipwright.io/v1alpha1
+apiVersion: build.dev/v1alpha1
 kind: Build
 metadata:
   name: ko-build
@@ -14,4 +14,4 @@ spec:
     name: ko
     kind: ClusterBuildStrategy
   output:
-    image: image-registry.openshift-image-registry.svc:5000/build-examples/shipwright-build
+    image: image-registry.openshift-image-registry.svc:5000/build-examples/build-operator
diff --git a/samples/buildrun/buildrun_ko_cr.yaml b/samples/buildrun/buildrun_ko_cr.yaml
index a7857afd..2a0a980e 100644
--- a/samples/buildrun/buildrun_ko_cr.yaml
+++ b/samples/buildrun/buildrun_ko_cr.yaml
@@ -1,5 +1,5 @@
 ---
-apiVersion: shipwright.io/v1alpha1
+apiVersion: build.dev/v1alpha1
 kind: BuildRun
 metadata:
   name: ko-buildrun
diff --git a/samples/buildstrategy/ko/buildstrategy_ko_cr.yaml b/samples/buildstrategy/ko/buildstrategy_ko_cr.yaml
index 79ddac83..ade6882d 100644
--- a/samples/buildstrategy/ko/buildstrategy_ko_cr.yaml
+++ b/samples/buildstrategy/ko/buildstrategy_ko_cr.yaml
@@ -1,5 +1,5 @@
 ---
-apiVersion: shipwright.io/v1alpha1
+apiVersion: build.dev/v1alpha1
 kind: ClusterBuildStrategy
 metadata:
   name: ko


Test patch:
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index e0fe9b4a..666e6ac2 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -76,22 +76,6 @@ var _ = Describe("Config", func() {
 				Expect(*config.ManagerOptions.RetryPeriod).To(Equal(time.Duration(10 * time.Second)))
 			})
 		})
-
-		It("should allow for an override of concurrent reconciles of the controllers", func() {
-			var overrides = map[string]string{
-				"BUILD_MAX_CONCURRENT_RECONCILES":                "2",
-				"BUILDRUN_MAX_CONCURRENT_RECONCILES":             "3",
-				"BUILDSTRATEGY_MAX_CONCURRENT_RECONCILES":        "4",
-				"CLUSTERBUILDSTRATEGY_MAX_CONCURRENT_RECONCILES": "5",
-			}
-
-			configWithEnvVariableOverrides(overrides, func(config *Config) {
-				Expect(config.Controllers.Build.MaxConcurrentReconciles).To(Equal(2))
-				Expect(config.Controllers.BuildRun.MaxConcurrentReconciles).To(Equal(3))
-				Expect(config.Controllers.BuildStrategy.MaxConcurrentReconciles).To(Equal(4))
-				Expect(config.Controllers.ClusterBuildStrategy.MaxConcurrentReconciles).To(Equal(5))
-			})
-		})
 	})
 })
 
diff --git a/pkg/reconciler/buildrun/resources/taskrun_test.go b/pkg/reconciler/buildrun/resources/taskrun_test.go
index 9b60f232..2bdf68d3 100644
--- a/pkg/reconciler/buildrun/resources/taskrun_test.go
+++ b/pkg/reconciler/buildrun/resources/taskrun_test.go
@@ -121,7 +121,7 @@ var _ = Describe("GenerateTaskrun", func() {
 
 			namespace = "build-test"
 			contextDir = "src"
-			revision = ""
+			revision = "master"
 			builderImage = &buildv1alpha1.Image{
 				ImageURL: "heroku/buildpacks:18",
 			}