Skip to content

Commit

Permalink
Add make target for generating crds through controller-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcui committed Mar 3, 2021
1 parent 965569b commit beada30
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
24 changes: 24 additions & 0 deletions hack/install-controller-gen.sh
Original file line number Diff line number Diff line change
@@ -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
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

0 comments on commit beada30

Please sign in to comment.