Skip to content

Commit

Permalink
Dockerize and upgrade controller-gen to v0.5.0
Browse files Browse the repository at this point in the history
frameworks/constraint had previously been reliant on an outdated version
of the controller-gen library for generating CRDs with embedded
JSONSchemas.  The older version of the library wasn't built to detect
a nested JSONSchema, and thus would not refuse it.

With the requirement of v1 CRDs around the corner in k8s 1.22,
framework/constraint requires the newer controller-gen v0.5.0.  This
library version can output v1 CRD.

This PR _does not_ output a v1 CRD for Constraint Template.  That will
be left for a future PR.  This PR brings the library up-to-date and
dockerizes it, isolating the dependency from the developer machine.

Signed-off-by: juliankatz <juliankatz@google.com>
  • Loading branch information
julianKatz committed Apr 28, 2021
1 parent 804ff2e commit 6f0e4bb
Show file tree
Hide file tree
Showing 1,407 changed files with 153,818 additions and 43,580 deletions.
35 changes: 20 additions & 15 deletions constraint/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,29 @@ test: generate
install: manifests
kubectl apply -f config/crds

# Install the generation dependencies on the location machine
gen-dependencies:
GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.5.0
GO111MODULE=on go get k8s.io/code-generator/cmd/conversion-gen@v0.21.0

# Generate manifests e.g. CRD, RBAC etc.
manifests: buildutils
controller-gen all
kustomize build config -o deploy/crds.yaml
manifests:
controller-gen \
crd:crdVersions="v1beta1",allowDangerousTypes="true" \
paths="./pkg/..." \
output:crd:artifacts:config=config/crds
cp config/crds/* deploy/crds.yaml

lint:
golangci-lint -v run ./... --timeout 5m

# Generate code
generate: buildutils
ifndef GOPATH
$(error GOPATH not defined, please define GOPATH. Run "go help gopath" to learn more about GOPATH)
endif
export GOROOT=$(go env root)
GO111MODULE=off go generate ./pkg/...

# find or download controller-gen
# download controller-gen if necessary
.PHONY: buildutils
buildutils:
cd buildutils && ./buildutils.sh
# Not working? Try running `make gen-dependencies`
generate:
controller-gen \
object:headerFile=./hack/boilerplate.go.txt \
paths="./pkg/..."
conversion-gen \
--input-dirs "./pkg/apis/templates/..." \
--go-header-file=./hack/boilerplate.go.txt \
--output-file-base=zz_generated.conversion
5 changes: 0 additions & 5 deletions constraint/buildutils/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions constraint/buildutils/buildutils.sh

This file was deleted.

48 changes: 0 additions & 48 deletions constraint/buildutils/go.mod

This file was deleted.

Loading

0 comments on commit 6f0e4bb

Please sign in to comment.