Skip to content

Commit

Permalink
Generate CRDs with structural schema (#1885)
Browse files Browse the repository at this point in the history
* generating CRDs with controller-tools and embedding in binary

Signed-off-by: Adnan Abdulhussein <[email protected]>
  • Loading branch information
Adnan Abdulhussein authored and skriss committed Sep 23, 2019
1 parent dc11e2a commit 5e22f9c
Show file tree
Hide file tree
Showing 18 changed files with 2,028 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions hack/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ RUN mkdir -p /go/src/k8s.io && \
git clone -b kubernetes-1.15.3 https://github.com/kubernetes/apimachinery && \
# vendor code-generator go modules to be compatible with pre-1.15
cd /go/src/k8s.io/code-generator && GO111MODULE=on go mod vendor && \
go get -d sigs.k8s.io/controller-tools/cmd/controller-gen && \
cd /go/src/sigs.k8s.io/controller-tools && GO111MODULE=on go mod vendor && \
go get golang.org/x/tools/cmd/goimports && \
cd /go/src/golang.org/x/tools && \
git checkout 40a48ad93fbe707101afb2099b738471f70594ec && \
Expand Down
136 changes: 136 additions & 0 deletions hack/crd-gen/main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions hack/update-generated-crd-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,27 @@ if [[ ! -d "${GOPATH}/src/k8s.io/code-generator" ]]; then
exit 1
fi

cd ${GOPATH}/src/k8s.io/code-generator
if [[ ! -d "${GOPATH}/src/sigs.k8s.io/controller-tools" ]]; then
echo "sigs.k8s.io/controller-tools missing from GOPATH"
exit 1
fi

./generate-groups.sh \
${GOPATH}/src/k8s.io/code-generator/generate-groups.sh \
all \
github.com/heptio/velero/pkg/generated \
github.com/heptio/velero/pkg/apis \
"velero:v1" \
--go-header-file ${GOPATH}/src/github.com/heptio/velero/hack/boilerplate.go.txt \
$@

if [[ "$@" == "--verify-only" ]]; then
# skip generating CRD manifests
exit
fi

go run ${GOPATH}/src/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \
crd \
output:dir=pkg/generated/crds/manifests \
paths=./pkg/apis/velero/v1/...

go generate ./pkg/generated/crds
69 changes: 69 additions & 0 deletions pkg/generated/crds/crds.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions pkg/generated/crds/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Package crds embeds the controller-tools generated CRD manifests
package crds

//go:generate go run ../../../hack/crd-gen/main.go
Loading

0 comments on commit 5e22f9c

Please sign in to comment.